From bdbe3a8995c5f1dae126acd4be4872f6af687cd1 Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Fri, 29 Sep 2000 19:11:42 +0000 Subject: [PATCH] (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. --- lisp/newcomment.el | 21 ++++++++++++++++----- 1 file 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 ;; 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)) -- 2.11.4.GIT