From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tassilo Horn Newsgroups: gmane.emacs.devel,gmane.emacs.help Subject: Bug in Elisp font-locking (was: Concern around use of eval) Date: Fri, 20 Mar 2015 18:19:43 +0100 Message-ID: <87d243si1c.fsf_-_@gnu.org> References: <878uerem09.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1426872025 29176 80.91.229.3 (20 Mar 2015 17:20:25 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 20 Mar 2015 17:20:25 +0000 (UTC) Cc: help-gnu-emacs@gnu.org, emacs-devel@gnu.org To: Thierry Volpiatto Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Mar 20 18:20:16 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YZ0ai-0003bX-7E for ged-emacs-devel@m.gmane.org; Fri, 20 Mar 2015 18:20:12 +0100 Original-Received: from localhost ([::1]:44906 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YZ0ah-0007Xa-8L for ged-emacs-devel@m.gmane.org; Fri, 20 Mar 2015 13:20:11 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54559) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YZ0aS-0007XU-AE for emacs-devel@gnu.org; Fri, 20 Mar 2015 13:19:57 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YZ0aJ-0004go-Jt for emacs-devel@gnu.org; Fri, 20 Mar 2015 13:19:56 -0400 Original-Received: from out3-smtp.messagingengine.com ([66.111.4.27]:53776) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YZ0aJ-0004gi-Bi for emacs-devel@gnu.org; Fri, 20 Mar 2015 13:19:47 -0400 Original-Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 8A1A6208DF for ; Fri, 20 Mar 2015 13:19:44 -0400 (EDT) Original-Received: from frontend2 ([10.202.2.161]) by compute1.internal (MEProxy); Fri, 20 Mar 2015 13:19:46 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=x-sasl-enc:from:to:cc:subject:references :date:in-reply-to:message-id:mime-version:content-type; s= smtpout; bh=PvKkp0Jui/lzxDGaZsCNjYW9kZc=; b=l2i2zGmsRj7qjRCOFaMQ s2XGlO9Mb4jdp90RXkFicU1fyqzEemUsmLQoBab/YsbES6j2f/0tDedWEP5J+anX WJApFyW+Q6R7exj3/4DKxSAwbhS0YrylDeGrP6NB0eeBSiLldeYxBaQ04V9JVxAo KCROH5RpHoMNfB8iqbtyk/Q= X-Sasl-enc: 9IkofUUlwHvFn4Uh5mmKaF9pqFDWQxOF1PkGBbxtPKPB 1426871986 Original-Received: from thinkpad-t440p (unknown [2.161.210.144]) by mail.messagingengine.com (Postfix) with ESMTPA id ECFC06800F3; Fri, 20 Mar 2015 13:19:45 -0400 (EDT) Mail-Followup-To: Thierry Volpiatto , help-gnu-emacs@gnu.org, emacs-devel@gnu.org In-Reply-To: <878uerem09.fsf@gmail.com> (Thierry Volpiatto's message of "Fri, 20 Mar 2015 16:17:42 +0100") User-Agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/25.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 66.111.4.27 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:184045 gmane.emacs.help:103226 Archived-At: Thierry Volpiatto writes: >> (defun lh/gen-predicate (label) >> (defalias (intern (concat "lh/" label "-p")) > ^^^^^^ > In this case intern should not be highlighted, isn't it ?. Indeed, it shouldn't be. But the font-lock entry for definitions which applies the function name face here matches next to `defun', `defmacro', or `defalias' also `cl-defstruct', and that may have the two forms (defstruct struct-name ...) (defstruct (struct-name OPTIONS) ...) and therefore, the regexp simply skips the paren. The following patch should fix that. Cc-ing emacs-devel to ask if that's ok to commit. Is it? Or too much hassle for just `defalias'? (I think that's the only definition form which is implemented as a function where the name may be provided by a funcall.) --8<---------------cut here---------------start------------->8--- diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index 6b30773..614fbc6 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el @@ -320,14 +320,18 @@ `( ;; Definitions. (,(concat "(" el-defs-re "\\_>" ;; Any whitespace and defined object. - "[ \t'\(]*" - "\\(\\(?:\\sw\\|\\s_\\)+\\)?") + "[ \t']*" + ;; With defstruct, the name may follow a paren, + ;; e.g. (defstruct (foo-struct opts)...). + "\\(([ \t']*\\)?\\(\\(?:\\sw\\|\\s_\\)+\\)?") (1 font-lock-keyword-face) - (2 (let ((type (get (intern-soft (match-string 1)) 'lisp-define-type))) - (cond ((eq type 'var) font-lock-variable-name-face) - ((eq type 'type) font-lock-type-face) - (t font-lock-function-name-face))) - nil t)) + (3 (let ((type (get (intern-soft (match-string 1)) 'lisp-define-type))) + (cond ((eq type 'var) font-lock-variable-name-face) + ((eq type 'type) font-lock-type-face) + ;; If match-string 2 is non-nil, we encountered a + ;; form like (defalias (intern (concat s "-p"))). + ((not (match-string 2)) font-lock-function-name-face))) + nil t)) ;; Emacs Lisp autoload cookies. Supports the slightly different ;; forms used by mh-e, calendar, etc. ("^;;;###\\([-a-z]*autoload\\)" 1 font-lock-warning-face prepend)) --8<---------------cut here---------------end--------------->8--- Bye, Tassilo