Mercurial > emacs
comparison lisp/emacs-lisp/lisp-mode.el @ 40790:3b3c00fa282a
(lisp-imenu-generic-expression): Paren typo.
(lisp-mode-variables): Don't set paragraph-{start,separate}.
Don't disable adaptive-fill-mode.
(lisp-fill-paragraph): Use tab-width rather than 8.
Prevent filling the first line of docstrings.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Wed, 07 Nov 2001 01:15:30 +0000 |
parents | 7441fb1a40ac |
children | a5e4e3a88a9e |
comparison
equal
deleted
inserted
replaced
40789:c85bebc9cbb4 | 40790:3b3c00fa282a |
---|---|
90 "defadvice" "define-skeleton" | 90 "defadvice" "define-skeleton" |
91 "define-minor-mode" "define-derived-mode" | 91 "define-minor-mode" "define-derived-mode" |
92 "define-compiler-macro" "define-modify-macro" | 92 "define-compiler-macro" "define-modify-macro" |
93 "defsetf" "define-setf-expander" | 93 "defsetf" "define-setf-expander" |
94 "define-method-combination" | 94 "define-method-combination" |
95 "defgeneric" "defmethod") t) | 95 "defgeneric" "defmethod") t)) |
96 "\\s-+\\(\\sw\\(\\sw\\|\\s_\\)+\\)"))) | 96 "\\s-+\\(\\sw\\(\\sw\\|\\s_\\)+\\)")) |
97 2) | 97 2) |
98 (list (purecopy "Variables") | 98 (list (purecopy "Variables") |
99 (purecopy (concat "^\\s-*(" | 99 (purecopy (concat "^\\s-*(" |
100 (eval-when-compile | 100 (eval-when-compile |
101 (regexp-opt | 101 (regexp-opt |
102 '("defvar" "defconst" "defconstant" "defcustom" | 102 '("defvar" "defconst" "defconstant" "defcustom" |
103 "defparameter" "define-symbol-macro") t) | 103 "defparameter" "define-symbol-macro") t)) |
104 "\\s-+\\(\\sw\\(\\sw\\|\\s_\\)+\\)"))) | 104 "\\s-+\\(\\sw\\(\\sw\\|\\s_\\)+\\)")) |
105 2) | 105 2) |
106 (list (purecopy "Types") | 106 (list (purecopy "Types") |
107 (purecopy (concat "^\\s-*(" | 107 (purecopy (concat "^\\s-*(" |
108 (eval-when-compile | 108 (eval-when-compile |
109 (regexp-opt | 109 (regexp-opt |
110 '("defgroup" "deftype" "defstruct" "defclass" | 110 '("defgroup" "deftype" "defstruct" "defclass" |
111 "define-condition" "define-widget" "defface" | 111 "define-condition" "define-widget" "defface" |
112 "defpackage") t) | 112 "defpackage") t)) |
113 "\\s-+'?\\(\\sw\\(\\sw\\|\\s_\\)+\\)"))) | 113 "\\s-+'?\\(\\sw\\(\\sw\\|\\s_\\)+\\)")) |
114 2)) | 114 2)) |
115 | 115 |
116 "Imenu generic expression for Lisp mode. See `imenu-generic-expression'.") | 116 "Imenu generic expression for Lisp mode. See `imenu-generic-expression'.") |
117 | 117 |
118 ;; This was originally in autoload.el and is still used there. | 118 ;; This was originally in autoload.el and is still used there. |
153 font-lock-comment-face)) | 153 font-lock-comment-face)) |
154 | 154 |
155 ;; The LISP-SYNTAX argument is used by code in inf-lisp.el and is | 155 ;; The LISP-SYNTAX argument is used by code in inf-lisp.el and is |
156 ;; (uselessly) passed from pp.el, chistory.el, gnus-kill.el and score-mode.el | 156 ;; (uselessly) passed from pp.el, chistory.el, gnus-kill.el and score-mode.el |
157 (defun lisp-mode-variables (&optional lisp-syntax) | 157 (defun lisp-mode-variables (&optional lisp-syntax) |
158 (cond (lisp-syntax | 158 (when lisp-syntax |
159 (set-syntax-table lisp-mode-syntax-table))) | 159 (set-syntax-table lisp-mode-syntax-table)) |
160 (setq local-abbrev-table lisp-mode-abbrev-table) | 160 (setq local-abbrev-table lisp-mode-abbrev-table) |
161 (make-local-variable 'paragraph-start) | |
162 (setq paragraph-start (concat page-delimiter "\\|$" )) | |
163 (make-local-variable 'paragraph-separate) | |
164 (setq paragraph-separate paragraph-start) | |
165 (make-local-variable 'paragraph-ignore-fill-prefix) | 161 (make-local-variable 'paragraph-ignore-fill-prefix) |
166 (setq paragraph-ignore-fill-prefix t) | 162 (setq paragraph-ignore-fill-prefix t) |
167 (make-local-variable 'fill-paragraph-function) | 163 (make-local-variable 'fill-paragraph-function) |
168 (setq fill-paragraph-function 'lisp-fill-paragraph) | 164 (setq fill-paragraph-function 'lisp-fill-paragraph) |
169 ;; Adaptive fill mode gets in the way of auto-fill, | 165 ;; Adaptive fill mode gets in the way of auto-fill, |
170 ;; and should make no difference for explicit fill | 166 ;; and should make no difference for explicit fill |
171 ;; because lisp-fill-paragraph should do the job. | 167 ;; because lisp-fill-paragraph should do the job. |
172 (make-local-variable 'adaptive-fill-mode) | 168 ;; I believe that newcomment's auto-fill code properly deals with it -stef |
173 (setq adaptive-fill-mode nil) | 169 ;;(set (make-local-variable 'adaptive-fill-mode) nil) |
174 (make-local-variable 'normal-auto-fill-function) | 170 (make-local-variable 'normal-auto-fill-function) |
175 (setq normal-auto-fill-function 'lisp-mode-auto-fill) | 171 (setq normal-auto-fill-function 'lisp-mode-auto-fill) |
176 (make-local-variable 'indent-line-function) | 172 (make-local-variable 'indent-line-function) |
177 (setq indent-line-function 'lisp-indent-line) | 173 (setq indent-line-function 'lisp-indent-line) |
178 (make-local-variable 'indent-region-function) | 174 (make-local-variable 'indent-region-function) |
615 (if (listp tem) (car tem) tem)) | 611 (if (listp tem) (car tem) tem)) |
616 (skip-chars-backward " \t") | 612 (skip-chars-backward " \t") |
617 (max (if (bolp) 0 (1+ (current-column))) | 613 (max (if (bolp) 0 (1+ (current-column))) |
618 comment-column)))) | 614 comment-column)))) |
619 | 615 |
616 ;; This function just forces a more costly detection of comments (using | |
617 ;; parse-partial-sexp from beginning-of-defun). I.e. It avoids the problem of | |
618 ;; taking a `;' inside a string started on another line for a comment starter. | |
619 ;; Note: `newcomment' gets it right in 99% of the cases if you're using | |
620 ;; font-lock, anyway, so we could get rid of it. -stef | |
620 (defun lisp-mode-auto-fill () | 621 (defun lisp-mode-auto-fill () |
621 (if (> (current-column) (current-fill-column)) | 622 (if (> (current-column) (current-fill-column)) |
622 (if (save-excursion | 623 (if (save-excursion |
623 (nth 4 (parse-partial-sexp (save-excursion | 624 (nth 4 (parse-partial-sexp (save-excursion |
624 (beginning-of-defun) | 625 (beginning-of-defun) |
1052 ((memq (char-after (point)) '(?\" ??)) (forward-sexp 1)))) | 1053 ((memq (char-after (point)) '(?\" ??)) (forward-sexp 1)))) |
1053 (looking-at ";+[\t ]*")) | 1054 (looking-at ";+[\t ]*")) |
1054 (error nil)) | 1055 (error nil)) |
1055 (setq has-comment t has-code-and-comment t) | 1056 (setq has-comment t has-code-and-comment t) |
1056 (setq comment-fill-prefix | 1057 (setq comment-fill-prefix |
1057 (concat (make-string (/ (current-column) 8) ?\t) | 1058 (concat (make-string (/ (current-column) tab-width) ?\t) |
1058 (make-string (% (current-column) 8) ?\ ) | 1059 (make-string (% (current-column) tab-width) ?\ ) |
1059 (buffer-substring (match-beginning 0) (match-end 0))))))) | 1060 (buffer-substring (match-beginning 0) (match-end 0))))))) |
1060 | 1061 |
1061 (if (not has-comment) | 1062 (if (not has-comment) |
1062 ;; `paragraph-start' is set here (not in the buffer-local | 1063 ;; `paragraph-start' is set here (not in the buffer-local |
1063 ;; variable so that `forward-paragraph' et al work as | 1064 ;; variable so that `forward-paragraph' et al work as |
1066 ;; filled means that sexps generally aren't filled as normal | 1067 ;; filled means that sexps generally aren't filled as normal |
1067 ;; text, which is probably sensible. The `;' and `:' stop the | 1068 ;; text, which is probably sensible. The `;' and `:' stop the |
1068 ;; filled para at following comment lines and keywords | 1069 ;; filled para at following comment lines and keywords |
1069 ;; (typically in `defcustom'). | 1070 ;; (typically in `defcustom'). |
1070 (let ((paragraph-start (concat paragraph-start | 1071 (let ((paragraph-start (concat paragraph-start |
1071 "\\|\\s-*[\(;:\"]"))) | 1072 "\\|\\s-*[\(;:\"]")) |
1073 ;; Avoid filling the first line of docstring. | |
1074 (paragraph-separate | |
1075 (concat paragraph-separate "\\|\\s-*\".*\\.$"))) | |
1072 (fill-paragraph justify)) | 1076 (fill-paragraph justify)) |
1073 | 1077 |
1074 ;; Narrow to include only the comment, and then fill the region. | 1078 ;; Narrow to include only the comment, and then fill the region. |
1075 (save-excursion | 1079 (save-excursion |
1076 (save-restriction | 1080 (save-restriction |
1077 (beginning-of-line) | 1081 (beginning-of-line) |
1078 (narrow-to-region | 1082 (narrow-to-region |
1079 ;; Find the first line we should include in the region to fill. | 1083 ;; Find the first line we should include in the region to fill. |
1080 (save-excursion | 1084 (save-excursion |
1081 (while (and (zerop (forward-line -1)) | 1085 (while (and (looking-at "[ \t]*;") |
1082 (looking-at "^[ \t]*;"))) | 1086 (zerop (forward-line -1)))) |
1083 ;; We may have gone too far. Go forward again. | |
1084 (or (looking-at ".*;") | |
1085 (forward-line 1)) | |
1086 (point)) | 1087 (point)) |
1087 ;; Find the beginning of the first line past the region to fill. | 1088 ;; Find the beginning of the first line past the region to fill. |
1088 (save-excursion | 1089 (save-excursion |
1089 (while (progn (forward-line 1) | 1090 (while (progn (forward-line 1) |
1090 (looking-at "^[ \t]*;"))) | 1091 (looking-at "[ \t]*;"))) |
1091 (point))) | 1092 (point))) |
1092 | 1093 |
1093 ;; Lines with only semicolons on them can be paragraph boundaries. | 1094 ;; Lines with only semicolons on them can be paragraph boundaries. |
1094 (let* ((paragraph-start (concat paragraph-start "\\|[ \t;]*$")) | 1095 (let* ((paragraph-start (concat paragraph-start "\\|[ \t;]*$")) |
1095 (paragraph-separate (concat paragraph-start "\\|[ \t;]*$")) | 1096 (paragraph-separate (concat paragraph-start "\\|[ \t;]*$")) |