comparison lisp/emacs-lisp/lisp-mode.el @ 65852:4b5af439906f

(lisp-mode-syntax-table): Move the nesting bit from # to |. (lisp-font-lock-syntactic-face-function): Distinguish |...| symbols.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Wed, 05 Oct 2005 15:19:38 +0000
parents c9b01535e163
children 48fff88992ce aa89c814f853
comparison
equal deleted inserted replaced
65851:c9b01535e163 65852:4b5af439906f
57 (setq i (1+ i))) 57 (setq i (1+ i)))
58 (modify-syntax-entry ?\s " " table) 58 (modify-syntax-entry ?\s " " table)
59 (modify-syntax-entry ?\t " " table) 59 (modify-syntax-entry ?\t " " table)
60 (modify-syntax-entry ?\f " " table) 60 (modify-syntax-entry ?\f " " table)
61 (modify-syntax-entry ?\n "> " table) 61 (modify-syntax-entry ?\n "> " table)
62 ;;; This is probably obsolete since nowadays such features use overlays. 62 ;; This is probably obsolete since nowadays such features use overlays.
63 ;;; ;; Give CR the same syntax as newline, for selective-display. 63 ;; ;; Give CR the same syntax as newline, for selective-display.
64 ;;; (modify-syntax-entry ?\^m "> " table) 64 ;; (modify-syntax-entry ?\^m "> " table)
65 (modify-syntax-entry ?\; "< " table) 65 (modify-syntax-entry ?\; "< " table)
66 (modify-syntax-entry ?` "' " table) 66 (modify-syntax-entry ?` "' " table)
67 (modify-syntax-entry ?' "' " table) 67 (modify-syntax-entry ?' "' " table)
68 (modify-syntax-entry ?, "' " table) 68 (modify-syntax-entry ?, "' " table)
69 (modify-syntax-entry ?@ "' " table) 69 (modify-syntax-entry ?@ "' " table)
80 80
81 (defvar lisp-mode-syntax-table 81 (defvar lisp-mode-syntax-table
82 (let ((table (copy-syntax-table emacs-lisp-mode-syntax-table))) 82 (let ((table (copy-syntax-table emacs-lisp-mode-syntax-table)))
83 (modify-syntax-entry ?\[ "_ " table) 83 (modify-syntax-entry ?\[ "_ " table)
84 (modify-syntax-entry ?\] "_ " table) 84 (modify-syntax-entry ?\] "_ " table)
85 (modify-syntax-entry ?# "' 14bn" table) 85 (modify-syntax-entry ?# "' 14b" table)
86 (modify-syntax-entry ?| "\" 23b" table) 86 (modify-syntax-entry ?| "\" 23bn" table)
87 table)) 87 table))
88 88
89 (define-abbrev-table 'lisp-mode-abbrev-table ()) 89 (define-abbrev-table 'lisp-mode-abbrev-table ())
90 90
91 (defvar lisp-imenu-generic-expression 91 (defvar lisp-imenu-generic-expression
152 (defvar lisp-doc-string-elt-property 'doc-string-elt 152 (defvar lisp-doc-string-elt-property 'doc-string-elt
153 "The symbol property that holds the docstring position info.") 153 "The symbol property that holds the docstring position info.")
154 154
155 (defun lisp-font-lock-syntactic-face-function (state) 155 (defun lisp-font-lock-syntactic-face-function (state)
156 (if (nth 3 state) 156 (if (nth 3 state)
157 ;; This might be a docstring. 157 ;; This might be a (doc)string or a |...| symbol.
158 (let* ((listbeg (nth 1 state)) 158 (let ((startpos (nth 8 state)))
159 (firstsym (and listbeg 159 (if (eq (char-after startpos) ?|)
160 (save-excursion 160 ;; This is not a string, but a |...| symbol.
161 (goto-char listbeg) 161 nil
162 (and (looking-at "([ \t\n]*\\(\\(\\sw\\|\\s_\\)+\\)") 162 (let* ((listbeg (nth 1 state))
163 (match-string 1))))) 163 (firstsym (and listbeg
164 (docelt (and firstsym (get (intern-soft firstsym) 164 (save-excursion
165 lisp-doc-string-elt-property)))) 165 (goto-char listbeg)
166 (if (and docelt 166 (and (looking-at "([ \t\n]*\\(\\(\\sw\\|\\s_\\)+\\)")
167 ;; It's a string passed to a macro that has docstrings. 167 (match-string 1)))))
168 ;; Check whether it's in docstring position. 168 (docelt (and firstsym (get (intern-soft firstsym)
169 (let ((startpos (nth 8 state))) 169 lisp-doc-string-elt-property))))
170 (save-excursion 170 (if (and docelt
171 (when (functionp docelt) 171 ;; It's a string in a form that can have a docstring.
172 (goto-char (match-end 1)) 172 ;; Check whether it's in docstring position.
173 (setq docelt (funcall docelt))) 173 (save-excursion
174 (goto-char listbeg) 174 (when (functionp docelt)
175 (forward-char 1) 175 (goto-char (match-end 1))
176 (condition-case nil 176 (setq docelt (funcall docelt)))
177 (while (and (> docelt 0) (< (point) startpos) 177 (goto-char listbeg)
178 (progn (forward-sexp 1) t)) 178 (forward-char 1)
179 (setq docelt (1- docelt))) 179 (condition-case nil
180 (error nil)) 180 (while (and (> docelt 0) (< (point) startpos)
181 (and (zerop docelt) (<= (point) startpos) 181 (progn (forward-sexp 1) t))
182 (progn (forward-comment (point-max)) t) 182 (setq docelt (1- docelt)))
183 (= (point) (nth 8 state)))))) 183 (error nil))
184 font-lock-doc-face 184 (and (zerop docelt) (<= (point) startpos)
185 font-lock-string-face)) 185 (progn (forward-comment (point-max)) t)
186 (= (point) (nth 8 state)))))
187 font-lock-doc-face
188 font-lock-string-face))))
186 font-lock-comment-face)) 189 font-lock-comment-face))
187 190
188 ;; The LISP-SYNTAX argument is used by code in inf-lisp.el and is 191 ;; The LISP-SYNTAX argument is used by code in inf-lisp.el and is
189 ;; (uselessly) passed from pp.el, chistory.el, gnus-kill.el and score-mode.el 192 ;; (uselessly) passed from pp.el, chistory.el, gnus-kill.el and score-mode.el
190 (defun lisp-mode-variables (&optional lisp-syntax) 193 (defun lisp-mode-variables (&optional lisp-syntax)