aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Mackenzie2014-11-05 18:38:51 +0000
committerAlan Mackenzie2014-11-05 18:38:51 +0000
commita2634462b873a00938811c4cbfa350b627124c96 (patch)
tree3544636c88763b348f0db1dd562f961b7ff7432e
parentceb7a7dfb8a2c2b17ac876e693d462ec65dcd97a (diff)
downloademacs-a2634462b873a00938811c4cbfa350b627124c96.tar.gz
emacs-a2634462b873a00938811c4cbfa350b627124c96.zip
Backport fix to bug #18749 to Emacs-24 branch.
-rw-r--r--lisp/ChangeLog7
-rw-r--r--lisp/progmodes/cc-engine.el21
2 files changed, 27 insertions, 1 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 111f98b8d4e..b83459503b4 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,10 @@
12014-10-18 Alan Mackenzie <acm@muc.de>
2
3 Check that a "macro" found near point-min isn't a ## operator.
4 Fixes bug #18749. Backported from trunk, 2014-11-05.
5 * progmodes/cc-engine.el (c-macro-is-genuine-p): New function.
6 (c-beginning-of-macro): Use the above new function.
7
12014-11-05 Alan Mackenzie <acm@muc.de> 82014-11-05 Alan Mackenzie <acm@muc.de>
2 9
3 Fix wrong bound to c-font-lock-declarators. Fixes bug #18948. 10 Fix wrong bound to c-font-lock-declarators. Fixes bug #18948.
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index f86e4b2c48a..3e14dd18397 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -248,6 +248,24 @@
248 (setq c-macro-cache-start-pos beg 248 (setq c-macro-cache-start-pos beg
249 c-macro-cache-syntactic nil)))) 249 c-macro-cache-syntactic nil))))
250 250
251(defun c-macro-is-genuine-p ()
252 ;; Check that the ostensible CPP construct at point is a real one. In
253 ;; particular, if point is on the first line of a narrowed buffer, make sure
254 ;; that the "#" isn't, say, the second character of a "##" operator. Return
255 ;; t when the macro is real, nil otherwise.
256 (let ((here (point)))
257 (beginning-of-line)
258 (prog1
259 (if (and (eq (point) (point-min))
260 (/= (point) 1))
261 (save-restriction
262 (widen)
263 (beginning-of-line)
264 (and (looking-at c-anchored-cpp-prefix)
265 (eq (match-beginning 1) here)))
266 t)
267 (goto-char here))))
268
251(defun c-beginning-of-macro (&optional lim) 269(defun c-beginning-of-macro (&optional lim)
252 "Go to the beginning of a preprocessor directive. 270 "Go to the beginning of a preprocessor directive.
253Leave point at the beginning of the directive and return t if in one, 271Leave point at the beginning of the directive and return t if in one,
@@ -278,7 +296,8 @@ comment at the start of cc-engine.el for more info."
278 (forward-line -1)) 296 (forward-line -1))
279 (back-to-indentation) 297 (back-to-indentation)
280 (if (and (<= (point) here) 298 (if (and (<= (point) here)
281 (looking-at c-opt-cpp-start)) 299 (looking-at c-opt-cpp-start)
300 (c-macro-is-genuine-p))
282 (progn 301 (progn
283 (setq c-macro-cache (cons (point) nil) 302 (setq c-macro-cache (cons (point) nil)
284 c-macro-cache-start-pos here) 303 c-macro-cache-start-pos here)