jed-users mailing list

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

Re: Re: redo in jed CUA mode


On Wed, 11 Dec 2002 19:36:50 +0800 wrote Andy Sy <andy@xxxxxxxxxxx>:

> > > 1) Why doesn't TAB do anything?
> Help->Show_Key says it is bound to indent_line(). But 
> when I press TAB nothing gets inserted/nothing happens.
>   
> > > 2) How do we make TAB and SHIFT-TAB indent/undent 
> > > a highlighted region?
> > 
> > Bind it to indent_region_or_line(). (See attached cuamisc.sl)
> 
> It doesn't seem to be working on my end. Even
> a manual invocation of indent_region_or_line
> via M-x does not seem to be doing anything.

Maybe, your line/region is already correctly indented? See the help for
indent_line:

 DESCRIPTION
   The `indent_line' line function indents the current line in a manner
   which depends upon the current buffer.  The actual function that gets
   called is set via a prior call the `set_buffer_hook' to set the indent
   hook.  The default value is to indent the line to the indentation
   level of the previous line.


The language-modes (python_mode, slang_mode, c_mode, ...) set the buffer hook
(description of hooks is in Help->Browse-Docs->hooks.txt).

When programming, I really appreciate this feature, as it indents e.g.
inserted lines automatically to the right level. Also, it is a kind of
syntax-check, as an unexpected indentation action is normally a sign for a
missing ")" or ";"!


If you want the TAB key to do some kind of "soft-tabbing" (i.e. skip to the
next begin-of-word in the line above) in text-mode, bind the
text_indent_relative() function to the indent_hook:


% newline_and_indent for structured text: indent to level of preceding line
% we have to redefine, as the default uses the indent_hook which does
% something different
define st_newline_and_indent ()
{
   variable c0 = what_column;
   % get number of leading spaces
   push_spot();
   bol_skip_white ();
   variable c = what_column;
   if (c > c0)  % more whitespace than the calling points column
     c = c0;
   pop_spot();
   newline();
   whitespace(c-1);
}

public define text_mode_hook ()
{
   set_buffer_hook("indent_hook", &text_indent_relative);
   set_buffer_hook("newline_indent_hook", &st_newline_and_indent);
}

However, I have bound TAB to indent_region_or_line() and Shift-TAB directly
to text_indent_relative. This way the bindings are kind of consitent over
the modes.

(BTW: For exploring the functionality of jed and slang-programming, I
recommend the extended help browser from the jmr:
      http://jedmodes.sf.net/devel 
It offers a kind of linkings: 
  * In a *.sl file press Shift-F1 (say) to see the help for the word under 
    the cursor. 
  * In the help press Enter on a "link" to go to a related function's help 
    or W to find out what key this function is bound to.
  * Find all functions containing a regexp in their name with apropos (this
    is in the standard help too) and jump from the list to the help texts
    just moving there and pressing Enter or double clicking.
  * Go back to the last help topic with the history feature.  
  * many many more  
)

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]