[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: TAB when the region is active
From: |
Dan Nicolaescu |
Subject: |
Re: TAB when the region is active |
Date: |
Tue, 18 Sep 2007 20:42:51 -0700 |
Dan Nicolaescu <address@hidden> writes:
> "Lennart Borgman (gmail)" <address@hidden> 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)
- TAB when the region is active, Dan Nicolaescu, 2007/09/14
- Re: TAB when the region is active, Richard Stallman, 2007/09/16
- Re: TAB when the region is active, Dan Nicolaescu, 2007/09/17
- 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 <=
- 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, 2007/09/20
- 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