+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.
(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
;; 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.
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., "#//"
)))))