all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Dima Kogan <dima@secretsauce.net>
To: Juri Linkov <juri@linkov.net>
Cc: 18241@debbugs.gnu.org, Lars Ingebrigtsen <larsi@gnus.org>
Subject: bug#18241: 24.4.50; [PATCH] I can now highlight-lines-matching-regexp from isearch
Date: Sun, 30 Jun 2019 20:09:59 -0700	[thread overview]
Message-ID: <878stiwiuw.fsf@secretsauce.net> (raw)
In-Reply-To: <87o92epvs0.fsf@mail.linkov.net>

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

Juri Linkov <juri@linkov.net> writes:

> Maybe it's possible to make the text shorter by just adding a new sentence
> about 'M-s h l' to the middle of the paragraph that describes 'M-s h r'?
>
>> -(defun isearch-highlight-regexp ()
>> +(defun isearch--highlight-regexp-or-lines-internal (hi-lock-func)
>
> The suffix '-internal' is not necessary here because the double dash
> in 'isearch--' implies that the function is internal.

Alright. Here's a new patch


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Add-ability-to-highlight-lines-matching-regexp-direc.patch --]
[-- Type: text/x-diff, Size: 5571 bytes --]

From 7a7f3c50fee9953ff57ed8010d626f7637008d45 Mon Sep 17 00:00:00 2001
From: Dima Kogan <dima@secretsauce.net>
Date: Sun, 30 Jun 2019 10:37:53 -0700
Subject: [PATCH] Add ability to highlight-lines-matching-regexp directly from
 isearch

* lisp/isearch.el: Implement the new functionality.
(isearch-highlight-lines-matching-regexp): New function bound to M-s h l in
isearch.
(isearch--highlight-regexp-or-lines): New internal function

* etc/NEWS (Search and Replace): Mention this change.

* doc/emacs/search.texi: Added this binding to the documentation
---
 doc/emacs/search.texi | 18 +++++++++++-------
 etc/NEWS              |  3 +++
 lisp/isearch.el       | 26 +++++++++++++++++++++++---
 3 files changed, 37 insertions(+), 10 deletions(-)

diff --git a/doc/emacs/search.texi b/doc/emacs/search.texi
index c61578bab76..571705b916f 100644
--- a/doc/emacs/search.texi
+++ b/doc/emacs/search.texi
@@ -453,13 +453,17 @@ Special Isearch
 
 @kindex M-s h r @r{(Incremental Search)}
 @findex isearch-highlight-regexp
-  You can exit the search while leaving the matches for the last
-search string highlighted on display.  To this end, type @kbd{M-s h r}
-(@code{isearch-highlight-regexp}), which will run
-@code{highlight-regexp} (@pxref{Highlight Interactively}) passing
-it the regexp derived from the last search string and prompting you
-for the face to use for highlighting.  To remove the highlighting,
-type @kbd{M-s h u} (@code{unhighlight-regexp}).
+@kindex M-s h l @r{(Incremental Search)}
+@findex isearch-highlight-lines-matching-regexp
+  You can exit the search while leaving matches for the last search
+string highlighted by typing @kbd{M-s h r}
+(@code{isearch-highlight-regexp}).  This runs @code{highlight-regexp}
+(@pxref{Highlight Interactively}), passing it the regexp derived from
+the last search string and prompting you for the face to use for
+highlighting.  Similarly, you can highlight whole lines containing
+matches by typing @kbd{M-s h l}
+(@code{isearch-highlight-lines-matching-regexp}).  To remove the
+highlighting, type @kbd{M-s h u} (@code{unhighlight-regexp}).
 
 @cindex incremental search, help on special keys
 @kindex C-h C-h @r{(Incremental Search)}
diff --git a/etc/NEWS b/etc/NEWS
index abbece374a4..72b30373587 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1111,6 +1111,9 @@ highlight in one iteration while processing the full buffer.
 'isearch-yank-symbol-or-char'.  'isearch-del-char' is now bound to
 'C-M-d'.
 
+'M-s h l' invokes highlight-lines-matching-regexp directly using the
+search string, similar to what 'M-s h r' was doing already.
+
 +++
 *** New variable 'isearch-yank-on-move' provides options 't' and 'shift'
 to extend the search string by yanking text that ends at the new
diff --git a/lisp/isearch.el b/lisp/isearch.el
index f150a3bba4b..888e83d15a1 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -753,6 +753,7 @@ isearch-mode-map
     (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.
@@ -1039,6 +1040,9 @@ isearch-forward
  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.
@@ -2339,12 +2343,11 @@ isearch-occur
 
 (declare-function hi-lock-read-face-name "hi-lock" ())
 
-(defun isearch-highlight-regexp ()
+(defun isearch--highlight-regexp-or-lines (hi-lock-func)
   "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
@@ -2373,9 +2376,26 @@ isearch-highlight-regexp
 			      (regexp-quote s))))
 			isearch-string ""))
 		      (t (regexp-quote isearch-string)))))
-    (hi-lock-face-buffer regexp (hi-lock-read-face-name)))
+    (funcall hi-lock-func regexp (hi-lock-read-face-name)))
   (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)
+  (isearch--highlight-regexp-or-lines 'hi-lock-face-buffer))
+
+(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)
+  (isearch--highlight-regexp-or-lines 'hi-lock-line-face-buffer))
+
 \f
 (defun isearch-delete-char ()
   "Undo last input item during a search.
-- 
2.20.0.rc2


  reply	other threads:[~2019-07-01  3:09 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-10 22:04 bug#18241: 24.4.50; [PATCH] I can now highlight-lines-matching-regexp from isearch Dima Kogan
2019-06-25 22:32 ` Lars Ingebrigtsen
2019-06-25 22:58   ` Dima Kogan
2019-06-26 13:49     ` Lars Ingebrigtsen
2019-06-28 19:12       ` Juri Linkov
2019-06-30 18:08         ` Dima Kogan
2019-06-30 21:12           ` Juri Linkov
2019-07-01  3:09             ` Dima Kogan [this message]
2019-07-01 14:08               ` Eli Zaretskii
2019-07-04  1:31                 ` Dima Kogan
2019-07-13  7:22                   ` Eli Zaretskii

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=878stiwiuw.fsf@secretsauce.net \
    --to=dima@secretsauce.net \
    --cc=18241@debbugs.gnu.org \
    --cc=juri@linkov.net \
    --cc=larsi@gnus.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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.