Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
How to customize <tab> behavior?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
whzhao@gmail.com  
View profile  
 More options May 24 2007, 6:17 pm
Newsgroups: comp.emacs
From: "whz...@gmail.com" <whz...@gmail.com>
Date: 24 May 2007 15:17:31 -0700
Local: Thurs, May 24 2007 6:17 pm
Subject: How to customize <tab> behavior?
Hi,

In cc mode, I like to customize <tab> behavior as follows.

If the pointer is before a statement, then <tab> is bind to c-indent-
command, otherwise (or if the pointer is after a statement), <tab> is
bind to indent-relative.

How to do this???

Many thanks.

--
Wenhua


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Emilio Lopes  
View profile  
 More options May 25 2007, 4:50 pm
Newsgroups: comp.emacs
From: Emilio Lopes <ec...@gmx.net>
Date: Fri, 25 May 2007 22:50:34 +0200
Local: Fri, May 25 2007 4:50 pm
Subject: Re: How to customize <tab> behavior?

whzhao@gmail com writes:
> If the pointer is before a statement, then <tab> is bind to c-indent-
> command, otherwise (or if the pointer is after a statement), <tab> is
> bind to indent-relative.
> How to do this???

Nice idea.  The code bellow is barely tested and works not only in
C-mode:

   (defun indent-dwim ()
     "Indent line or move point to the next indent point."
     (interactive "*")
     (if (looking-back "^\\s-*")
         (indent-for-tab-command)
       (indent-relative)))

--
Emílio C. Lopes                            Ich leb und weiß nit wie lang,
Munich, Germany                            ich stirb und weiß nit wann,
                                           ich fahr und weiß nit wohin,
                 (Martinus von Biberach)   mich wundert, dass ich fröhlich bin!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Miles Bader  
View profile  
 More options May 25 2007, 9:12 pm
Newsgroups: comp.emacs
From: Miles Bader <mi...@gnu.org>
Date: Sat, 26 May 2007 10:12:11 +0900
Local: Fri, May 25 2007 9:12 pm
Subject: Re: How to customize <tab> behavior?

"whz...@gmail.com" <whz...@gmail.com> writes:
> In cc mode, I like to customize <tab> behavior as follows.

What version of Emacs?

In the current CVS emacs (about to be released as Emacs 22), the
document for c-indent-command (bounded to TAB) says:

   TAB (translated from <tab>) runs the command c-indent-command
   ...
   Indent current line as C code, and/or insert some whitespace.

   If `c-tab-always-indent' is t, always just indent the current line.
   If nil, indent the current line only if point is at the left margin or
   in the line's indentation; otherwise insert some whitespace[*].  If
   other than nil or t, then some whitespace[*] is inserted only within
   literals (comments and strings), but the line is always reindented.
   ...
     [*] The amount and kind of whitespace inserted is controlled by the
     variable `c-insert-tab-function', which is called to do the actual
     insertion of whitespace.  Normally the function in this variable
     just inserts a tab character, or the equivalent number of spaces,
     depending on the variable `indent-tabs-mode'.

-Miles

--
P.S.  All information contained in the above letter is false,
      for reasons of military security.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Giorgos Keramidas  
View profile  
 More options May 25 2007, 9:41 pm
Newsgroups: comp.emacs
From: Giorgos Keramidas <keram...@ceid.upatras.gr>
Date: Sat, 26 May 2007 04:41:09 +0300
Local: Fri, May 25 2007 9:41 pm
Subject: Re: How to customize <tab> behavior?
On 24 May 2007 15:17:31 -0700, "whz...@gmail.com" <whz...@gmail.com> wrote:

> Hi,
> In cc mode, I like to customize <tab> behavior as follows.

> If the pointer is before a statement, then <tab> is bind to c-indent-
> command, otherwise (or if the pointer is after a statement), <tab> is
> bind to indent-relative.

> How to do this???

Look at the documentation of `c-indent-command'.  It contains several
useful hints.  Unless I misunderstood what you wrote, one of them is
exactly what you are looking for:

,---[ C-h f c-indent-command ]------------------------------------------
| c-indent-command is an interactive compiled Lisp function in `cc-cmds.el'.
| (c-indent-command &optional ARG)
|
| Indent current line as C code, and/or insert some whitespace.
|
| If `c-tab-always-indent' is t, always just indent the current line.
| If nil, indent the current line only if point is at the left margin or
| in the line's indentation; otherwise insert some whitespace[*].  If
| other than nil or t, then some whitespace[*] is inserted only within
| literals (comments and strings), but the line is always reindented.
|
| If `c-syntactic-indentation' is t, indentation is done according to
| the syntactic context.  A numeric argument, regardless of its value,
| means indent rigidly all the lines of the expression starting after
| point so that this line becomes properly indented.  The relative
| indentation among the lines of the expression is preserved.
|
| If `c-syntactic-indentation' is nil, the line is just indented one
| step according to `c-basic-offset'.  In this mode, a numeric argument
| indents a number of such steps, positive or negative, and an empty
| prefix argument is equivalent to -1.
|
|   [*] The amount and kind of whitespace inserted is controlled by the
|   variable `c-insert-tab-function', which is called to do the actual
|   insertion of whitespace.  Normally the function in this variable
|   just inserts a tab character, or the equivalent number of spaces,
|   depending on the variable `indent-tabs-mode'.
`-----------------------------------------------------------------------


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
whzhao@gmail.com  
View profile  
 More options May 26 2007, 2:59 am
Newsgroups: comp.emacs
From: "whz...@gmail.com" <whz...@gmail.com>
Date: 25 May 2007 23:59:22 -0700
Local: Sat, May 26 2007 2:59 am
Subject: Re: How to customize <tab> behavior?
> ,---[ C-h f c-indent-command ]------------------------------------------
> | c-indent-command is an interactive compiled Lisp function in `cc-cmds.el'.
> | (c-indent-command &optional ARG)
> |
> | Indent current line as C code, and/or insert some whitespace.
> |
> | If `c-tab-always-indent' is t, always just indent the current line.

This is what I want.  Thanks.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »