From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: lisp-font-lock-syntactic-face-function Date: Wed, 18 May 2005 19:49:38 -0400 Message-ID: <87fywk85bl.fsf-monnier+emacs@gnu.org> References: <428B06BB.6070701@gmx.at> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1116461777 5378 80.91.229.2 (19 May 2005 00:16:17 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 19 May 2005 00:16:17 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu May 19 02:16:15 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DYYhH-0004Q0-Cf for ged-emacs-devel@m.gmane.org; Thu, 19 May 2005 02:15:31 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DYYjo-0001um-IF for ged-emacs-devel@m.gmane.org; Wed, 18 May 2005 20:18:08 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DYYfM-0006To-NW for emacs-devel@gnu.org; Wed, 18 May 2005 20:13:32 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DYYfK-0006SF-WB for emacs-devel@gnu.org; Wed, 18 May 2005 20:13:31 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DYYfK-0006P4-09 for emacs-devel@gnu.org; Wed, 18 May 2005 20:13:30 -0400 Original-Received: from [209.226.175.110] (helo=tomts43-srv.bellnexxia.net) by monty-python.gnu.org with esmtp (Exim 4.34) id 1DYYl8-0002lx-Tv for emacs-devel@gnu.org; Wed, 18 May 2005 20:19:31 -0400 Original-Received: from alfajor ([70.49.81.51]) by tomts43-srv.bellnexxia.net (InterMail vM.5.01.06.10 201-253-122-130-110-20040306) with ESMTP id <20050519001108.GJBJ2981.tomts43-srv.bellnexxia.net@alfajor>; Wed, 18 May 2005 20:11:08 -0400 Original-Received: by alfajor (Postfix, from userid 1000) id 0C73CD7324; Wed, 18 May 2005 19:49:38 -0400 (EDT) Original-To: martin rudalics In-Reply-To: <428B06BB.6070701@gmx.at> (martin rudalics's message of "Wed, 18 May 2005 11:11:23 +0200") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:37320 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:37320 > 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