unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Minor bug in c-beginning-of-defun.  May I fix it?
@ 2007-04-17 18:21 Alan Mackenzie
  2007-04-17 19:07 ` Chong Yidong
  0 siblings, 1 reply; 5+ messages in thread
From: Alan Mackenzie @ 2007-04-17 18:21 UTC (permalink / raw)
  To: Chong Yidong, emacs-devel

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  <acm@muc.de>

	* 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).

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-04-17 20:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-17 18:21 Minor bug in c-beginning-of-defun. May I fix it? Alan Mackenzie
2007-04-17 19:07 ` Chong Yidong
2007-04-17 19:47   ` Alan Mackenzie
2007-04-17 20:04     ` Chong Yidong
2007-04-17 20:50       ` Alan Mackenzie

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).