From: Dan Nicolaescu <dann@ics.uci.edu>
To: "Lennart Borgman \(gmail\)" <lennart.borgman@gmail.com>
Cc: rms@gnu.org, Drew Adams <drew.adams@oracle.com>, emacs-devel@gnu.org
Subject: Re: TAB when the region is active
Date: Tue, 18 Sep 2007 20:42:51 -0700 [thread overview]
Message-ID: <200709190342.l8J3gpHQ020774@oogie-boogie.ics.uci.edu> (raw)
In-Reply-To: <200709172328.l8HNSCK9001067@oogie-boogie.ics.uci.edu> (Dan Nicolaescu's message of "Mon\, 17 Sep 2007 16\:28\:12 -0700")
Dan Nicolaescu <dann@ics.uci.edu> writes:
> "Lennart Borgman (gmail)" <lennart.borgman@gmail.com> writes:
>
> > Richard Stallman wrote:
> > > > The idea is logical, but we need to ask users if they find the change
> > > > annoying.
> > >
> > > Given that we are not close to a release, this would be a good time to
> > > experiment. Can you please OK such a change?
> > >
> > > I will ok trying it, if you agree to follow up in a few weeks
> > > by reminding people to try it and say if they don't like it.
> >
> >
> > The code below is what I currently use. There are some problems I know
> > about:
Here's my first try at doing this. lisp-mode needed changes because it
binds TAB differently...
Can you please give it a spin?
Does anything need to be done for the case where TAB is used to insert
a tab character? (I don't know when that is supposed to happen and
what is the expected behavior...)
*** indent.el 26 Jul 2007 10:17:33 -0700 1.68
--- indent.el 18 Sep 2007 08:38:25 -0700
***************
*** 75,81 ****
(indent-line-to column)
(save-excursion (indent-line-to column))))
;; The normal case.
! (funcall indent-line-function)))
(defun indent-for-tab-command (&optional arg)
"Indent line in proper way for current major mode or insert a tab.
--- 75,84 ----
(indent-line-to column)
(save-excursion (indent-line-to column))))
;; The normal case.
! (if (and transient-mark-mode mark-active
! (not (eq (region-beginning) (region-end))))
! (indent-region (region-beginning) (region-end))
! (funcall indent-line-function))))
(defun indent-for-tab-command (&optional arg)
"Indent line in proper way for current major mode or insert a tab.
*** emacs-lisp/lisp-mode.el 20 Aug 2007 15:47:53 -0700 1.207
--- emacs-lisp/lisp-mode.el 18 Sep 2007 08:46:08 -0700
***************
*** 261,267 ****
(defvar lisp-mode-shared-map
(let ((map (make-sparse-keymap)))
! (define-key map "\t" 'lisp-indent-line)
(define-key map "\e\C-q" 'indent-sexp)
(define-key map "\177" 'backward-delete-char-untabify)
;; This gets in the way when viewing a Lisp file in view-mode. As
--- 261,267 ----
(defvar lisp-mode-shared-map
(let ((map (make-sparse-keymap)))
! (define-key map "\t" 'lisp-indent-line-or-region)
(define-key map "\e\C-q" 'indent-sexp)
(define-key map "\177" 'backward-delete-char-untabify)
;; This gets in the way when viewing a Lisp file in view-mode. As
***************
*** 828,833 ****
--- 828,841 ----
(> end beg))
(indent-code-rigidly beg end shift-amt)))))
+ (defun lisp-indent-line-or-region (&optional whole-exp)
+ "Indent the current line or the region if it is active."
+ (interactive "P")
+ (if (and transient-mark-mode mark-active
+ (not (eq (region-beginning) (region-end))))
+ (lisp-indent-region (region-beginning) (region-end))
+ (lisp-indent-line whole-exp)))
+
(defvar calculate-lisp-indent-last-sexp)
(defun calculate-lisp-indent (&optional parse-start)
next prev parent reply other threads:[~2007-09-19 3:42 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-09-14 21:59 TAB when the region is active Dan Nicolaescu
2007-09-16 5:35 ` Richard Stallman
2007-09-17 4:09 ` Dan Nicolaescu
2007-09-17 22:24 ` Richard Stallman
2007-09-17 22:40 ` Lennart Borgman (gmail)
2007-09-17 22:47 ` Drew Adams
2007-09-17 23:28 ` Dan Nicolaescu
2007-09-19 3:42 ` Dan Nicolaescu [this message]
2007-09-19 5:11 ` Drew Adams
2007-09-19 13:45 ` Stefan Monnier
2007-09-19 14:34 ` Drew Adams
2007-09-19 13:45 ` Stefan Monnier
2007-09-20 1:54 ` Dan Nicolaescu
2007-09-20 13:52 ` Stefan Monnier
2007-09-22 1:00 ` Dan Nicolaescu
2007-09-24 0:07 ` Juri Linkov
2007-09-24 1:09 ` Drew Adams
2007-09-24 1:15 ` Juri Linkov
2007-09-24 3:50 ` Stefan Monnier
2007-09-29 23:18 ` M-q when the region is active (Re: TAB when the region is active) Juri Linkov
2007-09-30 12:54 ` Richard Stallman
2007-10-06 22:43 ` M-$ when the region is active (Re: M-q " Juri Linkov
2007-09-24 18:20 ` TAB when the region is active Richard Stallman
2007-09-24 2:37 ` Dan Nicolaescu
2007-09-24 18:20 ` Richard Stallman
2007-09-17 23:13 ` Dan Nicolaescu
2007-09-16 18:48 ` Lennart Borgman
2007-09-16 19:17 ` Paul Pogonyshev
2007-09-16 20:32 ` Drew Adams
2007-09-17 3:59 ` Richard Stallman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200709190342.l8J3gpHQ020774@oogie-boogie.ics.uci.edu \
--to=dann@ics.uci.edu \
--cc=drew.adams@oracle.com \
--cc=emacs-devel@gnu.org \
--cc=lennart.borgman@gmail.com \
--cc=rms@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).