unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: dapfy@t-online.de (Daniel Pfeiffer)
Cc: emacs-devel@gnu.org
Subject: Re: Changes to emacs/lisp/progmodes/grep.el
Date: Fri, 2 Jul 2004 23:58:48 +0200	[thread overview]
Message-ID: <20040702235848.255ecbbe@pfdabpc.inhouse.start.de> (raw)
In-Reply-To: <87oen1k4yc.fsf@mail.jurta.org>

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

Saluton,

Thanks a lot for your patch.  I'm sending what I discussed below, and it seems
to work.  Could you please reverify and also write a ChangeLog?

Juri Linkov <juri@jurta.org> skribis:

> dapfy@t-online.de (Daniel Pfeiffer) writes:

> Anyhow, there is a new patch below which puts an `invisible' property
> on matched strings.  I tested it, and I find it acceptable even with
> invisible text since I don't operate too much on the grep buffer.

Without my understanding why, patch barfed at both halves of this, so I had to
apply it manually :-(

> Daniel, you added a new option `grep-error-screen-columns' recently.
> But I don't see where it is used.  Could you tell how do you plan to
> use it?  Currently I set `compilation-error-screen-columns' to nil in
> `grep-regexp-alist', but perhaps I should use `grep-error-screen-columns'?

Ah ha!  Grep inherits from compilation, so all the like-named variables get
passed through.  As for your setting this on every match, I don't see the
point, not even setting this once.  This is an option, which means that people
could set it to match the understanding of whatever external prog they use.

> BTW, as you can see below I also changed handling of `end-mk' in
> `compilation-goto-locus'.  Currently it activates the region around a
> matched string.  This is very inconvenient.  I changed this to put a
> highlighted overlay on a matched string just as it does now for the
> whole line.

This was Stef's idea for users of transient-mark-mode.  It has the advantage
of staying around longer, but your approach is more useful for everyone.  (I
suspect transient-mark-mode is not so popular, at least not with me.)

> diff -u -r1.16 grep.el
> --- lisp/progmodes/grep.el	23 Jun 2004 23:10:33 -0000	1.16
> +++ lisp/progmodes/grep.el	30 Jun 2004 03:27:24 -0000

> +     (4 (list 'face nil 'invisible t 'intangible t))
> +     (5 (list 'face compilation-column-face))
> +     (6 (list 'face nil 'invisible t 'intangible t))

I've simplified these a little and made the face customizable, defaulting to
isearch's.

> diff -u -r1.322 compile.el
> --- lisp/progmodes/compile.el	18 Jun 2004 23:00:46 -0000	1.322
> +++ lisp/progmodes/compile.el	30 Jun 2004 03:35:13 -0000

> +	(overlay-put compilation-highlight-overlay 'face next-error-face))

This variable is undefined.

coralament / best Grötens / liebe Grüße / best regards / elkorajn salutojn
Daniel Pfeiffer

-- 
lerne / learn / apprends / lär dig / ucz się    Esperanto:
                              http://lernu.net/

[-- Attachment #2: gnu-grep.patch --]
[-- Type: application/octet-stream, Size: 5462 bytes --]

--- /home/pfeiffer/.emacs.d/cvs/lisp/progmodes/compile.el.~1.322.~	2004-06-19 01:00:08.000000000 +0200
+++ compile.el (buffer)	2004-07-02 23:50:01.414072000 +0200
@@ -579,12 +579,17 @@
     (and end-line
 	 (setq end-line (match-string-no-properties end-line))
 	 (setq end-line (string-to-number end-line)))
-    (and col
-	 (setq col (match-string-no-properties col))
-	 (setq col (- (string-to-number col) compilation-first-column)))
-    (if (and end-col (setq end-col (match-string-no-properties end-col)))
-	(setq end-col (- (string-to-number end-col) compilation-first-column -1))
-      (if end-line (setq end-col -1)))
+    (if col
+	(if (functionp col)
+	    (setq col (funcall col))
+	  (and
+	   (setq col (match-string-no-properties col))
+	   (setq col (- (string-to-number col) compilation-first-column)))))
+    (if (and end-col (functionp end-col))
+	(setq end-col (funcall end-col))
+      (if (and end-col (setq end-col (match-string-no-properties end-col)))
+	  (setq end-col (- (string-to-number end-col) compilation-first-column -1))
+	(if end-line (setq end-col -1))))
     (if (consp type)			; not a static type, check what it is.
 	(setq type (or (and (car type) (match-end (car type)) 1)
 		       (and (cdr type) (match-end (cdr type)) 0)
@@ -726,10 +731,10 @@
 	      ,@(when end-line
 		  `((,end-line compilation-line-face nil t)))
 
-	      ,@(when col
-		  `((,col compilation-column-face nil t)))
-	      ,@(when end-col
-		  `((,end-col compilation-column-face nil t)))
+	      ,@(when (integerp col)
+ 		  `((,col compilation-column-face nil t)))
+	      ,@(when (integerp end-col)
+ 		  `((,end-col compilation-column-face nil t)))
 
 	      ,@(nthcdr 6 item)
 	      (,(or (nth 5 item) 0)
@@ -1535,9 +1540,7 @@
   (unless (eq (goto-char mk) (point))
     (widen)
     (goto-char mk))
-  (if end-mk
-      (push-mark end-mk nil t)
-    (if mark-active (setq mark-active)))
+  (if mark-active (setq mark-active))
   ;; If hideshow got in the way of
   ;; seeing the right place, open permanently.
   (dolist (ov (overlays-at (point)))
@@ -1557,17 +1560,16 @@
 			     compilation-highlight-regexp)))
     (compilation-set-window-height w)
 
-    (when (and highlight-regexp
-	       (not (and end-mk transient-mark-mode)))
+    (when highlight-regexp
       (unless compilation-highlight-overlay
 	(setq compilation-highlight-overlay
 	      (make-overlay (point-min) (point-min)))
 	(overlay-put compilation-highlight-overlay 'face 'region))
       (with-current-buffer (marker-buffer mk)
 	(save-excursion
-	  (end-of-line)
+	  (if end-mk (goto-char end-mk) (end-of-line))
 	  (let ((end (point)))
-	    (beginning-of-line)
+	    (if mk (goto-char mk) (beginning-of-line))
 	    (if (and (stringp highlight-regexp)
 		     (re-search-forward highlight-regexp end t))
 		(progn
--- /home/pfeiffer/.emacs.d/cvs/lisp/progmodes/grep.el.~1.16.~	2004-06-24 01:07:08.000000000 +0200
+++ grep.el (buffer)	2004-07-02 23:49:17.042372000 +0200
@@ -64,6 +64,21 @@
   :version "21.4"
   :group 'grep)
 
+(defcustom grep-highlight-matches t
+  "*Non-nil to use grep markers to highlight matching strings.
+
+Some grep programs are able to surround matching strings with
+special markers in grep output.  Such markers can be used to
+highlight matching strings in grep mode.
+
+This option sets the environment variable GREP_COLOR to specify
+markers for highlighting and GREP_OPTIONS to place the --color
+option in front of any explicit grep options before starting
+the grep."
+  :type 'boolean
+  :version "21.4"
+  :group 'grep)
+
 (defcustom grep-scroll-output nil
   "*Non-nil to scroll the *grep* buffer window as output appears.
 
@@ -227,6 +242,21 @@
   '(("^\\(.+?\\)[:( \t]+\
 \\([0-9]+\\)\\([.:]?\\)\\([0-9]+\\)?\
 \\(?:-\\(?:\\([0-9]+\\)\\3\\)?\\.?\\([0-9]+\\)?\\)?[:) \t]" 1 (2 . 5) (4 . 6))
+    ("^\\(.+?\\)[:(]+\\([0-9]+\\)\\([:)]\\).*?\\(\033\\[01;41m\\)\\(.*?\\)\\(\033\\[00m\\)"
+     1 2
+     ((lambda () (- (match-beginning 5) (match-end 3) 8))
+      .
+      (lambda () (- (match-end 5) (match-end 3) 8)))
+     nil nil
+     (4 '(face nil invisible t intangible t))
+     (5 grep-match-face)
+     (6 '(face nil invisible t intangible t))
+     ;; highlight other matches on the same line
+     ("\\(\033\\[01;41m\\)\\(.*?\\)\\(\033\\[00m\\)"
+      nil nil
+      (1 '(face nil invisible t intangible t))
+      (2 grep-match-face t)
+      (3 '(face nil invisible t intangible t))))
     ("^Binary file \\(.+\\) matches$" 1 nil nil 1))
   "Regexp used to match grep hits.  See `compilation-error-regexp-alist'.")
 
@@ -241,6 +271,9 @@
 (defvar grep-error-face	compilation-error-face
   "Face name to use for grep error messages.")
 
+(defvar grep-match-face	'isearch-lazy-highlight-face
+  "Face name to use for grep matches with GNU grep.")
+
 (defvar grep-mode-font-lock-keywords
    '(;; Command output lines.
      ("^\\([A-Za-z_0-9/\.+-]+\\)[ \t]*:" 1 font-lock-function-name-face)
@@ -291,6 +324,10 @@
 (defun grep-process-setup ()
   "Setup compilation variables and buffer for `grep'.
 Set up `compilation-exit-message-function' and run `grep-setup-hook'."
+  (when grep-highlight-matches
+    ;; Modify `process-environment' locally bound in `compilation-start'
+    (setenv "GREP_OPTIONS" (concat (getenv "GREP_OPTIONS") " --color=always"))
+    (setenv "GREP_COLOR" "01;41"))
   (set (make-local-variable 'compilation-exit-message-function)
        (lambda (status code msg)
 	 (if (eq status 'exit)

[-- 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:[~2004-07-02 21:58 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <E1BdGt8-0003Tg-Qb@lists.gnu.org>
2004-06-24 23:16 ` Changes to emacs/lisp/progmodes/grep.el Juri Linkov
2004-06-25 20:03   ` Daniel Pfeiffer
2004-06-26  0:03     ` Juri Linkov
2004-06-27 10:43       ` Daniel Pfeiffer
2004-06-26  6:03     ` Richard Stallman
2004-06-27 10:33       ` Daniel Pfeiffer
2004-06-27 11:58         ` Adrian Aichner
2004-06-28  2:23         ` Richard Stallman
2004-06-28  2:37           ` Miles Bader
2004-06-28  4:44           ` David Kastrup
2004-06-28  8:40             ` Daniel Pfeiffer
2004-06-28 18:00               ` Eli Zaretskii
2004-06-28 21:22                 ` Daniel Pfeiffer
2004-06-29  5:10                   ` Eli Zaretskii
2004-06-29 20:08                     ` Daniel Pfeiffer
2004-06-29 21:19                       ` Eli Zaretskii
2004-06-30  5:16                         ` Juri Linkov
2004-07-01 22:20                         ` Daniel Pfeiffer
2004-06-30  5:08                       ` Juri Linkov
2004-07-02 21:58                         ` Daniel Pfeiffer [this message]
2004-07-01 23:31                           ` Stefan
2004-07-01 23:38                             ` David Kastrup
2004-07-01 23:46                               ` Stefan
2004-07-03 18:20                               ` Richard Stallman
2004-07-04 10:47                                 ` Mark handling (Was: Changes to emacs/lisp/progmodes/grep.el) Daniel Pfeiffer
2004-07-05 16:56                                   ` Richard Stallman
2004-07-05 19:57                                     ` Daniel Pfeiffer
2004-07-06 22:00                                       ` Richard Stallman
2004-07-07 19:47                                         ` Daniel Pfeiffer
2004-07-08 23:18                                           ` Richard Stallman
2004-07-10 19:54                                             ` Daniel Pfeiffer
2004-07-06 22:00                                       ` Richard Stallman
2004-07-07 20:58                                         ` Richard Stallman
2004-07-02  0:20                             ` Transient mark mode (was: " Paul Pogonyshev
2004-07-03  8:28                             ` Changes to emacs/lisp/progmodes/grep.el Daniel Pfeiffer
2004-07-02  9:07                               ` Juri Linkov
2004-07-03 11:35                                 ` Daniel Pfeiffer
2004-07-02  8:48                           ` Juri Linkov
2004-07-06 16:55                         ` Juri Linkov
2004-07-06 18:16                           ` Luc Teirlinck
2004-07-07 20:57                           ` Richard Stallman
2004-06-30 18:52                       ` Richard Stallman
2004-07-01  5:08                         ` Juri Linkov

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=20040702235848.255ecbbe@pfdabpc.inhouse.start.de \
    --to=dapfy@t-online.de \
    --cc=emacs-devel@gnu.org \
    --cc=occitan@esperanto.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).