Emilia Smólska <[email protected]> wrote:
> For the issue of not being able to force-insert tabs in c-mode conveniently
> I had two potential solutions, one to simply make the tab key selfinsert after
> fixing the indentation (if one wants only the indentation fix and not the
> self-insert, they can backspace the tab immediately), and one to bind
> something like C-M-i (ESC TAB) to a function that inserts a tab without regard
> for proper indentation, however I couldn't quite figure out how to make that
> work as a binding registered by c-mode itself, without modifying the
> fundamental keymap; the keymap structures are a bit confusing...
>
> I would appreciate some words from someone more familiar with mg internals
> (op@?) on my ideas and thoughts on trying to improve c-mode in general :)
>
> The below is a diff that makes TAB also self-insert in c-mode:
this seems a bit too harsh to use, personally speaking.
i think a desiderable outcome would be:
- user press tab:
-> was the line indented?
if yes, do nothing else
if no, insert tab
unfortunately, it's not as easy ahah. cc_indent() first deletes the
leading whitespaces with delleadwhite(), then indents the line, which
has the added problem of marking the buffer as modified even when there
was nothing to reindent, so we cannot check the changed flag on the
buffer.
another way, would be to save the current position before the indent,
and if it didn't changed do the literal insert.
i'd propend more for the first one, since it would also fix a bug in the
process, but it's not trivial to do.
don't have time right now to attempt to implement it, i'll try a bit
later if you don't beat me to it :P
Thanks!
Omar Polo
P.S. it's fine to mail tech@ for these kind of stuff IMHO.