From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Dima Kogan Newsgroups: gmane.emacs.bugs 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 Message-ID: <878stiwiuw.fsf@secretsauce.net> References: <87sil4uhlw.fsf@secretsauce.net> <87a7e55l3b.fsf@shorty.i-did-not-set--mail-host-address--so-tickle-me> <87d0ixaawv.fsf@mail.linkov.net> <87blyfvtdb.fsf@secretsauce.net> <87o92epvs0.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="5456"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: mu4e 1.0; emacs 27.0.50 Cc: 18241@debbugs.gnu.org, Lars Ingebrigtsen To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Jul 01 05:11:15 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hhmin-0001IM-Sh for geb-bug-gnu-emacs@m.gmane.org; Mon, 01 Jul 2019 05:11:15 +0200 Original-Received: from localhost ([::1]:47372 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hhmil-0007A3-RC for geb-bug-gnu-emacs@m.gmane.org; Sun, 30 Jun 2019 23:11:11 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46817) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hhmif-00079l-UD for bug-gnu-emacs@gnu.org; Sun, 30 Jun 2019 23:11:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hhmie-0005Hm-He for bug-gnu-emacs@gnu.org; Sun, 30 Jun 2019 23:11:05 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:33991) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hhmie-0005HR-7O for bug-gnu-emacs@gnu.org; Sun, 30 Jun 2019 23:11:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hhmid-0002HV-RB for bug-gnu-emacs@gnu.org; Sun, 30 Jun 2019 23:11:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Dima Kogan Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 01 Jul 2019 03:11:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 18241 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 18241-submit@debbugs.gnu.org id=B18241.15619506148709 (code B ref 18241); Mon, 01 Jul 2019 03:11:03 +0000 Original-Received: (at 18241) by debbugs.gnu.org; 1 Jul 2019 03:10:14 +0000 Original-Received: from localhost ([127.0.0.1]:47535 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hhmhq-0002GO-9g for submit@debbugs.gnu.org; Sun, 30 Jun 2019 23:10:14 -0400 Original-Received: from wout4-smtp.messagingengine.com ([64.147.123.20]:55725) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hhmhm-0002G7-R7 for 18241@debbugs.gnu.org; Sun, 30 Jun 2019 23:10:11 -0400 Original-Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id BC30D32B; Sun, 30 Jun 2019 23:10:04 -0400 (EDT) Original-Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Sun, 30 Jun 2019 23:10:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=secretsauce.net; h=references:from:to:cc:subject:in-reply-to:date:message-id :mime-version:content-type; s=fm3; bh=EHVSrZOlIbv1fz02gxWdcKuh9E FHURjyBtJh4yNX+Dw=; b=t2Cj5sj7+YnGqLke+qW+gnr4MDKHlZ4IyIfc5dGBQf ncALvLXBtp9fmPTG8Na1XN/6WXkg/10KQ+T8vToF+8dhuTiCpCghgdl0mokksc+X b7+rjWqGqyTqvn4tSFWzsYEy9QWl666gsZ/JKjKWqeSU2S+hcTwT3P/0QUiZu9y2 3V5lyNbajPkxOF/KJiuOsOIIMchdKuGsl789YBUF2WwXH4+lrtjTCOdZdxkYf5ZV hTOQVVY9o+0Inm/Sl/eU8oAdUh8JJjDLXt2Fb23ouAaPwNfX6l8bGtkJ9yTDcp0E 6ZEOeJAydn8s/YmJf0fHCk2ub4rdXskgTTt6mplrdd9w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=EHVSrZ OlIbv1fz02gxWdcKuh9EFHURjyBtJh4yNX+Dw=; b=Ty85K+F5LtOJdMN463+G5o IZVtyc4ykgpGjzO0IlGyen21BS/ms+Veb4XELOcJQViA67cF7rAael/8TRNcq/En xtw0mrRBKLeEYp2jKK/CyQruBwP2A7yddDFgZ1LNBLCGUn/Opfe+qF9HzyhtXA/y XA9bZWsIIv4XNbqqnYcUAzalvmQYry9pAtlVxy340RZxAwwv7Ay3FIsWmAhvji1A QjPaDcLPeTg8OAQBLaHLV9J6i29cbHISlsACvcJjKHRYGzsFoWrNc9HjfijrxwJo jTaxIckHHNxOK2iO0OxnBS1Bsw7e8NwnvEzvFxEMU6aYbfESszui73+czk9HRfOw == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduvddrvdehgdeijecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpehffgfhvffujgffkfggtgesmhdtreertdertdenucfhrhhomhepffhimhgrucfm ohhgrghnuceoughimhgrsehsvggtrhgvthhsrghutggvrdhnvghtqeenucfkphepuddtje drvddutddrvddufedrvdegfeenucfrrghrrghmpehmrghilhhfrhhomhepughimhgrsehs vggtrhgvthhsrghutggvrdhnvghtnecuvehluhhsthgvrhfuihiivgeptd X-ME-Proxy: Original-Received: from scrawny (107-210-213-243.lightspeed.irvnca.sbcglobal.net [107.210.213.243]) by mail.messagingengine.com (Postfix) with ESMTPA id B8761380085; Sun, 30 Jun 2019 23:10:02 -0400 (EDT) Original-Received: from dima by scrawny with local (Exim 4.91) (envelope-from ) id 1hhmhb-0000vV-E9; Sun, 30 Jun 2019 20:09:59 -0700 In-reply-to: <87o92epvs0.fsf@mail.linkov.net> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:161922 Archived-At: --=-=-= Content-Type: text/plain Juri Linkov 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 --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Add-ability-to-highlight-lines-matching-regexp-direc.patch >From 7a7f3c50fee9953ff57ed8010d626f7637008d45 Mon Sep 17 00:00:00 2001 From: Dima Kogan 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)) + (defun isearch-delete-char () "Undo last input item during a search. -- 2.20.0.rc2 --=-=-=--