[
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:
2007年12月23日 04:52:46 +0900
martin rudalics <address@hidden> writes:
> For `tab-always-indent' t it might make sense to do `beginning-of-line'
> before the `forward-sexp'.
True. It doesn't reach that code at all if tab-always-indent is nil and
the point is not in the indentation, so I think it can just always move
to the start of the line before calling forward-sexp.
> BTW, isn't
>
> ((memq indent-line-function '(indent-relative indent-relative-maybe))
> (funcall indent-line-function))
> ;; Indent the line.
> (t
> (indent-according-to-mode))
>
> semantically equivalent to
>
> (t
> (funcall indent-line-function))
Indeed yes! That's a nice simplification...
I fixed some other little problems (e.g. it should have been using "P"
[raw-prefix] in the interactive spec), so here's the current patch:
--- 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,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-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)))
+ (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)))
--
Ich bin ein Virus. Mach' mit und kopiere mich in Deine .signature.
- 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, 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 <=
- 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日
- Re: C-u prefix behavior of TAB broken , martin rudalics, 2007年12月23日
- Re: C-u prefix behavior of TAB broken , Richard Stallman, 2007年12月24日