Commit 20e527d0 authored by Alan Mackenzie's avatar Alan Mackenzie
Browse files

Correct the placement of c-cpp-delimiters when there're #s not at col 0.

        * progmodes/cc-langs.el (c-anchored-cpp-prefix): Reformulate and
        place a submatch around the #.
        * progmodes/cc-mode.el(c-neutralize-syntax-in-and-mark-CPP): Start
        a search at BOL.  Put the c-cpp-delimiter category text propertiy
        on the #, not BOL.
parent dabefae5
2013-04-15 Alan Mackenzie <acm@muc.de>
Correct the placement of c-cpp-delimiters when there're #s not at
col 0.
* progmodes/cc-langs.el (c-anchored-cpp-prefix): Reformulate and
place a submatch around the #.
* progmodes/cc-mode.el(c-neutralize-syntax-in-and-mark-CPP): Start
a search at BOL. Put the c-cpp-delimiter category text propertiy
on the #, not BOL.
2013-04-15 Stefan Monnier <monnier@iro.umontreal.ca>
* emacs-lisp/nadvice.el: Properly test names when adding advice.
......
......@@ -812,8 +812,8 @@ Assumed to not contain any submatches or \\| operators."
(c-lang-defconst c-anchored-cpp-prefix
"Regexp matching the prefix of a cpp directive anchored to BOL,
in the languages that have a macro preprocessor."
t (if (c-lang-const c-opt-cpp-prefix)
(concat "^" (c-lang-const c-opt-cpp-prefix))))
t "^\\s *\\(#\\)\\s *"
(java awk) nil)
(c-lang-defvar c-anchored-cpp-prefix (c-lang-const c-anchored-cpp-prefix))
(c-lang-defconst c-opt-cpp-start
......
......@@ -936,7 +936,8 @@ Note that the style variables are always made local to the buffer."
;; Add needed properties to each CPP construct in the region.
(goto-char c-new-BEG)
(let ((pps-position c-new-BEG) pps-state mbeg)
(skip-chars-backward " \t")
(let ((pps-position (point)) pps-state mbeg)
(while (and (< (point) c-new-END)
(search-forward-regexp c-anchored-cpp-prefix c-new-END t))
;; If we've found a "#" inside a string/comment, ignore it.
......@@ -945,14 +946,12 @@ Note that the style variables are always made local to the buffer."
pps-position (point))
(unless (or (nth 3 pps-state) ; in a string?
(nth 4 pps-state)) ; in a comment?
(goto-char (match-beginning 0))
(goto-char (match-beginning 1))
(setq mbeg (point))
(if (> (c-syntactic-end-of-macro) mbeg)
(progn
(c-neutralize-CPP-line mbeg (point))
(c-set-cpp-delimiters mbeg (point))
;(setq pps-position (point))
)
(c-set-cpp-delimiters mbeg (point)))
(forward-line)) ; no infinite loop with, e.g., "#//"
)))))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment