[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] trunk r118147: Check that a "macro" found near point-min i
From: |
Alan Mackenzie |
Subject: |
[Emacs-diffs] trunk r118147: Check that a "macro" found near point-min isn't a ## operator. Fixes |
Date: |
Sat, 18 Oct 2014 10:10:06 +0000 |
User-agent: |
Bazaar (2.6b2) |
------------------------------------------------------------
revno: 118147
revision-id: address@hidden
parent: address@hidden
committer: Alan Mackenzie <address@hidden>
branch nick: trunk
timestamp: Sat 2014-10-18 10:02:59 +0000
message:
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.
modified:
lisp/ChangeLog changelog-20091113204419-o5vbwnq5f7feedwu-1432
lisp/progmodes/cc-engine.el
ccengine.el-20091113204419-o5vbwnq5f7feedwu-1227
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog 2014-10-18 01:02:30 +0000
+++ b/lisp/ChangeLog 2014-10-18 10:02:59 +0000
@@ -1,3 +1,10 @@
+2014-10-18 Alan Mackenzie <address@hidden>
+
+ 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.
+
2014-10-18 Teodor Zlatanov <address@hidden>
* net/gnutls.el (gnutls-negotiate): Don't use cl-mapcan; pass
=== modified file 'lisp/progmodes/cc-engine.el'
--- a/lisp/progmodes/cc-engine.el 2014-10-12 20:09:15 +0000
+++ b/lisp/progmodes/cc-engine.el 2014-10-18 10:02:59 +0000
@@ -249,6 +249,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,
@@ -279,7 +297,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)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] trunk r118147: Check that a "macro" found near point-min isn't a ## operator. Fixes,
Alan Mackenzie <=