GNU bug report logs - #18241
24.4.50; [PATCH] I can now highlight-lines-matching-regexp from isearch

Previous Next

Package: emacs;

Reported by: Dima Kogan <dima <at> secretsauce.net>

Date: Sun, 10 Aug 2014 22:05:01 UTC

Severity: wishlist

Tags: patch

Found in version 24.4.50

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Dima Kogan <dima <at> secretsauce.net>
Subject: bug#18241: closed (Re: bug#18241: 24.4.50; [PATCH] I can now
 highlight-lines-matching-regexp from isearch)
Date: Sat, 13 Jul 2019 07:23:02 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#18241: 24.4.50; [PATCH] I can now highlight-lines-matching-regexp from isearch

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 18241 <at> debbugs.gnu.org.

-- 
18241: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=18241
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Eli Zaretskii <eliz <at> gnu.org>
To: Dima Kogan <dima <at> secretsauce.net>
Cc: larsi <at> gnus.org, 18241-done <at> debbugs.gnu.org, juri <at> linkov.net
Subject: Re: bug#18241: 24.4.50;
 [PATCH] I can now highlight-lines-matching-regexp from isearch
Date: Sat, 13 Jul 2019 10:22:07 +0300
> From: Dima Kogan <dima <at> secretsauce.net>
> Cc: juri <at> linkov.net, 18241 <at> debbugs.gnu.org, larsi <at> gnus.org
> Date: Wed, 03 Jul 2019 18:31:08 -0700
> 
> Try the attached

Thanks, I pushed it to master.  Please note that there were a few
minor nits left that I fixed, see my followup commit.

[Message part 3 (message/rfc822, inline)]
From: Dima Kogan <dima <at> secretsauce.net>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.4.50;
 [PATCH] I can now highlight-lines-matching-regexp from isearch
Date: Sun, 10 Aug 2014 15:04:11 -0700
[Message part 4 (text/plain, inline)]
Hi.

Before this patch it was possible to 'M-s h r' during an isearch to
highlight the regexp being sought. This patch adds similar functionality
for matching lines with 'M-s h l'. This patch moves the previous 'M-s h
r' isearch functionality into a macro, and then calls this macro
separately for the regex and line cases.


[0001-I-can-now-highlight-lines-matching-regexp-from-isear.patch (text/x-diff, inline)]
From ca3b5261d034b21467f781d7aa2620d0050fea37 Mon Sep 17 00:00:00 2001
From: Dima Kogan <dima <at> secretsauce.net>
Date: Sun, 10 Aug 2014 14:57:56 -0700
Subject: [PATCH] I can now highlight-lines-matching-regexp from isearch

Before this patch it was possible to 'M-s h r' during an isearch to highlight
the regexp being sought. This patch adds similar functionality for matching
lines
---
 lisp/isearch.el | 79 ++++++++++++++++++++++++++++++++++++---------------------
 1 file changed, 50 insertions(+), 29 deletions(-)

diff --git a/lisp/isearch.el b/lisp/isearch.el
index 20dabdc..710890c 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -524,6 +524,7 @@ This is like `describe-bindings', but displays only Isearch keys."
     (define-key map [?\C-\M-%] 'isearch-query-replace-regexp)
     (define-key map "\M-so" 'isearch-occur)
     (define-key map "\M-shr" 'isearch-highlight-regexp)
+    (define-key map "\M-shl" 'isearch-highlight-lines-matching-regexp)
 
     ;; The key translations defined in the C-x 8 prefix should add
     ;; characters to the search string.  See iso-transl.el.
@@ -732,6 +733,8 @@ Type \\[isearch-occur] to run `occur' that shows\
  the last search string.
 Type \\[isearch-highlight-regexp] to run `highlight-regexp'\
  that highlights the last search string.
+Type \\[isearch-highlight-lines-matching-regexp] to run `highlight-lines-matching-regexp'\
+ that highlights lines matching the last search string.
 
 Type \\[isearch-describe-bindings] to display all Isearch key bindings.
 Type \\[isearch-describe-key] to display documentation of Isearch key.
@@ -1804,42 +1807,60 @@ characters in that string."
 
 (declare-function hi-lock-read-face-name "hi-lock" ())
 
+
+(defmacro isearch--hi-lock (hi-lock-form)
+  "Backend for isearch-highlight-*. Does all the setup work, and
+evaluates the given `hi-lock-form' to actually invoke the
+highlighting function"
+  `(progn
+     (let (
+           ;; Set `isearch-recursive-edit' to nil to prevent calling
+           ;; `exit-recursive-edit' in `isearch-done' that terminates
+           ;; the execution of this command when it is non-nil.
+           ;; We call `exit-recursive-edit' explicitly at the end below.
+           (isearch-recursive-edit nil))
+       (isearch-done nil t)
+       (isearch-clean-overlays))
+     (let ((regexp (cond ((functionp isearch-word)
+                          (funcall isearch-word isearch-string))
+                         (isearch-word (word-search-regexp isearch-string))
+                         (isearch-regexp isearch-string)
+                         ((if (and (eq isearch-case-fold-search t)
+                                   search-upper-case)
+                              (isearch-no-upper-case-p
+                               isearch-string isearch-regexp)
+                            isearch-case-fold-search)
+                          ;; Turn isearch-string into a case-insensitive
+                          ;; regexp.
+                          (mapconcat
+                           (lambda (c)
+                             (let ((s (string c)))
+                               (if (string-match "[[:alpha:]]" s)
+                                   (format "[%s%s]" (upcase s) (downcase s))
+                                 (regexp-quote s))))
+                           isearch-string ""))
+                         (t (regexp-quote isearch-string)))))
+       (eval ,hi-lock-form))
+     (and isearch-recursive-edit (exit-recursive-edit))))
+
 (defun isearch-highlight-regexp ()
   "Run `highlight-regexp' with regexp from the current search string.
 It exits Isearch mode and calls `hi-lock-face-buffer' with its regexp
 argument from the last search regexp or a quoted search string,
 and reads its face argument using `hi-lock-read-face-name'."
   (interactive)
-  (let (
-	;; Set `isearch-recursive-edit' to nil to prevent calling
-	;; `exit-recursive-edit' in `isearch-done' that terminates
-	;; the execution of this command when it is non-nil.
-	;; We call `exit-recursive-edit' explicitly at the end below.
-	(isearch-recursive-edit nil))
-    (isearch-done nil t)
-    (isearch-clean-overlays))
   (require 'hi-lock nil t)
-  (let ((regexp (cond ((functionp isearch-word)
-		       (funcall isearch-word isearch-string))
-		      (isearch-word (word-search-regexp isearch-string))
-		      (isearch-regexp isearch-string)
-		      ((if (and (eq isearch-case-fold-search t)
-				search-upper-case)
-			   (isearch-no-upper-case-p
-			    isearch-string isearch-regexp)
-			 isearch-case-fold-search)
-		       ;; Turn isearch-string into a case-insensitive
-		       ;; regexp.
-		       (mapconcat
-			(lambda (c)
-			  (let ((s (string c)))
-			    (if (string-match "[[:alpha:]]" s)
-				(format "[%s%s]" (upcase s) (downcase s))
-			      (regexp-quote s))))
-			isearch-string ""))
-		      (t (regexp-quote isearch-string)))))
-    (hi-lock-face-buffer regexp (hi-lock-read-face-name)))
-  (and isearch-recursive-edit (exit-recursive-edit)))
+  (isearch--hi-lock (hi-lock-face-buffer regexp (hi-lock-read-face-name))))
+
+(defun isearch-highlight-lines-matching-regexp ()
+  "Run `highlight-lines-matching-regexp' with regexp from the
+current search string.  It exits Isearch mode and calls
+`hi-lock-face-buffer' with its regexp argument from the last
+search regexp or a quoted search string, and reads its face
+argument using `hi-lock-read-face-name'."
+  (interactive)
+  (require 'hi-lock nil t)
+  (isearch--hi-lock (hi-lock-line-face-buffer regexp (hi-lock-read-face-name))))
 
 
 (defun isearch-delete-char ()
-- 
2.0.0


This bug report was last modified 5 years and 318 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.