Mercurial > emacs
comparison lisp/emacs-lisp/lisp-mode.el @ 13802:8107433d6a22
(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.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Thu, 21 Dec 1995 17:54:46 +0000 |
parents | 1319330ca7ff |
children | 5f985037b64f |
comparison
equal
deleted
inserted
replaced
13801:b400658e8735 | 13802:8107433d6a22 |
---|---|
696 (match-end 0)))) | 696 (match-end 0)))) |
697 | 697 |
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) |
714 (fill-paragraph justify) | 719 (fill-paragraph justify) |
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. |
728 (save-excursion | 734 (save-excursion |
729 (while (progn (forward-line 1) | 735 (while (progn (forward-line 1) |
732 | 738 |
733 ;; Lines with only semicolons on them can be paragraph boundaries. | 739 ;; Lines with only semicolons on them can be paragraph boundaries. |
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 |
741 (defun indent-code-rigidly (start end arg &optional nochange-regexp) | 747 (defun indent-code-rigidly (start end arg &optional nochange-regexp) |
742 "Indent all lines of code, starting in the region, sideways by ARG columns. | 748 "Indent all lines of code, starting in the region, sideways by ARG columns. |