siduck / chadwm

Making dwm as beautiful as possible!
MIT License
2.25k stars 169 forks source link

spaces and tabs #187

Closed erikdubois closed 3 months ago

erikdubois commented 4 months ago

Checking code for spaces and tabs

MinePro120 commented 4 months ago

This is something I wanted to do for some time since the indentation of code seems so to be quite inconsistent (I assume because of the patches). Perhaps you could use the tool indent (maybe with some arguments) to automatically format all the source files. I would also assume that the config file needs some manual tweaking, especially the comments. Some variables also need to be renamed so they are on the same case (for example, new_window_attach_on_end to newwindowattachonend) and the code should also be populated with comments so that we know where each patch is located in the code. These could all be separate PRs though.

erikdubois commented 4 months ago

We can also agree to use visual studio code (or something else) and choose between extensions and have a uniform layout/indentation that way

erikdubois commented 4 months ago

To use the indent command to apply a universal indentation style to all your files, you can use it with the appropriate options to match your desired coding style. Here's an example of how to use the indent command to format a file and some common options you might want to use:

Basic Usage

indent filename.c

This command will format the file filename.c according to the default style.

Common Options

Here are some common options you might use to customize the formatting:

Example Command

To apply a universal indent style, such as the GNU style with 4-space indentation and no tabs, you would use:

indent -gnu -i4 -nut -ts4 filename.c

Applying to Multiple Files

To apply this to all your C source files in the current directory, you can use a loop or find command in your shell:

Using a Loop

for file in *.c; do
    indent -gnu -i4 -nut -ts4 "$file"
done

Using find

find . -name '*.c' -exec indent -gnu -i4 -nut -ts4 {} \;

Creating a Configuration File

If you want to avoid typing the options every time, you can create a configuration file named .indent.pro in your home directory or the root of your project:

.indent.pro Content

-gnu
-i4
-nut
-ts4

Usage

Once you have the .indent.pro file set up, you can simply run:

indent filename.c

Or to apply it to all C files:

for file in *.c; do
    indent "$file"
done

Or:

find . -name '*.c' -exec indent {} \;

Summary

By using the indent command with appropriate options or a configuration file, you can ensure a consistent indentation style across all your files. The provided examples show how to apply the formatting to individual files or all files in a directory.

I guess you need to decide how you want your code to become

erikdubois commented 4 months ago

new_window_attach_on_end

I would prefer keeping the underscores for readability

only 4 references

image

erikdubois commented 4 months ago

we can decide on indentation maybe at the end when we have merged more code into your github if you are willing to accept more code?

erikdubois commented 4 months ago

idea : shall we open up discussions on your github of chadwm to be able to communicate faster/better image

erikdubois commented 4 months ago

maybe this one ?

indent -kr -i4 -ts4 drw.c

siduck commented 3 months ago

idea : shall we open up discussions on your github of chadwm to be able to communicate faster/better image

https://github.com/siduck/chadwm/discussions