emacs-devel
[Top][All Lists]
Advanced

[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: Sun, 23 Dec 2007 07:59:08 +0900

martin rudalics <address@hidden> writes:
>> +    (let ((indentation-change (- (current-indentation) old-indent)))
>
> `lisp-indent-line' quits here when `indentation-change' equals zero.

Good point (fixed below).

-Miles


--- orig/lisp/indent.el
+++ mod/lisp/indent.el
@@ -86,10 +86,10 @@
 indent the region.
 The function actually called to indent the line is determined by the value of
 `indent-line-function'."
-  (interactive "p")
+  (interactive "P")
   (cond
    ;; The region is active, indent it.
-   ((and arg transient-mark-mode mark-active
+   ((and transient-mark-mode mark-active
         (not (eq (region-beginning) (region-end))))
     (indent-region (region-beginning) (region-end)))
    ((or ;; indent-to-left-margin is only meant for indenting,
@@ -99,13 +99,27 @@
             (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-line 0) (forward-sexp) (point-marker))))
+         (old-indent
+          (current-indentation)))
+
+      ;; Indent the line.
+      (funcall indent-line-function)
+
+      ;; 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)))
+         (unless (zerop indentation-change)
+           (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)))


-- 
The car has become... an article of dress without which we feel uncertain,
unclad, and incomplete.  [Marshall McLuhan, Understanding Media, 1964]




reply via email to

[Prev in Thread] Current Thread [Next in Thread]