changeset: 4435:1e2fc51563a598c293a47edbd50b1ff58caa308f
tag: tip
user: Didier Verna <didier(a)xemacs.org>
date: Wed Mar 05 18:01:37 2008 +0100
files: lisp/ChangeLog lisp/newcomment.el
description:
Fix auto-formatting of comments in auto-fill-mode
This patch makes auto-fill-mode properly format comments (when lines are
automatically broken). It looks strangely similar to that of:
| 1999-06-24 Bob Weiner <weiner(a)beopen.com>
|
| * simple.el (indent-new-comment-line): Locally bound
| `block-comment-start' to `comstart' or else when this is called
| from do-auto-fill, e.g. in Lisp mode, it will insert any non-nil
| `block-comment-start' value, ignoring any existing spacing after a
| comment prefix in the previous line and producing ugly comments.
diff -r 7f3d065a56a176d7567899561d6cb5df5a251e41 -r
1e2fc51563a598c293a47edbd50b1ff58caa308f lisp/ChangeLog
--- a/lisp/ChangeLog Wed Mar 05 10:41:54 2008 +0100
+++ b/lisp/ChangeLog Wed Mar 05 18:01:37 2008 +0100
@@ -1,3 +1,12 @@ 2008-03-05 Didier Verna <didier@xemacs
+2008-03-05 Didier Verna <didier(a)xemacs.org>
+
+ Fix auto-formatting of comments in auto-fill-mode.
+
+ * newcomment.el (comment-indent): Don't insert a space at bol.
+ * newcomment.el (comment-indent-new-line): Bind
+ block-comment-start to comment-start in order to preserve the
+ formatting of previous comment lines.
+
2008-03-05 Didier Verna <didier(a)xemacs.org>
Ease customization of face(s) under point.
diff -r 7f3d065a56a176d7567899561d6cb5df5a251e41 -r
1e2fc51563a598c293a47edbd50b1ff58caa308f lisp/newcomment.el
--- a/lisp/newcomment.el Wed Mar 05 10:41:54 2008 +0100
+++ b/lisp/newcomment.el Wed Mar 05 18:01:37 2008 +0100
@@ -240,7 +240,7 @@ This is obsolete because you might as we
(substring comment-start 1)))
;; Hasn't been necessary yet.
;; (unless (string-match comment-start-skip comment-continue)
- ;; (kill-local-variable 'comment-continue))
+ ;; (kill-local-variable 'comment-continue))
)
;; comment-skip regexps
(unless (and comment-start-skip
@@ -443,12 +443,12 @@ Point is assumed to be just at the end o
; (save-excursion
; (beginning-of-line)
; (let ((eol (save-excursion (end-of-line) (point))))
-; (and comment-start-skip
-; (re-search-forward comment-start-skip eol t)
-; (setq eol (match-beginning 0)))
-; (goto-char eol)
-; (skip-chars-backward " \t")
-; (max comment-column (1+ (current-column))))))
+; (and comment-start-skip
+; (re-search-forward comment-start-skip eol t)
+; (setq eol (match-beginning 0)))
+; (goto-char eol)
+; (skip-chars-backward " \t")
+; (max comment-column (1+ (current-column))))))
; "Function to compute desired indentation for a comment.
; This function is called with no args with point at the beginning of
; the comment's starting delimiter.")
@@ -498,7 +498,8 @@ Comments starting in column 0 are not mo
(setq begpos (point))
;; Ensure there's a space before the comment for things
;; like sh where it matters (as well as being neater).
- (unless (eq ?\ (char-syntax (char-before)))
+ ;; ... but unless we're at the beginning of a line -- dvl
+ (unless (or (bolp) (eq ?\ (char-syntax (char-before))))
(insert ?\ ))
(insert starter)
(setq cpos (point-marker))
@@ -516,8 +517,8 @@ Comments starting in column 0 are not mo
(+ (current-column)
(- (or comment-fill-column fill-column)
(save-excursion (end-of-line) (current-column)))))))
- ;; XEmacs change: Preserve indentation of comments starting in
- ;; column 0, as documented.
+ ;; XEmacs change: Preserve indentation of comments starting in
+ ;; column 0, as documented.
(unless (or (= (current-column) 0) (= (current-column) indent))
;; If that's different from current, change it.
(delete-region (point) (progn (skip-chars-backward " \t") (point)))
@@ -653,21 +654,21 @@ comment markers."
(setq end (copy-marker end))
(let* ((numarg (prefix-numeric-value arg))
- (ccs comment-continue)
- (srei (comment-padright ccs 're))
- (sre (and srei (concat "^\\s-*?\\(" srei "\\)")))
- spt)
+ (ccs comment-continue)
+ (srei (comment-padright ccs 're))
+ (sre (and srei (concat "^\\s-*?\\(" srei "\\)")))
+ spt)
(while (and (< (point) end)
(setq spt (comment-search-forward end t)))
(let ((ipt (point))
- ;; Find the end of the comment.
- (ept (progn
- (goto-char spt)
- (unless (comment-forward)
- (error "Can't find the comment end"))
- (point)))
- (box nil)
- (box-equal nil)) ;Whether we might be using `=' for boxes.
+ ;; Find the end of the comment.
+ (ept (progn
+ (goto-char spt)
+ (unless (comment-forward)
+ (error "Can't find the comment end"))
+ (point)))
+ (box nil)
+ (box-equal nil)) ;Whether we might be using `=' for boxes.
(save-restriction
(narrow-to-region spt ept)
@@ -1097,6 +1098,7 @@ unless optional argument SOFT is non-nil
(point))
nil t)))))
(comment-start comstart)
+ (block-comment-start comment-start)
(continuep (or comment-multi-line
(cadr (assoc comment-style comment-styles))))
;; Force comment-continue to be recreated from comment-start.
_______________________________________________
XEmacs-Patches mailing list
XEmacs-Patches(a)xemacs.org
http://calypso.tux.org/cgi-bin/mailman/listinfo/xemacs-patches