X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/9efd720d16c6a8adba600cfb303b4bd75d7c6cdf..58635e4de85621d4f16befe15b1df44a637bd078:/lisp/progmodes/cc-cmds.el diff --git a/lisp/progmodes/cc-cmds.el b/lisp/progmodes/cc-cmds.el index 8639ebba3b..5ac30bc28c 100644 --- a/lisp/progmodes/cc-cmds.el +++ b/lisp/progmodes/cc-cmds.el @@ -1,8 +1,6 @@ ;;; cc-cmds.el --- user level commands for CC Mode -;; Copyright (C) 1985, 1987, 1992, 1993, 1994, 1995, 1996, 1997, 1998, -;; 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 -;; Free Software Foundation, Inc. +;; Copyright (C) 1985, 1987, 1992-2011 Free Software Foundation, Inc. ;; Authors: 2003- Alan Mackenzie ;; 1998- Martin Stjernholm @@ -2442,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 ";\\|};?") @@ -2562,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))) @@ -2647,14 +2654,19 @@ sentence motion in or near comments and multiline strings." ;; Are we about to move forward into or out of a ;; preprocessor command? (when (eq (cdr res) 'macro-boundary) - (save-excursion - (end-of-line) - (setq macro-fence - (and (not (eobp)) - (progn (c-skip-ws-forward) - (c-beginning-of-macro)) - (progn (c-end-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 forward into a literal? (when (memq (cdr res) '(macro-boundary literal)) (setq range (c-ascertain-following-literal))) @@ -4574,5 +4586,4 @@ normally bound to C-o. See `c-context-line-break' for the details." (cc-provide 'cc-cmds) -;; arch-tag: bf0611dc-d1f4-449e-9e45-4ec7c6936677 ;;; cc-cmds.el ends here