diff options
| author | Stefan Monnier | 2000-09-29 19:11:42 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2000-09-29 19:11:42 +0000 |
| commit | bdbe3a8995c5f1dae126acd4be4872f6af687cd1 (patch) | |
| tree | 2c26691ff117bc2b6979886ed213ab41419cdd01 | |
| parent | a3ef6569e5dbc3278b95610271404a39cf6d93cb (diff) | |
| download | emacs-bdbe3a8995c5f1dae126acd4be4872f6af687cd1.tar.gz emacs-bdbe3a8995c5f1dae126acd4be4872f6af687cd1.zip | |
(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.el | 21 |
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 @@ | |||
| 6 | ;; Maintainer: Stefan Monnier <monnier@cs.yale.edu> | 6 | ;; Maintainer: Stefan Monnier <monnier@cs.yale.edu> |
| 7 | ;; Keywords: comment uncomment | 7 | ;; Keywords: comment uncomment |
| 8 | ;; Version: $Name: $ | 8 | ;; Version: $Name: $ |
| 9 | ;; Revision: $Id: newcomment.el,v 1.18 2000/07/06 13:24:28 monnier Exp $ | 9 | ;; Revision: $Id: newcomment.el,v 1.19 2000/07/06 13:25:31 monnier Exp $ |
| 10 | 10 | ||
| 11 | ;; This file is part of GNU Emacs. | 11 | ;; This file is part of GNU Emacs. |
| 12 | 12 | ||
| @@ -55,6 +55,11 @@ | |||
| 55 | ;; - somehow allow comment-dwim to use the region even if transient-mark-mode | 55 | ;; - somehow allow comment-dwim to use the region even if transient-mark-mode |
| 56 | ;; is not turned on. | 56 | ;; is not turned on. |
| 57 | 57 | ||
| 58 | ;; - when auto-filling a comment, try to move the comment to the left | ||
| 59 | ;; rather than break it (if possible). | ||
| 60 | ;; - sometimes default the comment-column to the same | ||
| 61 | ;; one used on the preceding line(s). | ||
| 62 | |||
| 58 | ;;; Code: | 63 | ;;; Code: |
| 59 | 64 | ||
| 60 | ;;;###autoload | 65 | ;;;###autoload |
| @@ -111,7 +116,7 @@ Should be an empty string if comments are terminated by end-of-line.") | |||
| 111 | 116 | ||
| 112 | ;;;###autoload | 117 | ;;;###autoload |
| 113 | (defvar comment-indent-function | 118 | (defvar comment-indent-function |
| 114 | (lambda () comment-column) | 119 | (lambda () (if (looking-at "\\s<\\s<\\s<") 0 comment-column)) |
| 115 | "Function to compute desired indentation for a comment. | 120 | "Function to compute desired indentation for a comment. |
| 116 | This function is called with no args with point at the beginning of | 121 | This function is called with no args with point at the beginning of |
| 117 | the comment's starting delimiter.") | 122 | the comment's starting delimiter.") |
| @@ -413,13 +418,19 @@ If CONTINUE is non-nil, use the `comment-continuation' markers if any." | |||
| 413 | (setq cpos (point-marker)) | 418 | (setq cpos (point-marker)) |
| 414 | (goto-char begpos)) | 419 | (goto-char begpos)) |
| 415 | ;; Compute desired indent. | 420 | ;; Compute desired indent. |
| 416 | (if (= (current-column) | 421 | (setq indent (funcall comment-indent-function)) |
| 417 | (setq indent (funcall comment-indent-function))) | 422 | ;; Avoid moving comments past the fill-column. |
| 423 | (setq indent | ||
| 424 | (min indent | ||
| 425 | (+ (current-column) | ||
| 426 | (- fill-column | ||
| 427 | (save-excursion (end-of-line) (current-column)))))) | ||
| 428 | (if (= (current-column) indent) | ||
| 418 | (goto-char begpos) | 429 | (goto-char begpos) |
| 419 | ;; If that's different from current, change it. | 430 | ;; If that's different from current, change it. |
| 420 | (skip-chars-backward " \t") | 431 | (skip-chars-backward " \t") |
| 421 | (delete-region (point) begpos) | 432 | (delete-region (point) begpos) |
| 422 | (indent-to indent)) | 433 | (indent-to (if (bolp) indent (max indent (1+ (current-column)))))) |
| 423 | ;; An existing comment? | 434 | ;; An existing comment? |
| 424 | (if cpos | 435 | (if cpos |
| 425 | (progn (goto-char cpos) (set-marker cpos nil)) | 436 | (progn (goto-char cpos) (set-marker cpos nil)) |