diff options
| author | Karl Heuer | 1995-12-21 17:54:46 +0000 |
|---|---|---|
| committer | Karl Heuer | 1995-12-21 17:54:46 +0000 |
| commit | 93353fea264973a4f1967d486e2bfae7c7e6c36b (patch) | |
| tree | 3a87c4de581840bbd70d3d167d66908e87183946 | |
| parent | 64690f3dfa768510055374f992358c130debe868 (diff) | |
| download | emacs-93353fea264973a4f1967d486e2bfae7c7e6c36b.tar.gz emacs-93353fea264973a4f1967d486e2bfae7c7e6c36b.zip | |
(lisp-fill-paragraph): Several changes.
Change how to recognize partial comment lines,
how to find start of region to fill. Use fill-region.
Use tabs when making comment-fill-prefix.
| -rw-r--r-- | lisp/emacs-lisp/lisp-mode.el | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index d8eaca3c808..29ca7ecc4c3 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el | |||
| @@ -698,16 +698,21 @@ and initial semicolons." | |||
| 698 | ;; A line with some code, followed by a comment? Remember that the | 698 | ;; A line with some code, followed by a comment? Remember that the |
| 699 | ;; semi which starts the comment shouldn't be part of a string or | 699 | ;; semi which starts the comment shouldn't be part of a string or |
| 700 | ;; character. | 700 | ;; character. |
| 701 | ((progn | 701 | ((condition-case nil |
| 702 | (while (not (looking-at ";\\|$")) | 702 | (save-restriction |
| 703 | (skip-chars-forward "^;\n\"\\\\?") | 703 | (narrow-to-region (point-min) |
| 704 | (cond | 704 | (save-excursion (end-of-line) (point))) |
| 705 | ((eq (char-after (point)) ?\\) (forward-char 2)) | 705 | (while (not (looking-at ";\\|$")) |
| 706 | ((memq (char-after (point)) '(?\" ??)) (forward-sexp 1)))) | 706 | (skip-chars-forward "^;\n\"\\\\?") |
| 707 | (looking-at ";+[\t ]*")) | 707 | (cond |
| 708 | ((eq (char-after (point)) ?\\) (forward-char 2)) | ||
| 709 | ((memq (char-after (point)) '(?\" ??)) (forward-sexp 1)))) | ||
| 710 | (looking-at ";+[\t ]*")) | ||
| 711 | (error nil)) | ||
| 708 | (setq has-comment t) | 712 | (setq has-comment t) |
| 709 | (setq comment-fill-prefix | 713 | (setq comment-fill-prefix |
| 710 | (concat (make-string (current-column) ? ) | 714 | (concat (make-string (/ (current-column) 8) ?\t) |
| 715 | (make-string (% (current-column) 8) ?\ ) | ||
| 711 | (buffer-substring (match-beginning 0) (match-end 0))))))) | 716 | (buffer-substring (match-beginning 0) (match-end 0))))))) |
| 712 | 717 | ||
| 713 | (if (not has-comment) | 718 | (if (not has-comment) |
| @@ -715,13 +720,14 @@ and initial semicolons." | |||
| 715 | 720 | ||
| 716 | ;; Narrow to include only the comment, and then fill the region. | 721 | ;; Narrow to include only the comment, and then fill the region. |
| 717 | (save-restriction | 722 | (save-restriction |
| 723 | (beginning-of-line) | ||
| 718 | (narrow-to-region | 724 | (narrow-to-region |
| 719 | ;; Find the first line we should include in the region to fill. | 725 | ;; Find the first line we should include in the region to fill. |
| 720 | (save-excursion | 726 | (save-excursion |
| 721 | (while (and (zerop (forward-line -1)) | 727 | (while (and (zerop (forward-line -1)) |
| 722 | (looking-at "^[ \t]*;"))) | 728 | (looking-at "^[ \t]*;"))) |
| 723 | ;; We may have gone to far. Go forward again. | 729 | ;; We may have gone to far. Go forward again. |
| 724 | (or (looking-at "^[ \t]*;") | 730 | (or (looking-at ".*;") |
| 725 | (forward-line 1)) | 731 | (forward-line 1)) |
| 726 | (point)) | 732 | (point)) |
| 727 | ;; Find the beginning of the first line past the region to fill. | 733 | ;; Find the beginning of the first line past the region to fill. |
| @@ -734,7 +740,7 @@ and initial semicolons." | |||
| 734 | (let ((paragraph-start (concat paragraph-start "\\|[ \t;]*$")) | 740 | (let ((paragraph-start (concat paragraph-start "\\|[ \t;]*$")) |
| 735 | (paragraph-separate (concat paragraph-start "\\|[ \t;]*$")) | 741 | (paragraph-separate (concat paragraph-start "\\|[ \t;]*$")) |
| 736 | (fill-prefix comment-fill-prefix)) | 742 | (fill-prefix comment-fill-prefix)) |
| 737 | (fill-paragraph justify)))) | 743 | (fill-region (point-min) (point-max) justify t)))) |
| 738 | t)) | 744 | t)) |
| 739 | 745 | ||
| 740 | 746 | ||