emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

lisp-font-lock-syntactic-face-function


From: martin rudalics
Subject: lisp-font-lock-syntactic-face-function
Date: Wed, 18 May 2005 11:11:23 +0200
User-agent: Mozilla Thunderbird 1.0 (Windows/20041206)

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))





reply via email to

[Prev in Thread] Current Thread [Next in Thread]