diff options
Diffstat (limited to 'lisp/newcomment.el')
| -rw-r--r-- | lisp/newcomment.el | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/lisp/newcomment.el b/lisp/newcomment.el index 5dfa1eb8959..0cf0160afb1 100644 --- a/lisp/newcomment.el +++ b/lisp/newcomment.el | |||
| @@ -299,7 +299,7 @@ the variables are properly set." | |||
| 299 | (substring comment-start 1))) | 299 | (substring comment-start 1))) |
| 300 | ;; Hasn't been necessary yet. | 300 | ;; Hasn't been necessary yet. |
| 301 | ;; (unless (string-match comment-start-skip comment-continue) | 301 | ;; (unless (string-match comment-start-skip comment-continue) |
| 302 | ;; (kill-local-variable 'comment-continue)) | 302 | ;; (kill-local-variable 'comment-continue)) |
| 303 | ) | 303 | ) |
| 304 | ;; comment-skip regexps | 304 | ;; comment-skip regexps |
| 305 | (unless (and comment-start-skip | 305 | (unless (and comment-start-skip |
| @@ -599,11 +599,16 @@ If CONTINUE is non-nil, use the `comment-continue' markers if any." | |||
| 599 | (if (and other (<= other max) (> other min)) | 599 | (if (and other (<= other max) (> other min)) |
| 600 | ;; There is a comment and it's in the range: bingo. | 600 | ;; There is a comment and it's in the range: bingo. |
| 601 | (setq indent other)))))))) | 601 | (setq indent other)))))))) |
| 602 | ;; Update INDENT to leave at least one space | ||
| 603 | ;; after other nonwhite text on the line. | ||
| 604 | (save-excursion | ||
| 605 | (skip-chars-backward " \t") | ||
| 606 | (unless (bolp) | ||
| 607 | (setq indent (max indent (1+ (current-column)))))) | ||
| 608 | ;; If that's different from comment's current position, change it. | ||
| 602 | (unless (= (current-column) indent) | 609 | (unless (= (current-column) indent) |
| 603 | ;; If that's different from current, change it. | ||
| 604 | (delete-region (point) (progn (skip-chars-backward " \t") (point))) | 610 | (delete-region (point) (progn (skip-chars-backward " \t") (point))) |
| 605 | (indent-to (if (bolp) indent | 611 | (indent-to indent))) |
| 606 | (max indent (1+ (current-column))))))) | ||
| 607 | (goto-char cpos) | 612 | (goto-char cpos) |
| 608 | (set-marker cpos nil)))) | 613 | (set-marker cpos nil)))) |
| 609 | 614 | ||
| @@ -764,7 +769,7 @@ comment markers." | |||
| 764 | (box-equal nil)) ;Whether we might be using `=' for boxes. | 769 | (box-equal nil)) ;Whether we might be using `=' for boxes. |
| 765 | (save-restriction | 770 | (save-restriction |
| 766 | (narrow-to-region spt ept) | 771 | (narrow-to-region spt ept) |
| 767 | 772 | ||
| 768 | ;; Remove the comment-start. | 773 | ;; Remove the comment-start. |
| 769 | (goto-char ipt) | 774 | (goto-char ipt) |
| 770 | (skip-syntax-backward " ") | 775 | (skip-syntax-backward " ") |
| @@ -793,7 +798,7 @@ comment markers." | |||
| 793 | ;; If there's something left but it doesn't look like | 798 | ;; If there's something left but it doesn't look like |
| 794 | ;; a comment-start any more, just remove it. | 799 | ;; a comment-start any more, just remove it. |
| 795 | (delete-region (point-min) (point)))) | 800 | (delete-region (point-min) (point)))) |
| 796 | 801 | ||
| 797 | ;; Remove the end-comment (and leading padding and such). | 802 | ;; Remove the end-comment (and leading padding and such). |
| 798 | (goto-char (point-max)) (comment-enter-backward) | 803 | (goto-char (point-max)) (comment-enter-backward) |
| 799 | ;; Check for special `=' used sometimes in comment-box. | 804 | ;; Check for special `=' used sometimes in comment-box. |
| @@ -1057,11 +1062,13 @@ The strings used as comment starts are built from | |||
| 1057 | lines | 1062 | lines |
| 1058 | (nth 3 style)))))) | 1063 | (nth 3 style)))))) |
| 1059 | 1064 | ||
| 1065 | ;;;###autoload | ||
| 1060 | (defun comment-box (beg end &optional arg) | 1066 | (defun comment-box (beg end &optional arg) |
| 1061 | "Comment out the BEG .. END region, putting it inside a box. | 1067 | "Comment out the BEG .. END region, putting it inside a box. |
| 1062 | The numeric prefix ARG specifies how many characters to add to begin- and | 1068 | The numeric prefix ARG specifies how many characters to add to begin- and |
| 1063 | end- comment markers additionally to what `comment-add' already specifies." | 1069 | end- comment markers additionally to what `comment-add' already specifies." |
| 1064 | (interactive "*r\np") | 1070 | (interactive "*r\np") |
| 1071 | (comment-normalize-vars) | ||
| 1065 | (let ((comment-style (if (cadr (assoc comment-style comment-styles)) | 1072 | (let ((comment-style (if (cadr (assoc comment-style comment-styles)) |
| 1066 | 'box-multi 'box))) | 1073 | 'box-multi 'box))) |
| 1067 | (comment-region beg end (+ comment-add arg)))) | 1074 | (comment-region beg end (+ comment-add arg)))) |