aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1996-03-17 15:38:50 +0000
committerRichard M. Stallman1996-03-17 15:38:50 +0000
commit4d2790ad5122ee7a8cf9e2f031d7fb53b1e5a8ec (patch)
treee13a1abc5c5acf8a6b8f2c15422730cf9cb30961
parentaf5eb153f539554ae71f038355d1184e73421b7b (diff)
downloademacs-4d2790ad5122ee7a8cf9e2f031d7fb53b1e5a8ec.tar.gz
emacs-4d2790ad5122ee7a8cf9e2f031d7fb53b1e5a8ec.zip
(lisp-fill-paragraph): Treat code-and-comment case specially.
-rw-r--r--lisp/emacs-lisp/lisp-mode.el16
1 files changed, 13 insertions, 3 deletions
diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el
index ea29b880bb3..9879b9f5fae 100644
--- a/lisp/emacs-lisp/lisp-mode.el
+++ b/lisp/emacs-lisp/lisp-mode.el
@@ -703,6 +703,9 @@ and initial semicolons."
703 ;; Non-nil if the current line contains a comment. 703 ;; Non-nil if the current line contains a comment.
704 has-comment 704 has-comment
705 705
706 ;; Non-nil if the current line contains code and a comment.
707 has-code-and-comment
708
706 ;; If has-comment, the appropriate fill-prefix for the comment. 709 ;; If has-comment, the appropriate fill-prefix for the comment.
707 comment-fill-prefix 710 comment-fill-prefix
708 ) 711 )
@@ -732,7 +735,7 @@ and initial semicolons."
732 ((memq (char-after (point)) '(?\" ??)) (forward-sexp 1)))) 735 ((memq (char-after (point)) '(?\" ??)) (forward-sexp 1))))
733 (looking-at ";+[\t ]*")) 736 (looking-at ";+[\t ]*"))
734 (error nil)) 737 (error nil))
735 (setq has-comment t) 738 (setq has-comment t has-code-and-comment t)
736 (setq comment-fill-prefix 739 (setq comment-fill-prefix
737 (concat (make-string (/ (current-column) 8) ?\t) 740 (concat (make-string (/ (current-column) 8) ?\t)
738 (make-string (% (current-column) 8) ?\ ) 741 (make-string (% (current-column) 8) ?\ )
@@ -765,11 +768,19 @@ and initial semicolons."
765 (paragraph-separate (concat paragraph-start "\\|[ \t;]*$")) 768 (paragraph-separate (concat paragraph-start "\\|[ \t;]*$"))
766 (paragraph-ignore-fill-prefix nil) 769 (paragraph-ignore-fill-prefix nil)
767 (fill-prefix comment-fill-prefix) 770 (fill-prefix comment-fill-prefix)
771 (after-line (if has-code-and-comment
772 (save-excursion
773 (forward-line 1) (point))))
768 (end (progn 774 (end (progn
769 (forward-paragraph) 775 (forward-paragraph)
770 (or (bolp) (newline 1)) 776 (or (bolp) (newline 1))
771 (point))) 777 (point)))
772 (beg (progn (backward-paragraph) (point)))) 778 ;; If this comment starts on a line with code,
779 ;; include that like in the filling.
780 (beg (progn (backward-paragraph)
781 (if (eq (point) after-line)
782 (forward-line -1))
783 (point))))
773 (fill-region-as-paragraph beg end 784 (fill-region-as-paragraph beg end
774 justify nil 785 justify nil
775 (save-excursion 786 (save-excursion
@@ -779,7 +790,6 @@ and initial semicolons."
779 (re-search-forward comment-start-skip) 790 (re-search-forward comment-start-skip)
780 (point)))))))) 791 (point))))))))
781 t)) 792 t))
782
783 793
784(defun indent-code-rigidly (start end arg &optional nochange-regexp) 794(defun indent-code-rigidly (start end arg &optional nochange-regexp)
785 "Indent all lines of code, starting in the region, sideways by ARG columns. 795 "Indent all lines of code, starting in the region, sideways by ARG columns.