comparison lisp/emacs-lisp/lisp-mode.el @ 14817:cdd8a024f000

(lisp-fill-paragraph): Treat code-and-comment case specially.
author Richard M. Stallman <rms@gnu.org>
date Sun, 17 Mar 1996 15:38:50 +0000
parents 20f4c4a078b2
children ca84d7021f4e
comparison
equal deleted inserted replaced
14816:485422b900d3 14817:cdd8a024f000
701 (interactive "P") 701 (interactive "P")
702 (let ( 702 (let (
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 )
709 712
710 ;; Figure out what kind of comment we are looking at. 713 ;; Figure out what kind of comment we are looking at.
730 (cond 733 (cond
731 ((eq (char-after (point)) ?\\) (forward-char 2)) 734 ((eq (char-after (point)) ?\\) (forward-char 2))
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) ?\ )
739 (buffer-substring (match-beginning 0) (match-end 0))))))) 742 (buffer-substring (match-beginning 0) (match-end 0)))))))
740 743
763 ;; Lines with only semicolons on them can be paragraph boundaries. 766 ;; Lines with only semicolons on them can be paragraph boundaries.
764 (let* ((paragraph-start (concat paragraph-start "\\|[ \t;]*$")) 767 (let* ((paragraph-start (concat paragraph-start "\\|[ \t;]*$"))
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
776 (goto-char beg) 787 (goto-char beg)
777 (if (looking-at fill-prefix) 788 (if (looking-at fill-prefix)
778 nil 789 nil
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.
786 Does not affect lines starting inside comments or strings, assuming that 796 Does not affect lines starting inside comments or strings, assuming that
787 the start of the region is not inside them. 797 the start of the region is not inside them.