From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: martin rudalics Newsgroups: gmane.emacs.devel Subject: Re: re-builder highlighting incorrect for more than 3 groupings Date: Thu, 27 Apr 2006 10:55:07 +0200 Message-ID: <445086EB.3080100@gmx.at> References: <87r73ljvfa.fsf@myusenet.dyndns.org> <444F19B7.9080906@gmx.at> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------020905090102030302090608" X-Trace: sea.gmane.org 1146128334 1529 80.91.229.2 (27 Apr 2006 08:58:54 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 27 Apr 2006 08:58:54 +0000 (UTC) Cc: cplate@web.de, emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Apr 27 10:58:47 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1FZ2Ka-0008Li-9C for ged-emacs-devel@m.gmane.org; Thu, 27 Apr 2006 10:58:36 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FZ2KZ-0006zo-Lx for ged-emacs-devel@m.gmane.org; Thu, 27 Apr 2006 04:58:35 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1FZ2KH-0006zR-US for emacs-devel@gnu.org; Thu, 27 Apr 2006 04:58:17 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1FZ2KF-0006yy-9C for emacs-devel@gnu.org; Thu, 27 Apr 2006 04:58:16 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FZ2KF-0006yv-4Z for emacs-devel@gnu.org; Thu, 27 Apr 2006 04:58:15 -0400 Original-Received: from [213.165.64.20] (helo=mail.gmx.net) by monty-python.gnu.org with smtp (Exim 4.52) id 1FZ2N7-0004S3-2j for emacs-devel@gnu.org; Thu, 27 Apr 2006 05:01:13 -0400 Original-Received: (qmail invoked by alias); 27 Apr 2006 08:58:12 -0000 Original-Received: from N780P020.adsl.highway.telekom.at (EHLO [62.47.41.116]) [62.47.41.116] by mail.gmx.net (mp030) with SMTP; 27 Apr 2006 10:58:12 +0200 X-Authenticated: #14592706 User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: de-DE, de, en-us, en Original-To: rms@gnu.org In-Reply-To: X-Y-GMX-Trusted: 0 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:53500 Archived-At: This is a multi-part message in MIME format. --------------020905090102030302090608 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit > You can add as many deffaces > > (defface reb-match-4 ... > > (defface reb-match-5 ... > > Can we do something so that it cycles thru the provided faces > once it has used them all? > > The attached patch tries to do that. --------------020905090102030302090608 Content-Type: text/plain; name="re-builder.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="re-builder.patch" 2006-04-27 Martin Rudalics * emacs-lisp/re-builder.el (reb-update-overlays): Cycle thru provided faces once they have been used all. *** re-builder.el Sat Nov 5 19:44:46 2005 --- re-builder.el Thu Apr 27 10:35:20 2006 *************** *** 112,118 **** (if (not (fboundp 'make-overlay)) (require 'overlay)) ! ;; User costomizable variables (defgroup re-builder nil "Options for the RE Builder." :group 'lisp --- 112,118 ---- (if (not (fboundp 'make-overlay)) (require 'overlay)) ! ;; User customizable variables (defgroup re-builder nil "Options for the RE Builder." :group 'lisp *************** *** 627,637 **** beg (match-end 0))) i)) - (defun reb-update-overlays (&optional subexp) "Switch to `reb-target-buffer' and mark all matches of `reb-regexp'. If SUBEXP is non-nil mark only the corresponding sub-expressions." - (let* ((re (reb-target-binding reb-regexp)) (subexps (reb-count-subexps re)) (matches 0) --- 627,635 ---- *************** *** 645,668 **** (or (not reb-auto-match-limit) (< matches reb-auto-match-limit))) (if (= 0 (length (match-string 0))) ! (error "Empty regular expression!")) ! (let ((i 0)) (setq matches (1+ matches)) (while (<= i subexps) (if (and (or (not subexp) (= subexp i)) (match-beginning i)) (let ((overlay (make-overlay (match-beginning i) (match-end i))) ! (face-name (format "reb-match-%d" i))) ! (if (not firstmatch) ! (setq firstmatch (match-data))) (setq reb-overlays (cons overlay reb-overlays) submatches (1+ submatches)) ! (overlay-put ! overlay 'face ! (or (intern-soft face-name) ! (error "Too many subexpressions - face `%s' not defined" ! face-name ))) (overlay-put overlay 'priority i))) (setq i (1+ i)))))) (let ((count (if subexp submatches matches))) --- 643,677 ---- (or (not reb-auto-match-limit) (< matches reb-auto-match-limit))) (if (= 0 (length (match-string 0))) ! (error "Empty regular expression!")) ! (let ((i 0) ! suffix max-suffix) (setq matches (1+ matches)) (while (<= i subexps) (if (and (or (not subexp) (= subexp i)) (match-beginning i)) (let ((overlay (make-overlay (match-beginning i) (match-end i))) ! ;; When we have exceeded the number of provided faces, ! ;; cycle thru them where `max-suffix' denotes the maximum ! ;; suffix for `reb-match-*' that has been defined and ! ;; `suffix' the suffix calculated for the current match. ! (face ! (cond ! (max-suffix ! (if (= suffix max-suffix) ! (setq suffix 1) ! (setq suffix (1+ suffix))) ! (intern-soft (format "reb-match-%d" suffix))) ! ((intern-soft (format "reb-match-%d" i))) ! ((setq max-suffix (1- i)) ! (setq suffix 1) ! ;; `reb-match-1' must exist. ! 'reb-match-1)))) ! (unless firstmatch (setq firstmatch (match-data))) (setq reb-overlays (cons overlay reb-overlays) submatches (1+ submatches)) ! (overlay-put overlay 'face face) (overlay-put overlay 'priority i))) (setq i (1+ i)))))) (let ((count (if subexp submatches matches))) --------------020905090102030302090608 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel --------------020905090102030302090608--