From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#13541: 24.2.92; awk-mode: wrong font locking regexp literals Date: Fri, 25 Jan 2013 17:50:57 +0000 Message-ID: <20130125175057.GA3345@acm.acm> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1359137778 20102 80.91.229.3 (25 Jan 2013 18:16:18 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 25 Jan 2013 18:16:18 +0000 (UTC) Cc: 13541@debbugs.gnu.org To: Leo Liu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Jan 25 19:16:37 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1TynpL-0007Vt-AP for geb-bug-gnu-emacs@m.gmane.org; Fri, 25 Jan 2013 19:16:35 +0100 Original-Received: from localhost ([::1]:40026 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tynp3-0004aN-Mw for geb-bug-gnu-emacs@m.gmane.org; Fri, 25 Jan 2013 13:16:17 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:56787) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tynow-0004Z7-HH for bug-gnu-emacs@gnu.org; Fri, 25 Jan 2013 13:16:16 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tynov-0006Uw-Bt for bug-gnu-emacs@gnu.org; Fri, 25 Jan 2013 13:16:10 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:44036) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TynXF-0000vj-P8; Fri, 25 Jan 2013 12:57:53 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1TynXO-0006qH-FC; Fri, 25 Jan 2013 12:58:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Fri, 25 Jan 2013 17:58:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 13541 X-GNU-PR-Package: emacs,cc-mode X-GNU-PR-Keywords: X-Debbugs-Original-Cc: bug-cc-mode@gnu.org, Glenn Morris , 13541@debbugs.gnu.org Original-Received: via spool by 13541-submit@debbugs.gnu.org id=B13541.135913668026293 (code B ref 13541); Fri, 25 Jan 2013 17:58:02 +0000 Original-Received: (at 13541) by debbugs.gnu.org; 25 Jan 2013 17:58:00 +0000 Original-Received: from localhost ([127.0.0.1]:49500 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TynXL-0006q2-Np for submit@debbugs.gnu.org; Fri, 25 Jan 2013 12:58:00 -0500 Original-Received: from colin.muc.de ([193.149.48.1]:44171 helo=mail.muc.de) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TynXI-0006pt-Qs for 13541@debbugs.gnu.org; Fri, 25 Jan 2013 12:57:58 -0500 Original-Received: (qmail 40203 invoked by uid 3782); 25 Jan 2013 17:57:45 -0000 Original-Received: from acm.muc.de (pD9519D27.dip.t-dialin.net [217.81.157.39]) by colin.muc.de (tmda-ofmipd) with ESMTP; Fri, 25 Jan 2013 18:57:38 +0100 Original-Received: (qmail 3497 invoked by uid 1000); 25 Jan 2013 17:50:57 -0000 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:70311 Archived-At: Hi, Leo. On Thu, Jan 24, 2013 at 07:43:06PM +0800, Leo Liu wrote: > In an awk buffer having the following text: > #--BEGIN-- > NF { /xyz/ } > NF { > /xyz/ > } > #--END-- > I have the second regexp properly font-locked but not the first one. Yes. Could you please try out, fairly thoroughly, the following patch, and let me know how it goes. It aims to fontify a /regexp/ wherever one might occur. === modified file 'lisp/progmodes/cc-awk.el' *** lisp/progmodes/cc-awk.el 2013-01-01 09:11:05 +0000 --- lisp/progmodes/cc-awk.el 2013-01-25 17:47:38 +0000 *************** *** 211,217 **** ;; division sign. (defconst c-awk-neutral-re ; "\\([{}@` \t]\\|\\+\\+\\|--\\|\\\\.\\)+") ; changed, 2003/6/7 ! "\\([{}@` \t]\\|\\+\\+\\|--\\|\\\\.\\)") ;; A "neutral" char(pair). Doesn't change the "state" of a subsequent /. ;; This is space/tab, braces, an auto-increment/decrement operator or an ;; escaped character. Or one of the (invalid) characters @ or `. But NOT an --- 211,217 ---- ;; division sign. (defconst c-awk-neutral-re ; "\\([{}@` \t]\\|\\+\\+\\|--\\|\\\\.\\)+") ; changed, 2003/6/7 ! "\\([}@` \t]\\|\\+\\+\\|--\\|\\\\\\(.\\|[\n\r]\\)\\)") ;; A "neutral" char(pair). Doesn't change the "state" of a subsequent /. ;; This is space/tab, braces, an auto-increment/decrement operator or an ;; escaped character. Or one of the (invalid) characters @ or `. But NOT an *************** *** 231,237 **** ;; will only work when there won't be a preceding " or / before the sought / ;; to foul things up. (defconst c-awk-non-arith-op-bra-re ! "[[\(&=:!><,?;'~|]") ;; Matches an opening BRAcket, round or square, or any operator character ;; apart from +,-,/,*,%. For the purpose at hand (detecting a / which is a ;; regexp bracket) these arith ops are unnecessary and a pain, because of "++" --- 231,237 ---- ;; will only work when there won't be a preceding " or / before the sought / ;; to foul things up. (defconst c-awk-non-arith-op-bra-re ! "[[\({&=:!><,?;'~|]") ;; Matches an opening BRAcket, round or square, or any operator character ;; apart from +,-,/,*,%. For the purpose at hand (detecting a / which is a ;; regexp bracket) these arith ops are unnecessary and a pain, because of "++" *************** *** 242,247 **** --- 242,257 ---- ;; bracket, in a context where an immediate / would be a division sign. This ;; will only work when there won't be a preceding " or / before the sought / ;; to foul things up. + (defconst c-awk-pre-exp-alphanum-kwd-re + (concat "\\(^\\|[^_\n\r]\\)\\<" + (regexp-opt '("print" "return" "case") t) + "\\>\\([^_\n\r]\\|$\\)")) + ;; Matches all AWK keywords which can precede expressions (including + ;; /regexp/). + (defconst c-awk-kwd-regexp-sign-re + (concat c-awk-pre-exp-alphanum-kwd-re c-awk-neutrals*-re "/")) + ;; Matches a piece of AWK buffer ending in /, where is a keyword + ;; which can precede an expression. ;; REGEXPS USED FOR FINDING THE POSITION OF A "virtual semicolon" (defconst c-awk-_-harmless-nonws-char-re "[^#/\"\\\\\n\r \t]") *************** *** 721,729 **** (goto-char anchor) ;; Analyze the line to find out what the / is. (if (if anchor-state-/div ! (not (search-forward-regexp c-awk-regexp-sign-re (1+ /point) t)) ! (search-forward-regexp c-awk-div-sign-re (1+ /point) t)) ! ;; A division sign. (progn (goto-char (1+ /point)) nil) ;; A regexp opener ;; Jump over the regexp innards, setting the match data. --- 731,740 ---- (goto-char anchor) ;; Analyze the line to find out what the / is. (if (if anchor-state-/div ! (not (search-forward-regexp c-awk-regexp-sign-re (1+ /point) t)) ! (and (not (search-forward-regexp c-awk-kwd-regexp-sign-re (1+ /point) t)) ! (search-forward-regexp c-awk-div-sign-re (1+ /point) t))) ! ;; A division sign. (progn (goto-char (1+ /point)) nil) ;; A regexp opener ;; Jump over the regexp innards, setting the match data. > Leo -- Alan Mackenzie (Nuremberg, Germany).