[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Minor bug in c-beginning-of-defun. May I fix it?
From: |
Alan Mackenzie |
Subject: |
Minor bug in c-beginning-of-defun. May I fix it? |
Date: |
17 Apr 2007 20:21:42 +0200 |
Date: |
Tue, 17 Apr 2007 20:41:47 +0100 |
User-agent: |
Mutt/1.5.9i |
Hi, Chong and Emacs!
Open (for example) ..../src/cmds.c and move point to within the braces
of the last function, `keys_of_cmds'. Do M-- C-M-a.
Since there is no next defun, point should be left at EOB. It is,
sadly, erroneously left after the last closing brace.
The fix is straightforward: The third argument NOERROR to a
`c-syntactic-re-search-forward' should not be t; it should be something
else non-nil. So, when a search fails, point will be left at EOB rather
than unmoved. The argument `NOERROR' here has the same meaning it does
in the Emacs core function `search-forward-regexp'.
I believe this patch is safe and trouble free. Please tell me to commit
it!
2007-04-17 Alan Mackenzie <address@hidden>
* progmodes/cc-cmds.el (c-beginning-of-defun): With -ve arg and
point too close to EOB, leave point at EOB rather than last `}'.
Index: cc-cmds.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/progmodes/cc-cmds.el,v
retrieving revision 1.58
diff -c -r1.58 cc-cmds.el
*** cc-cmds.el 9 Apr 2007 10:51:29 -0000 1.58
--- cc-cmds.el 17 Apr 2007 18:04:26 -0000
***************
*** 1531,1537 ****
(setq arg (c-forward-to-nth-EOF-} (- arg) where)))
;; Move forward to the next opening brace....
(when (and (= arg 0)
! (c-syntactic-re-search-forward "{" nil t))
(backward-char)
;; ... and backward to the function header.
(c-beginning-of-decl-1)
--- 1531,1537 ----
(setq arg (c-forward-to-nth-EOF-} (- arg) where)))
;; Move forward to the next opening brace....
(when (and (= arg 0)
! (c-syntactic-re-search-forward "{" nil 'eob))
(backward-char)
;; ... and backward to the function header.
(c-beginning-of-decl-1)
--
Alan Mackenzie (Ittersbach, Germany).
- Minor bug in c-beginning-of-defun. May I fix it?,
Alan Mackenzie <=