X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/ce07fa9adcea121b5515f98e161e257d1210c9b0..73b0cd50031a714347109169ceb8bacae338612a:/lisp/progmodes/cc-cmds.el diff --git a/lisp/progmodes/cc-cmds.el b/lisp/progmodes/cc-cmds.el index 10267a6b2d..f1c00ddbd4 100644 --- a/lisp/progmodes/cc-cmds.el +++ b/lisp/progmodes/cc-cmds.el @@ -1,7 +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 +;; Copyright (C) 1985, 1987, 1992-2011 ;; Free Software Foundation, Inc. ;; Authors: 2003- Alan Mackenzie @@ -12,8 +11,8 @@ ;; 1985 Richard M. Stallman ;; Maintainer: bug-cc-mode@gnu.org ;; Created: 22-Apr-1997 (split from cc-mode.el) -;; Version: See cc-mode.el -;; Keywords: c languages oop +;; Keywords: c languages +;; Package: cc-mode ;; This file is part of GNU Emacs. @@ -266,8 +265,10 @@ With universal argument, inserts the analysis as a comment on that line." (symbol-value 'subword-mode)) "w" ""))) + ;; FIXME: Derived modes might want to use something else + ;; than a string for `mode-name'. (bare-mode-name (if (string-match "\\(^[^/]*\\)/" mode-name) - (substring mode-name (match-beginning 1) (match-end 1)) + (match-string 1 mode-name) mode-name))) ;; (setq c-submode-indicators ;; (if (> (length fmt) 1) @@ -3974,16 +3975,19 @@ command to conveniently insert and align the necessary backslashes." ;; "Invalid search bound (wrong side of point)" ;; error in the subsequent re-search. Maybe ;; another fix would be needed (2007-12-08). - (and (> (- (cdr c-lit-limits) 2) (point)) - (search-forward-regexp - (concat "\\=[ \t]*\\(" c-current-comment-prefix "\\)") - (- (cdr c-lit-limits) 2) t) - (not (search-forward-regexp - "\\(\\s \\|\\sw\\)" - (- (cdr c-lit-limits) 2) 'limit)) - ;; The comment ender IS on its own line. Exclude - ;; this line from the filling. - (set-marker end (c-point 'bol)))) +; (or (<= (- (cdr c-lit-limits) 2) (point)) +; 2010-10-17 Construct removed. +; (or (< (- (cdr c-lit-limits) 2) (point)) + (and + (search-forward-regexp + (concat "\\=[ \t]*\\(" c-current-comment-prefix "\\)") + (- (cdr c-lit-limits) 2) t) + (not (search-forward-regexp + "\\(\\s \\|\\sw\\)" + (- (cdr c-lit-limits) 2) 'limit)) + ;; The comment ender IS on its own line. Exclude this + ;; line from the filling. + (set-marker end (c-point 'bol))));) ;; The comment ender is hanging. Replace all space between it ;; and the last word either by one or two 'x's (when @@ -4000,6 +4004,14 @@ command to conveniently insert and align the necessary backslashes." (goto-char ender-start) (current-column))) (point-rel (- ender-start here)) + (sentence-ends-comment + (save-excursion + (goto-char ender-start) + (and (search-backward-regexp + (c-sentence-end) (c-point 'bol) t) + (goto-char (match-end 0)) + (looking-at "[ \t]*") + (= (match-end 0) ender-start)))) spaces) (save-excursion @@ -4042,7 +4054,9 @@ command to conveniently insert and align the necessary backslashes." (setq spaces (max (min spaces - (if sentence-end-double-space 2 1)) + (if (and sentence-ends-comment + sentence-end-double-space) + 2 1)) 1))) ;; Insert the filler first to keep marks right. (insert-char ?x spaces t) @@ -4252,8 +4266,11 @@ Optional prefix ARG means justify paragraph as well." (let ((fill-paragraph-function ;; Avoid infinite recursion. (if (not (eq fill-paragraph-function 'c-fill-paragraph)) - fill-paragraph-function))) - (c-mask-paragraph t nil 'fill-paragraph arg)) + fill-paragraph-function)) + (start-point (point-marker))) + (c-mask-paragraph + t nil (lambda () (fill-region-as-paragraph (point-min) (point-max) arg))) + (goto-char start-point)) ;; Always return t. This has the effect that if filling isn't done ;; above, it isn't done at all, and it's therefore effectively ;; disabled in normal code. @@ -4556,5 +4573,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