commit/cc-mode: acm: Check that a "macro" found near point-min isn't a ## operator.

[email protected] Sat, 18 Oct 2014 10:34:55 -0000
Newsgroups gmane.emacs.xemacs.patches
Message-ID <[email protected]>
1 new commit in cc-mode:

https://bitbucket.org/xemacs/cc-mode/commits/3b8ae6d070a7/
Changeset:   3b8ae6d070a7
User:        acm
Date:        2014-10-18 10:21:56+00:00
Summary:     Check that a "macro" found near point-min isn't a ## operator.
Fixes Emacs bug #18749.
cc-engine.el (c-macro-is-genuine-p): New function.
(c-beginning-of-macro): Use the above new function.
Affected #:  1 file

diff -r d642888abd550fb46cb98c83fb8b37a340fc9dc6 -r 3b8ae6d070a74023f7ab1897c5ac79965cb93cb1 cc-engine.el
--- a/cc-engine.el
+++ b/cc-engine.el
@@ -254,6 +254,24 @@
     (setq c-macro-cache-start-pos beg
 	  c-macro-cache-syntactic nil))))
 
+(defun c-macro-is-genuine-p ()
+  ;; Check that the ostensible CPP construct at point is a real one.  In
+  ;; particular, if point is on the first line of a narrowed buffer, make sure
+  ;; that the "#" isn't, say, the second character of a "##" operator.  Return
+  ;; t when the macro is real, nil otherwise.
+  (let ((here (point)))
+    (beginning-of-line)
+    (prog1
+	(if (and (eq (point) (point-min))
+		 (/= (point) 1))
+	    (save-restriction
+	      (widen)
+	      (beginning-of-line)
+	      (and (looking-at c-anchored-cpp-prefix)
+		   (eq (match-beginning 1) here)))
+	  t)
+      (goto-char here))))
+
 (defun c-beginning-of-macro (&optional lim)
   "Go to the beginning of a preprocessor directive.
 Leave point at the beginning of the directive and return t if in one,
@@ -284,7 +302,8 @@
 	    (forward-line -1))
 	  (back-to-indentation)
 	  (if (and (<= (point) here)
-		   (looking-at c-opt-cpp-start))
+		   (looking-at c-opt-cpp-start)
+		   (c-macro-is-genuine-p))
 	      (progn
 		(setq c-macro-cache (cons (point) nil)
 		      c-macro-cache-start-pos here)

Repository URL: https://bitbucket.org/xemacs/cc-mode/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.