diff options
author | Karl Heuer <kwzh@gnu.org> | 1995-12-21 17:54:46 +0000 |
---|---|---|
committer | Karl Heuer <kwzh@gnu.org> | 1995-12-21 17:54:46 +0000 |
commit | 93353fea264973a4f1967d486e2bfae7c7e6c36b (patch) | |
tree | 3a87c4de581840bbd70d3d167d66908e87183946 /lisp | |
parent | 64690f3dfa768510055374f992358c130debe868 (diff) | |
download | emacs-93353fea264973a4f1967d486e2bfae7c7e6c36b.tar.gz |
(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.
Diffstat (limited to 'lisp')
-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." ;; A line with some code, followed by a comment? Remember that the ;; semi which starts the comment shouldn't be part of a string or ;; character. - ((progn - (while (not (looking-at ";\\|$")) - (skip-chars-forward "^;\n\"\\\\?") - (cond - ((eq (char-after (point)) ?\\) (forward-char 2)) - ((memq (char-after (point)) '(?\" ??)) (forward-sexp 1)))) - (looking-at ";+[\t ]*")) + ((condition-case nil + (save-restriction + (narrow-to-region (point-min) + (save-excursion (end-of-line) (point))) + (while (not (looking-at ";\\|$")) + (skip-chars-forward "^;\n\"\\\\?") + (cond + ((eq (char-after (point)) ?\\) (forward-char 2)) + ((memq (char-after (point)) '(?\" ??)) (forward-sexp 1)))) + (looking-at ";+[\t ]*")) + (error nil)) (setq has-comment t) (setq comment-fill-prefix - (concat (make-string (current-column) ? ) + (concat (make-string (/ (current-column) 8) ?\t) + (make-string (% (current-column) 8) ?\ ) (buffer-substring (match-beginning 0) (match-end 0))))))) (if (not has-comment) @@ -715,13 +720,14 @@ and initial semicolons." ;; Narrow to include only the comment, and then fill the region. (save-restriction + (beginning-of-line) (narrow-to-region ;; Find the first line we should include in the region to fill. (save-excursion (while (and (zerop (forward-line -1)) (looking-at "^[ \t]*;"))) ;; We may have gone to far. Go forward again. - (or (looking-at "^[ \t]*;") + (or (looking-at ".*;") (forward-line 1)) (point)) ;; Find the beginning of the first line past the region to fill. @@ -734,7 +740,7 @@ and initial semicolons." (let ((paragraph-start (concat paragraph-start "\\|[ \t;]*$")) (paragraph-separate (concat paragraph-start "\\|[ \t;]*$")) (fill-prefix comment-fill-prefix)) - (fill-paragraph justify)))) + (fill-region (point-min) (point-max) justify t)))) t)) |