unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* lisp-font-lock-syntactic-face-function
@ 2005-05-18  9:11 martin rudalics
  2005-05-18 23:49 ` lisp-font-lock-syntactic-face-function Stefan Monnier
  0 siblings, 1 reply; 6+ messages in thread
From: martin rudalics @ 2005-05-18  9:11 UTC (permalink / raw)


In `lisp-font-lock-syntactic-face-function' the expression

(eq n (or (get sym 'doc-string-elt) 3))

causes to paint _every_ third string subexpression of a top-level
expression with `font-lock-doc-face'.  That's annoying in a number of
cases like, for example, `define-abbrev'.  Why not simplify this to

(eq n (get sym 'doc-string-elt))

and provide the necessary additional doc-string-elts like,

(put 'defgroup 'doc-string-elt 3)
(put 'defface 'doc-string-elt 3)

(put 'defalias 'doc-string-elt 3)
(put 'defvaralias 'doc-string-elt 3)
(put 'define-obsolete-function-alias 'doc-string-elt 4)
(put 'define-obsolete-variable-alias 'doc-string-elt 4)

(put 'defimage 'doc-string-elt 3)
(put 'define-category 'doc-string-elt 2)
(put 'define-widget 'doc-string-elt 3)

Also, the while loop in `lisp-font-lock-syntactic-face-function' seems
overly expensive: For example, any top-level expression terminating with
a string requires to backward-sexp from the start of the string to the
start of the expression just to find out that the string is not a
doc-string.

I tried the following with the puts from above and encountered no
problems so far:

(defun lisp-font-lock-syntactic-face-function (state)
   (if (nth 3 state)
       (if (and (eq (nth 0 state) 1)
                (nth 1 state)            ; is this needed ???
                (save-excursion
                  (let* ((from (1+ (nth 1 state))) ; is 1+ OK here ???
                         (sym (intern-soft
                               (buffer-substring
                                from
                                (progn
                                  (goto-char from) (forward-sexp 1) (point)))))
                         (doc-string-elt (get sym 'doc-string-elt)))
                    (and (numberp doc-string-elt) ; check for > 0 too ???
                         (condition-case nil
                             (progn
                               (forward-sexp (1- doc-string-elt))
                               (forward-comment (buffer-size))
                               ;; the last two lines could be replaced by:
                               ;; (forward-sexp doc-string-elt)
                               ;; (backward-sexp)
                               (= (point) (nth 8 state)))
                           (scan-error nil))))))
	  font-lock-doc-face
	font-lock-string-face)
     font-lock-comment-face))

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2005-11-21  0:02 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-05-18  9:11 lisp-font-lock-syntactic-face-function martin rudalics
2005-05-18 23:49 ` lisp-font-lock-syntactic-face-function Stefan Monnier
2005-10-21  8:05   ` lisp-font-lock-syntactic-face-function martin rudalics
2005-10-24 16:48     ` lisp-font-lock-syntactic-face-function Stefan Monnier
2005-11-18 10:49       ` lisp-font-lock-syntactic-face-function martin rudalics
2005-11-21  0:02         ` lisp-font-lock-syntactic-face-function Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).