jed-users mailing list

[2002 Date Index] [2002 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

TAB and indent_hook (was: Reindent an entire C code in one shot)


On Thu, 21 Nov 2002 12:20:14 -0500 wrote "John E. Davis" <davis@xxxxxxxxxxxxx>:

 
> >I know about the solution to reset the TAB key with the global-mode hook.
> >Still I wonder, whether it would be more clean to
> 
>   I think that the solution is to remove explicit tab key bindings
> from the code and rely soleup upon the indent_line_hook functions.
> The default binding of the tab key could be to the "indent_line"
> functions.  Then if the user does not like the smart indentation by
> the tab key, the user can simply bind if to, e.g., "self_insert_cmd".

This is exactly what I wanted to say.
 
>   Do you see a problem with this proposed scheme?

Yes (maybe only a request for documentation). 

Example: I'd like to have the Tabulator key as "smart tabulator", i.e. I set

  define text_mode_hook ()
  {
     set_buffer_hook( "indent_hook", "text_indent_relative");
  }

However, now every new line get indendet to the start of the second word in
the previous line! (The same would happen if I use the "indent_hook" to make
tab insert a literal tab in just one mode: Return would insert a new line
and a "\t".)

One solution is to set the "newline_indent_hook" explicitely to indent
to the level of the preceding line (or something more elaborated, maybe).

(Maybe a cange in hooks.txt would suffice:

 "newline_indent_hook"

     If this hook exists, it will be called by the newline_and_indent
     function.  It takes no arguments and returns nothing.
+    If it doesnot exist, the newline_and_indent function uses the
+    "indent_hook" for indendation (if existent, of course).


Another solution would be

  define text_mode_hook ()
     local_setkey("text_indent_relative", "\t");

which, however, would not help in modes that don't define a keymap (no-mode,
say).

Günter


--
Milde at ife.et.tu-dresden.de


--------------------------
To unsubscribe send email to <jed-users-request@xxxxxxxxxxx> with
the word "unsubscribe" in the message body.
Need help? Email <jed-users-owner@xxxxxxxxxxx>.


[2002 date index] [2002 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]