[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: C-u prefix behavior of TAB broken
From: |
Miles Bader |
Subject: |
Re: C-u prefix behavior of TAB broken |
Date: |
Sat, 22 Dec 2007 22:48:23 +0900 |
martin rudalics <address@hidden> writes:
> For the case a prefix argument is given and the region is not active, we
> could try to set the region around the smallest containing form and call
> `indent-region' on that. But that would be a different feature.
Can't indent-for-tab-command simply, if there's a prefix argument given,
rigidly indent the following sexp by the change in indentation? That
doesn't seem hard at all, and matches the behavior I remember (perhaps
there are corner cases where it would differ, but I don't think I know
about them...).
For instance, the following isn't the most elegant code, but it seems to
do the right thing:
--- orig/lisp/indent.el
+++ mod/lisp/indent.el
@@ -99,13 +99,26 @@
(or (> (current-column) (current-indentation))
(eq this-command last-command))))
(insert-tab arg))
- ;; Those functions are meant specifically for tabbing and not for
- ;; indenting, so we can't pass them to indent-according-to-mode.
- ((memq indent-line-function '(indent-relative indent-relative-maybe))
- (funcall indent-line-function))
- ;; Indent the line.
(t
- (indent-according-to-mode))))
+ (let ((end-marker (and arg (save-excursion (forward-sexp) (point-marker))))
+ (old-indent (current-indentation)))
+
+ ;; Those functions are meant specifically for tabbing and not for
+ ;; indenting, so we can't pass them to indent-according-to-mode.
+ (if (memq indent-line-function '(indent-relative indent-relative-maybe))
+ (funcall indent-line-function)
+ ;; Indent the line.
+ (indent-according-to-mode))
+
+ ;; If a prefix argument was given, rigidly indent the following
+ ;; sexp to match the change in the current line's indentation.
+ ;;
+ (when arg
+ (let ((indentation-change (- (current-indentation) old-indent)))
+ (save-excursion
+ (forward-line 1)
+ (when (< (point) end-marker)
+ (indent-rigidly (point) end-marker indentation-change)))))))))
(defun insert-tab (&optional arg)
(let ((count (prefix-numeric-value arg)))
-Miles
--
"An atheist doesn't have to be someone who thinks he has a proof that there
can't be a god. He only has to be someone who believes that the evidence
on the God question is at a similar level to the evidence on the werewolf
question." [John McCarthy]
- C-u prefix behavior of TAB broken, Miles Bader, 2007/12/16
- Re: C-u prefix behavior of TAB broken, martin rudalics, 2007/12/17
- Re: C-u prefix behavior of TAB broken, Miles Bader, 2007/12/17
- Re: C-u prefix behavior of TAB broken, martin rudalics, 2007/12/17
- Re: C-u prefix behavior of TAB broken, Stefan Monnier, 2007/12/20
- Re: C-u prefix behavior of TAB broken, Richard Stallman, 2007/12/21
- Re: C-u prefix behavior of TAB broken, Miles Bader, 2007/12/21
- Re: C-u prefix behavior of TAB broken, martin rudalics, 2007/12/22
- Re: C-u prefix behavior of TAB broken,
Miles Bader <=
- Re: C-u prefix behavior of TAB broken, martin rudalics, 2007/12/22
- Re: C-u prefix behavior of TAB broken, Miles Bader, 2007/12/22
- Re: C-u prefix behavior of TAB broken, martin rudalics, 2007/12/22
- Re: C-u prefix behavior of TAB broken, Miles Bader, 2007/12/22
- Re: C-u prefix behavior of TAB broken, Stefan Monnier, 2007/12/22
- Re: C-u prefix behavior of TAB broken, Miles Bader, 2007/12/22
- Re: C-u prefix behavior of TAB broken, Stefan Monnier, 2007/12/23
- Re: C-u prefix behavior of TAB broken, Richard Stallman, 2007/12/22
- Re: C-u prefix behavior of TAB broken, martin rudalics, 2007/12/22
- Re: C-u prefix behavior of TAB broken, Richard Stallman, 2007/12/23