summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2000-09-29 19:11:42 +0000
committerStefan Monnier <monnier@iro.umontreal.ca>2000-09-29 19:11:42 +0000
commitbdbe3a8995c5f1dae126acd4be4872f6af687cd1 (patch)
tree2c26691ff117bc2b6979886ed213ab41419cdd01
parenta3ef6569e5dbc3278b95610271404a39cf6d93cb (diff)
downloademacs-bdbe3a8995c5f1dae126acd4be4872f6af687cd1.tar.gz
(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.
-rw-r--r--lisp/newcomment.el21
1 files changed, 16 insertions, 5 deletions
diff --git a/lisp/newcomment.el b/lisp/newcomment.el
index eeb048bfa30..bf6e3e104cc 100644
--- a/lisp/newcomment.el
+++ b/lisp/newcomment.el
@@ -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 @@ Should be an empty string if comments are terminated by end-of-line.")
;;;###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 @@ If CONTINUE is non-nil, use the `comment-continuation' markers if any."
(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))