[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: TAB when the region is active
From: |
Stefan Monnier |
Subject: |
Re: TAB when the region is active |
Date: |
Thu, 20 Sep 2007 09:52:21 -0400 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/23.0.50 (gnu/linux) |
>> > Here's my first try at doing this.
>> The change should not be in indent-according-to-mode, but in
>> indent-for-tab-command.
> If I do it like this:
> *** indent.el 26 Jul 2007 10:17:33 -0700 1.68
> --- indent.el 19 Sep 2007 18:29:56 -0700
> ***************
> *** 98,104 ****
> ((memq indent-line-function '(indent-relative indent-relative-maybe))
> (funcall indent-line-function))
> (t ;; The normal case.
> ! (indent-according-to-mode))))
> (defun insert-tab (&optional arg)
> (let ((count (prefix-numeric-value arg)))
> --- 101,110 ----
> ((memq indent-line-function '(indent-relative indent-relative-maybe))
> (funcall indent-line-function))
> (t ;; The normal case.
> ! (if (and transient-mark-mode mark-active
> ! (not (eq (region-beginning) (region-end))))
> ! (indent-region (region-beginning) (region-end))
> ! (indent-according-to-mode)))))
Please don't use an `if' in the tail of a `cond': just place the condition
directly in the `cond'.
> (defun insert-tab (&optional arg)
> (let ((count (prefix-numeric-value arg)))
> then indenting the region by pressing TAB does not work in c-mode
> anymore (it did work in my first try).
Sure. Some modes use the default behavior of TAB (e.g. it obeys
tab-always-indent), others override it. Those who override it have their
reason to do it, so we may want to tell them about it, but we shouldn't
impose it.
Putting the code in indent-according-to-mode will introduce bugs in code
that calls it specifically to indent a single line. It is just the
wrong place.
> Should c-mode also not bind TAB?
That's up to the maintainer of c-mode.
Stefan
- Re: TAB when the region is active, (continued)
- Re: TAB when the region is active, Richard Stallman, 2007/09/17
- Re: TAB when the region is active, Lennart Borgman (gmail), 2007/09/17
- RE: TAB when the region is active, Drew Adams, 2007/09/17
- Re: TAB when the region is active, Dan Nicolaescu, 2007/09/17
- Re: TAB when the region is active, Dan Nicolaescu, 2007/09/18
- RE: TAB when the region is active, Drew Adams, 2007/09/19
- Re: TAB when the region is active, Stefan Monnier, 2007/09/19
- RE: TAB when the region is active, Drew Adams, 2007/09/19
- Re: TAB when the region is active, Stefan Monnier, 2007/09/19
- Re: TAB when the region is active, Dan Nicolaescu, 2007/09/19
- Re: TAB when the region is active,
Stefan Monnier <=
- Re: TAB when the region is active, Dan Nicolaescu, 2007/09/21
- Re: TAB when the region is active, Juri Linkov, 2007/09/23
- RE: TAB when the region is active, Drew Adams, 2007/09/23
- Re: TAB when the region is active, Juri Linkov, 2007/09/23
- Re: TAB when the region is active, Stefan Monnier, 2007/09/23
- Re: M-q when the region is active (Re: TAB when the region is active), Juri Linkov, 2007/09/29
- Re: M-q when the region is active (Re: TAB when the region is active), Richard Stallman, 2007/09/30
- Re: TAB when the region is active, Richard Stallman, 2007/09/24
- Re: TAB when the region is active, Dan Nicolaescu, 2007/09/23
- Re: TAB when the region is active, Richard Stallman, 2007/09/24