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: Juri Linkov
Subject: Re: C-u prefix behavior of TAB broken
Date: Sun, 24 Feb 2008 21:05:09 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (x86_64-amd64-linux-gnu)

> +      ;; 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))))))))))

I have bound a key to the command that calls `indent-for-tab-command'
with a prefix argument, and when I accidently type it a close parenthesis,
it fails with the error "Containing expression ends prematurely".

I think it would be better not to fail at such places, and just indent
the current line without indenting the following sexp.

The following patch fixes this.  Any better ideas?

Index: lisp/indent.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/indent.el,v
retrieving revision 1.76
diff -u -r1.76 indent.el
--- lisp/indent.el      8 Jan 2008 20:44:48 -0000       1.76
+++ lisp/indent.el      24 Feb 2008 19:04:32 -0000
@@ -29,6 +29,8 @@
 
 ;;; Code:
 
+(eval-when-compile (require 'cl)) ;; for `ignore-errors'
+
 (defgroup indent nil
   "Indentation commands."
   :group 'editing)
@@ -109,7 +111,7 @@
     (let ((end-marker
           (and arg
                (save-excursion
-                 (forward-line 0) (forward-sexp) (point-marker))))
+                 (forward-line 0) (ignore-errors (forward-sexp)) 
(point-marker))))
          (old-indent
           (current-indentation)))
 
-- 
Juri Linkov
http://www.jurta.org/emacs/




reply via email to

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