lijunsong / pollen-mode

An Emacs major mode for editing in pollen markup language
GNU Lesser General Public License v3.0
42 stars 9 forks source link

Indentation width #15

Closed ghost closed 7 years ago

ghost commented 7 years ago

Hello, I just started to use Emacs and pollen-mode but when I hit TAB I'm getting 8 spaces and I would like to get only 2, so I was wondering how to change that if possible. Thanks!

ylluminarious commented 7 years ago

Put (setq tab-width 2) in your init files or do M-x customize-variable RET tab-width RET and put 2 in the input field instead of 8.

ghost commented 7 years ago

Thank you so much @ylluminarious, I already had setq tab-width 2 on my init file but it wasn't working, so I did the second option and looks like is good now. Although there is an issue but I don't know if is actually a problem or just a mistake in my formating; It looks like it's inferring the indentation in ways that I don't expect instead of always using 2 spaces.

For example, I have this:

◊title{Lorem ipsum dolor sit amet, consectetur adipiscing elit
◊small{Lorem ipsum dolor sit amet, consectetur adipiscing elit}
}

And these are all the different indentations I get:

image

image

image

This is the correct one, but I have to add the content in a new line and indent it, so the second line gets indented correctly.

image

In other places looks like it works correctly. But I can live with that, I just have to organize the code where tabs work. If that's an expected behavior then this issue can be closed. Thank you again.

ylluminarious commented 7 years ago

@jameskolce Hmm, I'm not sure about that; maybe @lijunsong knows the correct behavior here?

lijunsong commented 7 years ago

Hi @jameskolce ,

(I am not sure why I didn't get notification until now.)

@ylluminarious got it partially right. Emacs default TAB does multiple things in different context: completion, indent line to align with the preceding line, insert TAB, etc. What you've configured is just one behavior of the TAB. It seems what you want from the normal TAB is to always insert two whitespace, is it?

Pollen-mode modifies Emacs default TAB behavior only when lozenge precedes the cursor. I think you need to customize your emacs's default TAB behavior, which is documented in indent-for-tab-command function.

Don't hesitate to follow up if you need any help on configuration.

ghost commented 7 years ago

Thanks @lijunsong! I'll try to work with the current settings and see how it feels, so far is working fine in most parts but if I start getting problems then I'll look into the function you mentioned.

Thanks again!

lijunsong commented 7 years ago

Sure. I'd love to help if you need anything.