unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: martin rudalics <rudalics@gmx.at>
Cc: cplate@web.de, emacs-devel@gnu.org
Subject: Re: re-builder highlighting incorrect for more than 3 groupings
Date: Thu, 27 Apr 2006 10:55:07 +0200	[thread overview]
Message-ID: <445086EB.3080100@gmx.at> (raw)
In-Reply-To: <E1FYyEW-0002Ci-H2@fencepost.gnu.org>

[-- Attachment #1: Type: text/plain, Size: 244 bytes --]

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


[-- Attachment #2: re-builder.patch --]
[-- Type: text/plain, Size: 3312 bytes --]

2006-04-27  Martin Rudalics  <rudalics@gmx.at>

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

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

  reply	other threads:[~2006-04-27  8:55 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-25 19:40 re-builder highlighting incorrect for more than 3 groupings Christian Plate
2006-04-26  6:56 ` martin rudalics
2006-04-27  4:36   ` Richard Stallman
2006-04-27  8:55     ` martin rudalics [this message]
2006-04-27  9:04     ` Juanma Barranquero
2006-04-28 22:03       ` Adrian Aichner
2006-04-28 23:23         ` Juanma Barranquero
2006-04-29 19:09         ` Richard Stallman
2006-04-29 20:36           ` Adrian Aichner
2006-04-30  1:02           ` Juanma Barranquero
2006-04-29  8:12       ` martin rudalics
2006-04-30  1:07         ` Juanma Barranquero
2006-04-30  3:03         ` Richard Stallman
2006-05-01 15:21           ` Kevin Rodgers
2006-05-02  2:04             ` Richard Stallman
2006-05-02  8:42               ` Juanma Barranquero
2006-05-02  9:06                 ` David Kastrup
2006-05-02  9:30                   ` Juanma Barranquero
2006-05-02  9:38                     ` David Kastrup
2006-05-02 10:17                       ` Juanma Barranquero
2006-05-02 21:37                 ` Richard Stallman

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=445086EB.3080100@gmx.at \
    --to=rudalics@gmx.at \
    --cc=cplate@web.de \
    --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).