aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Mackenzie2014-10-18 10:02:59 +0000
committerAlan Mackenzie2014-10-18 10:02:59 +0000
commit605cfb8b7a4ef8f73ddc8f2de5c086f3a7455971 (patch)
treed1547a365dc150ed909f82068d63d89ede926c82
parent4b6d6e69098ec2c823b637a82e1c3fb10539f7b0 (diff)
downloademacs-605cfb8b7a4ef8f73ddc8f2de5c086f3a7455971.tar.gz
emacs-605cfb8b7a4ef8f73ddc8f2de5c086f3a7455971.zip
Check that a "macro" found near point-min isn't a ## operator. Fixes
bug #18749. progmodes/cc-engine.el (c-macro-is-genuine-p): New function. (c-beginning-of-macro): Use the above new function.
-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 0da7f2877e1..0e99febb366 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.
5 * progmodes/cc-engine.el (c-macro-is-genuine-p): New function.
6 (c-beginning-of-macro): Use the above new function.
7
12014-10-18 Teodor Zlatanov <tzz@lifelogs.com> 82014-10-18 Teodor Zlatanov <tzz@lifelogs.com>
2 9
3 * net/gnutls.el (gnutls-negotiate): Don't use cl-mapcan; pass 10 * net/gnutls.el (gnutls-negotiate): Don't use cl-mapcan; pass
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index 9a2531d1e99..ccc3f067571 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -249,6 +249,24 @@
249 (setq c-macro-cache-start-pos beg 249 (setq c-macro-cache-start-pos beg
250 c-macro-cache-syntactic nil)))) 250 c-macro-cache-syntactic nil))))
251 251
252(defun c-macro-is-genuine-p ()
253 ;; Check that the ostensible CPP construct at point is a real one. In
254 ;; particular, if point is on the first line of a narrowed buffer, make sure
255 ;; that the "#" isn't, say, the second character of a "##" operator. Return
256 ;; t when the macro is real, nil otherwise.
257 (let ((here (point)))
258 (beginning-of-line)
259 (prog1
260 (if (and (eq (point) (point-min))
261 (/= (point) 1))
262 (save-restriction
263 (widen)
264 (beginning-of-line)
265 (and (looking-at c-anchored-cpp-prefix)
266 (eq (match-beginning 1) here)))
267 t)
268 (goto-char here))))
269
252(defun c-beginning-of-macro (&optional lim) 270(defun c-beginning-of-macro (&optional lim)
253 "Go to the beginning of a preprocessor directive. 271 "Go to the beginning of a preprocessor directive.
254Leave point at the beginning of the directive and return t if in one, 272Leave point at the beginning of the directive and return t if in one,
@@ -279,7 +297,8 @@ comment at the start of cc-engine.el for more info."
279 (forward-line -1)) 297 (forward-line -1))
280 (back-to-indentation) 298 (back-to-indentation)
281 (if (and (<= (point) here) 299 (if (and (<= (point) here)
282 (looking-at c-opt-cpp-start)) 300 (looking-at c-opt-cpp-start)
301 (c-macro-is-genuine-p))
283 (progn 302 (progn
284 (setq c-macro-cache (cons (point) nil) 303 (setq c-macro-cache (cons (point) nil)
285 c-macro-cache-start-pos here) 304 c-macro-cache-start-pos here)