emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Small `c-electric-paren' fix


From: David Hansen
Subject: Small `c-electric-paren' fix
Date: Sat, 31 Mar 2007 14:15:46 +0200
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.95 (gnu/linux)

Hello,

I've already send this to the cc-mode list some time ago (X-Post
anyway) but seems the maintainer is kinda busy.  Can someone else
please take care of it?  It's clearly a bug and the fix is pretty
short and obvious.

To reproduce:

(defun dh-c-mode-hook ()
  (push 'space-before-funcall c-cleanup-list))

(add-hook 'c-mode-hook #'dh-c-mode-hook)


Now open some .c file and type some parenthesis.  A space is
automatically inserted even if the paren is not a function call.

Fix:

Index: lisp/progmodes/cc-cmds.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/progmodes/cc-cmds.el,v
retrieving revision 1.55
diff -u -r1.55 cc-cmds.el
--- lisp/progmodes/cc-cmds.el   30 Mar 2007 20:20:35 -0000      1.55
+++ lisp/progmodes/cc-cmds.el   31 Mar 2007 09:27:03 -0000
@@ -1262,11 +1262,11 @@
                     (backward-char)
                     (skip-chars-backward " \t")
                     (setq beg (point))
-                    (c-save-buffer-state () (c-on-identifier))
-                    ;; Don't add a space into #define FOO()....
-                    (not (and (c-beginning-of-macro)
-                              (c-forward-over-cpp-define-id)
-                              (eq (point) beg)))))
+                    (and (c-save-buffer-state () (c-on-identifier))
+                          ;; Don't add a space into #define FOO()....
+                          (not (and (c-beginning-of-macro)
+                                    (c-forward-over-cpp-define-id)
+                                    (eq (point) beg))))))
              (save-excursion
                (delete-region beg end)
                (goto-char beg)





reply via email to

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