summaryrefslogtreecommitdiff
path: root/lisp/progmodes/cc-cmds.el
diff options
context:
space:
mode:
authorChong Yidong <cyd@stupidchicken.com>2011-01-31 18:54:50 -0500
committerChong Yidong <cyd@stupidchicken.com>2011-01-31 18:54:50 -0500
commit14beddf4711854b01d400f36166dc71eb39435bb (patch)
tree04fd96bb0f5dcf5f3aa4e9f39a537edc61038f83 /lisp/progmodes/cc-cmds.el
parent2a4466ca2001c29fd654420b081b780981333dc5 (diff)
parent113ef437f21c6ea1b65abe668feb86f1622a9f2e (diff)
downloademacs-14beddf4711854b01d400f36166dc71eb39435bb.tar.gz
Merge changes from emacs-23 branch
Diffstat (limited to 'lisp/progmodes/cc-cmds.el')
-rw-r--r--lisp/progmodes/cc-cmds.el33
1 files changed, 21 insertions, 12 deletions
diff --git a/lisp/progmodes/cc-cmds.el b/lisp/progmodes/cc-cmds.el
index 327ebea40cc..ec913e05c7e 100644
--- a/lisp/progmodes/cc-cmds.el
+++ b/lisp/progmodes/cc-cmds.el
@@ -2440,13 +2440,15 @@ function does not require the declaration to contain a brace block."
(goto-char last)
(throw 'done '(nil . nil)))
- ;; Stop if we encounter a preprocessor line.
- ((and (not macro-end)
+ ;; Stop if we encounter a preprocessor line. Continue if we
+ ;; hit a naked #
+ ((and c-opt-cpp-prefix
+ (not macro-end)
(eq (char-after) ?#)
(= (point) (c-point 'boi)))
- (goto-char last)
- ;(throw 'done (cons (eq (point) here) 'macro-boundary))) ; Changed 2003/3/26
- (throw 'done '(t . macro-boundary)))
+ (if (= (point) here) ; Not a macro, therefore naked #.
+ (forward-char)
+ (throw 'done '(t . macro-boundary))))
;; Stop after a ';', '}', or "};"
((looking-at ";\\|};?")
@@ -2560,14 +2562,21 @@ be more \"DWIM:ey\"."
(c-backward-syntactic-ws))
(or (bobp) (c-after-statement-terminator-p)))))))
;; Are we about to move backwards into or out of a
- ;; preprocessor command? If so, locate it's beginning.
+ ;; preprocessor command? If so, locate its beginning.
(when (eq (cdr res) 'macro-boundary)
- (save-excursion
- (beginning-of-line)
- (setq macro-fence
- (and (not (bobp))
- (progn (c-skip-ws-backward) (c-beginning-of-macro))
- (point)))))
+ (setq macro-fence
+ (save-excursion
+ (if macro-fence
+ (progn
+ (end-of-line)
+ (and (not (eobp))
+ (progn (c-skip-ws-forward)
+ (c-beginning-of-macro))
+ (progn (c-end-of-macro)
+ (point))))
+ (and (not (eobp))
+ (c-beginning-of-macro)
+ (progn (c-end-of-macro) (point)))))))
;; Are we about to move backwards into a literal?
(when (memq (cdr res) '(macro-boundary literal))
(setq range (c-ascertain-preceding-literal)))