aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Stjernholm2002-04-24 00:50:29 +0000
committerMartin Stjernholm2002-04-24 00:50:29 +0000
commit467690bb1ba4d18bb39e350f328ed3b53ebde23b (patch)
tree700f1d7f5b1e05b85d648f9c83a2cfd81d0fc381
parent7c1fc733989b4b707c7c84bb6d4645548f07ef59 (diff)
downloademacs-467690bb1ba4d18bb39e350f328ed3b53ebde23b.tar.gz
emacs-467690bb1ba4d18bb39e350f328ed3b53ebde23b.zip
(c-mask-comment): More fixes when used from `c-do-auto-fill' and point
is at or near the limit of the comment. Fixed bug when the prefix from `c-guess-fill-prefix' is longer than the text on the first line of the comment when it's masked.
-rw-r--r--lisp/ChangeLog8
-rw-r--r--lisp/progmodes/cc-cmds.el25
2 files changed, 22 insertions, 11 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index a051c4ad7bd..9e59081b598 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
12002-04-24 Martin Stjernholm <mast@lysator.liu.se>
2
3 * progmodes/cc-cmds.el (c-mask-comment): More fixes when used
4 from `c-do-auto-fill' and point is at or near the limit of the
5 comment. Fixed bug when the prefix from `c-guess-fill-prefix'
6 is longer than the text on the first line of the comment when
7 it's masked.
8
12002-04-24 Miles Bader <miles@gnu.org> 92002-04-24 Miles Bader <miles@gnu.org>
2 10
3 * menu-bar.el (menu-bar-update-buffers-1): Make sure 11 * menu-bar.el (menu-bar-update-buffers-1): Make sure
diff --git a/lisp/progmodes/cc-cmds.el b/lisp/progmodes/cc-cmds.el
index 7c63b5fc7b4..96b72eb1754 100644
--- a/lisp/progmodes/cc-cmds.el
+++ b/lisp/progmodes/cc-cmds.el
@@ -2761,7 +2761,7 @@ command to conveniently insert and align the necessary backslashes."
2761 '("" . 0)))))) 2761 '("" . 0))))))
2762 )) 2762 ))
2763 2763
2764(defun c-mask-comment (fill-include-ender apply-outside-literal fun &rest args) 2764(defun c-mask-comment (fill-mode apply-outside-literal fun &rest args)
2765 ;; Calls FUN with ARGS ar arguments. If point is inside a comment, 2765 ;; Calls FUN with ARGS ar arguments. If point is inside a comment,
2766 ;; the comment starter and ender are masked and the buffer is 2766 ;; the comment starter and ender are masked and the buffer is
2767 ;; narrowed to make it look like a normal paragraph during the call. 2767 ;; narrowed to make it look like a normal paragraph during the call.
@@ -2790,7 +2790,7 @@ command to conveniently insert and align the necessary backslashes."
2790 ;; Widen to catch comment limits correctly. 2790 ;; Widen to catch comment limits correctly.
2791 (widen) 2791 (widen)
2792 (unless c-lit-limits 2792 (unless c-lit-limits
2793 (setq c-lit-limits (c-literal-limits nil t))) 2793 (setq c-lit-limits (c-literal-limits nil fill-mode)))
2794 (setq c-lit-limits (c-collect-line-comments c-lit-limits)) 2794 (setq c-lit-limits (c-collect-line-comments c-lit-limits))
2795 (unless c-lit-type 2795 (unless c-lit-type
2796 (setq c-lit-type (c-literal-type c-lit-limits)))) 2796 (setq c-lit-type (c-literal-type c-lit-limits))))
@@ -2840,8 +2840,8 @@ command to conveniently insert and align the necessary backslashes."
2840 "\\)\\*/")) 2840 "\\)\\*/"))
2841 (eq (cdr c-lit-limits) (match-end 0)) 2841 (eq (cdr c-lit-limits) (match-end 0))
2842 ;; Leave the comment ender on its own line. 2842 ;; Leave the comment ender on its own line.
2843 (set-marker end (point)))) 2843 (set-marker end (max (point) here))))
2844 (when fill-include-ender 2844 (when fill-mode
2845 ;; The comment ender should hang. Replace all cruft 2845 ;; The comment ender should hang. Replace all cruft
2846 ;; between it and the last word with one or two 'x' 2846 ;; between it and the last word with one or two 'x'
2847 ;; and include it in the region. We'll change them 2847 ;; and include it in the region. We'll change them
@@ -2900,12 +2900,13 @@ command to conveniently insert and align the necessary backslashes."
2900 ;; The region includes the comment starter. 2900 ;; The region includes the comment starter.
2901 (save-excursion 2901 (save-excursion
2902 (goto-char (car c-lit-limits)) 2902 (goto-char (car c-lit-limits))
2903 (if (and (looking-at (concat "\\(" comment-start-skip "\\)$")) 2903 (when (and (looking-at comment-start-skip)
2904 (> here (match-end 0))) 2904 (> here (match-end 0)))
2905 ;; Begin with the next line. 2905 (if (eq (match-end 0) (c-point 'eol))
2906 (setq beg (c-point 'bonl)) 2906 ;; Begin with the next line.
2907 ;; Fake the fill prefix in the first line. 2907 (setq beg (c-point 'bonl))
2908 (setq tmp-pre t))))) 2908 ;; Fake the fill prefix in the first line.
2909 (setq tmp-pre t))))))
2909 ((eq c-lit-type 'string) ; String. 2910 ((eq c-lit-type 'string) ; String.
2910 (save-excursion 2911 (save-excursion
2911 (when (>= end (cdr c-lit-limits)) 2912 (when (>= end (cdr c-lit-limits))
@@ -2951,7 +2952,9 @@ Warning: Regexp from `c-comment-prefix-regexp' doesn't match the comment prefix
2951 (goto-char (match-end 0)) 2952 (goto-char (match-end 0))
2952 (forward-char 2) 2953 (forward-char 2)
2953 (skip-chars-forward " \t")) 2954 (skip-chars-forward " \t"))
2954 (while (< (current-column) (cdr fill)) (forward-char 1)) 2955 (while (and (< (current-column) (cdr fill))
2956 (not (eolp)))
2957 (forward-char 1))
2955 (let ((col (current-column))) 2958 (let ((col (current-column)))
2956 (setq beg (1+ (point)) 2959 (setq beg (1+ (point))
2957 tmp-pre (list (point))) 2960 tmp-pre (list (point)))