unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: lisp-font-lock-syntactic-face-function
Date: Wed, 18 May 2005 19:49:38 -0400	[thread overview]
Message-ID: <87fywk85bl.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <428B06BB.6070701@gmx.at> (martin rudalics's message of "Wed, 18 May 2005 11:11:23 +0200")

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

[ I wrote the code ]
I have no opinion on this.

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

I don't have time to look into it in detail, but the approach looks fine.


        Stefan

  reply	other threads:[~2005-05-18 23:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-18  9:11 lisp-font-lock-syntactic-face-function martin rudalics
2005-05-18 23:49 ` Stefan Monnier [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87fywk85bl.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).