changeset 32014:13bd1ce1c353

(comment-indent-function): Use 0 for ;;; and %%%. (comment-indent): Make sure there's a space between code and comment. Shift comments left to avoid going past fill-column.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Fri, 29 Sep 2000 19:11:42 +0000
parents cfd201123ef1
children 5519caf281ee
files lisp/newcomment.el
diffstat 1 files changed, 16 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/newcomment.el	Fri Sep 29 18:47:57 2000 +0000
+++ b/lisp/newcomment.el	Fri Sep 29 19:11:42 2000 +0000
@@ -6,7 +6,7 @@
 ;; Maintainer: Stefan Monnier <monnier@cs.yale.edu>
 ;; Keywords: comment uncomment
 ;; Version: $Name:  $
-;; Revision: $Id: newcomment.el,v 1.18 2000/07/06 13:24:28 monnier Exp $
+;; Revision: $Id: newcomment.el,v 1.19 2000/07/06 13:25:31 monnier Exp $
 
 ;; This file is part of GNU Emacs.
 
@@ -55,6 +55,11 @@
 ;; - somehow allow comment-dwim to use the region even if transient-mark-mode
 ;;   is not turned on.
 
+;; - when auto-filling a comment, try to move the comment to the left
+;;   rather than break it (if possible).
+;; - sometimes default the comment-column to the same
+;;   one used on the preceding line(s).
+
 ;;; Code:
 
 ;;;###autoload
@@ -111,7 +116,7 @@
 
 ;;;###autoload
 (defvar comment-indent-function
-  (lambda () comment-column)
+  (lambda () (if (looking-at "\\s<\\s<\\s<") 0 comment-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.")
@@ -413,13 +418,19 @@
 	    (setq cpos (point-marker))
 	    (goto-char begpos))
           ;; Compute desired indent.
-          (if (= (current-column)
-                 (setq indent (funcall comment-indent-function)))
+	  (setq indent (funcall comment-indent-function))
+	  ;; Avoid moving comments past the fill-column.
+	  (setq indent
+		(min indent
+		     (+ (current-column)
+			(- fill-column
+			   (save-excursion (end-of-line) (current-column))))))
+          (if (= (current-column) indent)
               (goto-char begpos)
             ;; If that's different from current, change it.
             (skip-chars-backward " \t")
             (delete-region (point) begpos)
-            (indent-to indent))
+            (indent-to (if (bolp) indent (max indent (1+ (current-column))))))
           ;; An existing comment?
           (if cpos
               (progn (goto-char cpos) (set-marker cpos nil))