all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: Daniel Colascione <dan.colascione@gmail.com>
Cc: 7595@debbugs.gnu.org
Subject: bug#7595: Infinite loop in cc-mode, or the coming of autumn
Date: Thu, 16 Dec 2010 21:39:16 +0000	[thread overview]
Message-ID: <20101216213915.GA3442__49696.8405823738$1292537376$gmane$org@muc.de> (raw)
In-Reply-To: <4D000FF1.10307@gmail.com>

Hi again, Daniel!

On Wed, Dec 08, 2010 at 03:08:33PM -0800, Daniel Colascione wrote:
> In a c-mode buf,
> press pound, then back, then M-e
> See eternal loop
> 

Would you try out the following patch, please, which I hope fixes the
problem.  (The line numbers will be a little different, but don't worry
about that.)  Let me know how well it works!  Thanks.




*** orig/cc-cmds.el	2010-12-12 21:08:40.000000000 +0000
--- cc-cmds.el	2010-12-16 20:55:30.778431600 +0000
***************
*** 2422,2434 ****
  	  (goto-char last)
  	  (throw 'done '(nil . nil)))
  
! 	 ;; Stop if we encounter a preprocessor line.
! 	 ((and (not macro-end)
  	       (eq (char-after) ?#)
  	       (= (point) (c-point 'boi)))
! 	  (goto-char last)
! 	  ;(throw 'done (cons (eq (point) here) 'macro-boundary))) ; Changed 2003/3/26
! 	  (throw 'done '(t . macro-boundary)))
  
  	 ;; Stop after a ';', '}', or "};"
  	 ((looking-at ";\\|};?")
--- 2422,2435 ----
  	  (goto-char last)
  	  (throw 'done '(nil . nil)))
  
! 	 ;; Stop if we encounter a preprocessor line.  Continue if we hit a naked #
! 	 ((and c-opt-cpp-prefix
! 	       (not macro-end)
  	       (eq (char-after) ?#)
  	       (= (point) (c-point 'boi)))
! 	  (if (= (point) here)		; Not a macro, therefore naked #.
! 	      (forward-char)
! 	    (throw 'done '(t . macro-boundary))))
  
  	 ;; Stop after a ';', '}', or "};"
  	 ((looking-at ";\\|};?")
***************
*** 2627,2640 ****
  		;; Are we about to move forward into or out of a
  		;; preprocessor command?
  		(when (eq (cdr res) 'macro-boundary)
! 		  (save-excursion
! 		    (end-of-line)
! 		    (setq macro-fence
! 			  (and (not (eobp))
! 			       (progn (c-skip-ws-forward)
! 				      (c-beginning-of-macro))
! 			       (progn (c-end-of-macro)
! 				      (point))))))
  		;; Are we about to move forward into a literal?
  		(when (memq (cdr res) '(macro-boundary literal))
  		  (setq range (c-ascertain-following-literal)))
--- 2628,2646 ----
  		;; Are we about to move forward into or out of a
  		;; preprocessor command?
  		(when (eq (cdr res) 'macro-boundary)
! 		  (setq macro-fence
! 			(save-excursion
! 			  (if macro-fence
! 			      (progn
! 				(end-of-line)
! 				(and (not (eobp))
! 				     (progn (c-skip-ws-forward)
! 					    (c-beginning-of-macro))
! 				     (progn (c-end-of-macro)
! 					    (point))))
! 			    (and (not (eobp))
! 				 (c-beginning-of-macro)
! 				 (progn (c-end-of-macro) (point)))))))
  		;; Are we about to move forward into a literal?
  		(when (memq (cdr res) '(macro-boundary literal))
  		  (setq range (c-ascertain-following-literal)))


 
All the best!

-- 
Alan Mackenzie (Nuremberg, Germany).





  reply	other threads:[~2010-12-16 21:39 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-08 23:08 bug#7595: Infinite loop in cc-mode, or the coming of autumn Daniel Colascione
2010-12-16 21:39 ` Alan Mackenzie [this message]
2011-01-30 23:25   ` Daniel Colascione
2011-01-31 23:08     ` Chong Yidong
2011-03-06 23:35       ` Daniel Colascione
2011-03-07  4:46         ` Chong Yidong
2011-03-07  5:00         ` Chong Yidong
2011-03-07  5:15           ` Daniel Colascione
2011-03-07 19:54           ` Alan Mackenzie
2011-03-07 20:09             ` Chong Yidong
2011-03-07 21:02               ` Alan Mackenzie
2011-03-08  7:25                 ` Daniel Colascione
2011-03-07 20:55           ` Alan Mackenzie
2011-03-06 23:35       ` Daniel Colascione

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='20101216213915.GA3442__49696.8405823738$1292537376$gmane$org@muc.de' \
    --to=acm@muc.de \
    --cc=7595@debbugs.gnu.org \
    --cc=dan.colascione@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.