unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [NonGNU] New package: ctrlf and Questions
@ 2022-02-23  8:04 Jai Flack
  0 siblings, 0 replies; 23+ messages in thread
From: Jai Flack @ 2022-02-23  8:04 UTC (permalink / raw)
  To: emacs-devel

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: 0001-elpa-packages-ctrlf-New-package.patch --]
[-- Type: text/x-diff, Size: 760 bytes --]

From 6ed94e13b3536ad6adc14c8be62971a004a64bdd Mon Sep 17 00:00:00 2001
From: Jai Flack <jflack@disroot.org>
Date: Wed, 23 Feb 2022 12:53:28 +1000
Subject: [PATCH] * elpa-packages (ctrlf): New package

---
 elpa-packages | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/elpa-packages b/elpa-packages
index fc0a508ae9..520e553dbb 100644
--- a/elpa-packages
+++ b/elpa-packages
@@ -81,6 +81,11 @@
   :readme "README.md"
   :news "CHANGELOG.md")
 
+ ("ctrlf"		:url "https://github.com/raxod502/ctrlf"
+  :readme "README.md"
+  :news "CHANGELOG.md"
+  :ignored-files ("scripts" "Dockerfile" "Makefile"))
+
  ("cyberpunk-theme"	:url "https://github.com/n3mo/cyberpunk-theme.el"
   :ignored-files ("cyberpunk-theme.png" "example-org-file.org"))
 
-- 
2.30.2


[-- Attachment #2: Type: text/plain, Size: 437 bytes --]

Greetings emacs-devel.

Apologies if these questions have been answered before.

I would like to submit a package `ctrlf' [1] for NonGNU ELPA (patch
attached). Previously I completed the copyright assignment for Emacs, is
a different assignment required for this?

Also I have many more packages to submit; is it preferable for me to
bulk-attach these patches into a single email?

[1] https://github.com/raxod502/ctrlf

-- 
Thanks,
Jai

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [NonGNU] New package: ctrlf and Questions
@ 2022-02-23 11:56 jflack
  2022-02-23 18:33 ` Augusto Stoffel
  0 siblings, 1 reply; 23+ messages in thread
From: jflack @ 2022-02-23 11:56 UTC (permalink / raw)
  To: emacs-devel

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

Greetings emacs-devel.

Apologies if these questions have been answered before.

I would like to submit a package `ctrlf' [1] for NonGNU ELPA (patch
attached). Previously I completed the copyright assignment for Emacs, is
a different assignment required for this?

Also I have many more packages to submit; is it preferable for me to
bulk-attach these patches into a single email?

[1] https://github.com/raxod502/ctrlf

-- 
Thanks,
Jai

[-- Attachment #2: 0001-elpa-packages-ctrlf-New-package.patch --]
[-- Type: application/octet-stream, Size: 760 bytes --]

From 6ed94e13b3536ad6adc14c8be62971a004a64bdd Mon Sep 17 00:00:00 2001
From: Jai Flack <jflack@disroot.org>
Date: Wed, 23 Feb 2022 12:53:28 +1000
Subject: [PATCH] * elpa-packages (ctrlf): New package

---
 elpa-packages | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/elpa-packages b/elpa-packages
index fc0a508ae9..520e553dbb 100644
--- a/elpa-packages
+++ b/elpa-packages
@@ -81,6 +81,11 @@
   :readme "README.md"
   :news "CHANGELOG.md")
 
+ ("ctrlf"		:url "https://github.com/raxod502/ctrlf"
+  :readme "README.md"
+  :news "CHANGELOG.md"
+  :ignored-files ("scripts" "Dockerfile" "Makefile"))
+
  ("cyberpunk-theme"	:url "https://github.com/n3mo/cyberpunk-theme.el"
   :ignored-files ("cyberpunk-theme.png" "example-org-file.org"))
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* Re: [NonGNU] New package: ctrlf and Questions
  2022-02-23 11:56 [NonGNU] New package: ctrlf and Questions jflack
@ 2022-02-23 18:33 ` Augusto Stoffel
  2022-02-23 19:40   ` Philip Kaludercic
  0 siblings, 1 reply; 23+ messages in thread
From: Augusto Stoffel @ 2022-02-23 18:33 UTC (permalink / raw)
  To: jflack; +Cc: emacs-devel

FWIW, a similar package already exists on ELPA:

    https://elpa.gnu.org/packages/isearch-mb.html

The main difference to Ctrlf being that isearch-mb integrates with
isearch instead of reinventing it (and therefore is much smaller than
Ctrlf).

On Wed, 23 Feb 2022 at 11:56, jflack@disroot.org wrote:

> Greetings emacs-devel.
>
> Apologies if these questions have been answered before.
>
> I would like to submit a package `ctrlf' [1] for NonGNU ELPA (patch
> attached). Previously I completed the copyright assignment for Emacs, is
> a different assignment required for this?
>
> Also I have many more packages to submit; is it preferable for me to
> bulk-attach these patches into a single email?
>
> [1] https://github.com/raxod502/ctrlf



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [NonGNU] New package: ctrlf and Questions
  2022-02-23 18:33 ` Augusto Stoffel
@ 2022-02-23 19:40   ` Philip Kaludercic
  2022-02-23 20:59     ` Augusto Stoffel
  0 siblings, 1 reply; 23+ messages in thread
From: Philip Kaludercic @ 2022-02-23 19:40 UTC (permalink / raw)
  To: Augusto Stoffel; +Cc: jflack, emacs-devel

Augusto Stoffel <arstoffel@gmail.com> writes:

> FWIW, a similar package already exists on ELPA:
>
>     https://elpa.gnu.org/packages/isearch-mb.html
>
> The main difference to Ctrlf being that isearch-mb integrates with
> isearch instead of reinventing it (and therefore is much smaller than
> Ctrlf).

Is there any advantage that Ctrlf has over isearch-mb?  If not, I don't
see why the more complex package is needed at all?

> On Wed, 23 Feb 2022 at 11:56, jflack@disroot.org wrote:
>
>> Greetings emacs-devel.
>>
>> Apologies if these questions have been answered before.
>>
>> I would like to submit a package `ctrlf' [1] for NonGNU ELPA (patch
>> attached). Previously I completed the copyright assignment for Emacs, is
>> a different assignment required for this?
>>
>> Also I have many more packages to submit; is it preferable for me to
>> bulk-attach these patches into a single email?
>>
>> [1] https://github.com/raxod502/ctrlf
>
>

-- 
	Philip Kaludercic



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [NonGNU] New package: ctrlf and Questions
  2022-02-23 19:40   ` Philip Kaludercic
@ 2022-02-23 20:59     ` Augusto Stoffel
  2022-02-24 10:36       ` Jai Flack
  0 siblings, 1 reply; 23+ messages in thread
From: Augusto Stoffel @ 2022-02-23 20:59 UTC (permalink / raw)
  To: Philip Kaludercic; +Cc: jflack, emacs-devel

On Wed, 23 Feb 2022 at 19:40, Philip Kaludercic <philipk@posteo.net> wrote:

> Augusto Stoffel <arstoffel@gmail.com> writes:
>
>> FWIW, a similar package already exists on ELPA:
>>
>>     https://elpa.gnu.org/packages/isearch-mb.html
>>
>> The main difference to Ctrlf being that isearch-mb integrates with
>> isearch instead of reinventing it (and therefore is much smaller than
>> Ctrlf).
>
> Is there any advantage that Ctrlf has over isearch-mb?  If not, I don't
> see why the more complex package is needed at all?

I'm not aware of any advantages (otherwise I could extend isearch-mb or,
more likely, isearch itself).  OTOH there is nothing wrong with
providing (a sensible number of) alternative implementations of the same
idea; in fact, isearch-mb was inspired by Ctrlf.  So I don't have a
strong opinion about this.

>
>> On Wed, 23 Feb 2022 at 11:56, jflack@disroot.org wrote:
>>
>>> Greetings emacs-devel.
>>>
>>> Apologies if these questions have been answered before.
>>>
>>> I would like to submit a package `ctrlf' [1] for NonGNU ELPA (patch
>>> attached). Previously I completed the copyright assignment for Emacs, is
>>> a different assignment required for this?
>>>
>>> Also I have many more packages to submit; is it preferable for me to
>>> bulk-attach these patches into a single email?
>>>
>>> [1] https://github.com/raxod502/ctrlf
>>
>>



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [NonGNU] New package: ctrlf and Questions
  2022-02-23 20:59     ` Augusto Stoffel
@ 2022-02-24 10:36       ` Jai Flack
  2022-02-26 11:02         ` Augusto Stoffel
  0 siblings, 1 reply; 23+ messages in thread
From: Jai Flack @ 2022-02-24 10:36 UTC (permalink / raw)
  To: Augusto Stoffel; +Cc: Philip Kaludercic, emacs-devel

Augusto Stoffel <arstoffel@gmail.com> writes:

> On Wed, 23 Feb 2022 at 19:40, Philip Kaludercic <philipk@posteo.net> wrote:
>
>> Augusto Stoffel <arstoffel@gmail.com> writes:
>>
>>> FWIW, a similar package already exists on ELPA:
>>>
>>>     https://elpa.gnu.org/packages/isearch-mb.html
>>>
>>> The main difference to Ctrlf being that isearch-mb integrates with
>>> isearch instead of reinventing it (and therefore is much smaller than
>>> Ctrlf).

Thanks for pointing me to isearch-mb.

>> Is there any advantage that Ctrlf has over isearch-mb?  If not, I don't
>> see why the more complex package is needed at all?

It's nice how ctrlf presents the count at the end of the matching line
(not just in the minibuffer) but apart from that they seem to have the
same feature set.

> I'm not aware of any advantages (otherwise I could extend isearch-mb or,
> more likely, isearch itself).  OTOH there is nothing wrong with
> providing (a sensible number of) alternative implementations of the same
> idea; in fact, isearch-mb was inspired by Ctrlf.  So I don't have a
> strong opinion about this.

I no longer wish for ctrlf to be added but feel free to add it if
someone else wants it.

-- 
Thanks,
Jai



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [NonGNU] New package: ctrlf and Questions
  2022-02-24 10:36       ` Jai Flack
@ 2022-02-26 11:02         ` Augusto Stoffel
  2022-02-27  4:02           ` Stefan Monnier
  2022-03-05  4:39           ` [NonGNU] New package: ctrlf and Questions Jai Flack
  0 siblings, 2 replies; 23+ messages in thread
From: Augusto Stoffel @ 2022-02-26 11:02 UTC (permalink / raw)
  To: Jai Flack; +Cc: Philip Kaludercic, emacs-devel

On Thu, 24 Feb 2022 at 20:36, Jai Flack <jflack@disroot.org> wrote:

> It's nice how ctrlf presents the count at the end of the matching line
> (not just in the minibuffer) but apart from that they seem to have the
> same feature set.

This feature is unrelated to isearch-mb, which focuses narrowly on how
the search string is read.  It's also probably too eccentric to include
in isearch itself (but I don't know what others actually think).  And it
seems a bit too small to become a package by itself.

I'm not quite sure what then answer is to these considerations.  But let
me mention that there's a wiki on the isearch-mb Github repo that can be
used to share tips and tricks like this one.



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [NonGNU] New package: ctrlf and Questions
  2022-02-26 11:02         ` Augusto Stoffel
@ 2022-02-27  4:02           ` Stefan Monnier
  2022-03-16 11:37             ` Overlay count for isearch (Was: [NonGNU] New package: ctrlf and Questions) Jai Flack
  2022-03-05  4:39           ` [NonGNU] New package: ctrlf and Questions Jai Flack
  1 sibling, 1 reply; 23+ messages in thread
From: Stefan Monnier @ 2022-02-27  4:02 UTC (permalink / raw)
  To: Augusto Stoffel; +Cc: Jai Flack, Philip Kaludercic, emacs-devel

Augusto Stoffel [2022-02-26 12:02:37] wrote:
> On Thu, 24 Feb 2022 at 20:36, Jai Flack <jflack@disroot.org> wrote:
>> It's nice how ctrlf presents the count at the end of the matching line
>> (not just in the minibuffer) but apart from that they seem to have the
>> same feature set.
> This feature is unrelated to isearch-mb, which focuses narrowly on how
> the search string is read.  It's also probably too eccentric to include
> in isearch itself (but I don't know what others actually think).  And it
> seems a bit too small to become a package by itself.

If it's not for everyone, then it should arguably be provided under the
control of the config var, but that doesn't mean it should be in
a separate package or relegated to some ELisp snippets for people to
copy&paste into their init file.

Whether it better belongs alongside `isearch` or `isearch-mb` will
probably depend on details of how it's implemented.


        Stefan




^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [NonGNU] New package: ctrlf and Questions
  2022-02-26 11:02         ` Augusto Stoffel
  2022-02-27  4:02           ` Stefan Monnier
@ 2022-03-05  4:39           ` Jai Flack
  1 sibling, 0 replies; 23+ messages in thread
From: Jai Flack @ 2022-03-05  4:39 UTC (permalink / raw)
  To: Augusto Stoffel; +Cc: Philip Kaludercic, emacs-devel

Augusto Stoffel <arstoffel@gmail.com> writes:

> I'm not quite sure what then answer is to these considerations.  But let
> me mention that there's a wiki on the isearch-mb Github repo that can be
> used to share tips and tricks like this one.

When I have time I'll look at how this could be implemented. If it's
short maybe it could be included as one of those tricks.

-- 
Thanks,
Jai



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Overlay count for isearch (Was: [NonGNU] New package: ctrlf and Questions)
  2022-02-27  4:02           ` Stefan Monnier
@ 2022-03-16 11:37             ` Jai Flack
  2022-03-16 12:00               ` Overlay count for isearch Augusto Stoffel
  0 siblings, 1 reply; 23+ messages in thread
From: Jai Flack @ 2022-03-16 11:37 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Augusto Stoffel, Philip Kaludercic, emacs-devel

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: 0001-New-setting-for-an-in-buffer-display-of-isearch-matc.patch --]
[-- Type: text/x-diff, Size: 10572 bytes --]

From d3a741f1b782b31f0ba62b5b173b84fbfddf677c Mon Sep 17 00:00:00 2001
From: Jai Flack <jflack@disroot.org>
Date: Wed, 16 Mar 2022 20:38:05 +1000
Subject: [PATCH] New setting for an in-buffer display of isearch match numbers

Exposes this behaviour through 'isearch-lazy-count-at-match' and
'isearch-lazy-count-at-match-format'. It relies on
'isearch-lazy-count' and 'isearch-lazy-highlight' behaviour for
counting.

* lisp/isearch.el (isearch-lazy-count-at-match): New variable
(lazy-count-at-match): New face
(isearch-show-lazy-count-at-match-format): New variable
(isearch-done): Call 'isearch-show-lazy-count-at-match-cleanup' when
appropriate
(isearch-message): Call 'isearch-show-lazy-count-at-match' when
appropriate
(isearch-message-prefix): Update call to 'isearch-lazy-count-format'
(isearch-message-suffix): Update call to 'isearch-lazy-count-format'
(isearch-lazy-count-format): Now accepts format strings instead of
SUFFIX-P
(isearch-lazy-count-at-match-overlay): New variable
(isearch-show-lazy-count-at-match): New function
(isearch-show-lazy-count-at-match-cleanup): New function
* doc/emacs/search.texi (Search Customizations): Document the
behaviour
---
 doc/emacs/search.texi |  10 +++
 etc/NEWS              |   7 +++
 lisp/isearch.el       | 138 +++++++++++++++++++++++++++++++-----------
 3 files changed, 119 insertions(+), 36 deletions(-)

diff --git a/doc/emacs/search.texi b/doc/emacs/search.texi
index f2d82324e9..9994e45535 100644
--- a/doc/emacs/search.texi
+++ b/doc/emacs/search.texi
@@ -2128,6 +2128,16 @@ Search Customizations
 @vindex lazy-count-suffix-format
 These two variables determine the format of showing the current and
 the total number of matches for @code{isearch-lazy-count}.
+
+@item isearch-lazy-count-at-match
+@vindex isearch-lazy-count-at-match
+Show the current match number and total number of matches just after
+the currently matched line.
+
+@item lazy-count-at-match-format
+@vindex lazy-count-at-match-format
+Determines the format for showing the current and the total number of
+matches for @code{isearch-lazy-count-at-match}.
 @end table
 
 @vindex search-nonincremental-instead
diff --git a/etc/NEWS b/etc/NEWS
index f4d8756950..292526d272 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -579,6 +579,13 @@ command accepts the Unicode name of an Emoji (for example, "smiling
 face" or "heart with arrow"), like 'C-x 8 e e', with minibuffer
 completion, and adds the Emoji into the search string.
 
++++
+*** New user options 'isearch-lazy-count-at-match'
+When non-nil, shows the current match numbers just after the current
+matches line. Format can be controlled with
+'isearch-lazy-count-at-match-format'. Requires 'isearch-lazy-count'
+and 'isearch-lazy-highlight' to be non-nil in order to work.
+
 ** New minor mode 'glyphless-display-mode'.
 This allows an easy way to toggle seeing all glyphless characters in
 the current buffer.
diff --git a/lisp/isearch.el b/lisp/isearch.el
index 8970216398..8abbc56275 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -362,6 +362,16 @@ isearch-lazy-count
   :group 'isearch
   :version "27.1")
 
+(defcustom isearch-lazy-count-at-match nil
+  "Show match numbers near the current matched search.
+When this option, `isearch-lazy-count' and
+`isearch-lazy-highlight' are non-nil, show the match numbers (see
+`isearch-lazy-count') at the end of the current matches line."
+  :type 'boolean
+  :group 'lazy-count
+  :group 'isearch
+  :version "29.1")
+
 ;;; Lazy highlight customization.
 
 (defgroup lazy-highlight nil
@@ -465,6 +475,23 @@ lazy-count-suffix-format
   :group 'lazy-count
   :version "27.1")
 
+;;; Lazy count at match customization.
+
+(defface lazy-count-at-match
+  '((t (:inherit isearch)))
+  "Face for the lazy count shown at current match."
+  :group 'lazy-count)
+
+(defcustom isearch-lazy-count-at-match-format " %s/%s"
+  "Format of the current/total number of matches for the in-buffer
+display.
+
+See `isearch-lazy-count-at-match'."
+  :type 'boolean
+  :group 'lazy-count
+  :group 'isearch
+  :version "29.1")
+
 \f
 ;; Define isearch help map.
 
@@ -1431,6 +1458,8 @@ isearch-done
   (setq minibuffer-message-timeout isearch-original-minibuffer-message-timeout)
   (isearch-dehighlight)
   (lazy-highlight-cleanup lazy-highlight-cleanup)
+  (when isearch-lazy-count-at-match
+    (isearch-show-lazy-count-at-match-cleanup))
   (setq isearch-lazy-highlight-last-string nil)
   (let ((found-start (window-group-start))
 	(found-point (point)))
@@ -3386,7 +3415,10 @@ isearch-message
 	     (isearch-message-prefix ellipsis isearch-nonincremental)
 	     m
 	     (isearch-message-suffix c-q-hack)))
-    (if c-q-hack m (let ((message-log-max nil)) (message "%s" m)))))
+    (if c-q-hack m (let ((message-log-max nil)) (message "%s" m))))
+  ;; Update the in-buffer count too
+  (when isearch-lazy-count-at-match
+    (isearch-show-lazy-count-at-match)))
 
 (defun isearch--describe-regexp-mode (regexp-function &optional space-before)
   "Make a string for describing REGEXP-FUNCTION.
@@ -3477,41 +3509,39 @@ isearch-message-prefix
 			(concat " [" current-input-method-title "]: "))
 		     ": ")
 		   )))
-    (apply #'propertize (concat (isearch-lazy-count-format)
+    (apply #'propertize (concat (isearch-lazy-count-format lazy-count-prefix-format)
                         (upcase (substring m 0 1)) (substring m 1))
 	   isearch-message-properties)))
 
 (defun isearch-message-suffix (&optional c-q-hack)
   (apply #'propertize (concat (if c-q-hack "^Q" "")
-		      (isearch-lazy-count-format 'suffix)
+		              (isearch-lazy-count-format lazy-count-suffix-format)
 		      (if isearch-error
 			  (concat " [" isearch-error "]")
 			"")
 		      (or isearch-message-suffix-add ""))
 	 isearch-message-properties))
 
-(defun isearch-lazy-count-format (&optional suffix-p)
-  "Format the current match number and the total number of matches.
-When SUFFIX-P is non-nil, the returned string is intended for
-isearch-message-suffix prompt.  Otherwise, for isearch-message-prefix."
-  (let ((format-string (if suffix-p
-                           lazy-count-suffix-format
-                         lazy-count-prefix-format)))
-    (if (and format-string
-             isearch-lazy-count
-             isearch-lazy-count-current
-             (not isearch-error)
-             (not isearch-suspended))
-        (format format-string
-                (if isearch-lazy-highlight-forward
-                    isearch-lazy-count-current
-                  (if (eq isearch-lazy-count-current 0)
-                      0
-                    (- isearch-lazy-count-total
-                       isearch-lazy-count-current
-                       -1)))
-                (or isearch-lazy-count-total "?"))
-      "")))
+(defun isearch-lazy-count-format (format-string)
+  "Format the current match number and the total number of matches
+using FORMAT-STRING. It is given two integer substitutions, the
+first is the current match number and second the total number of
+matches."
+  (if (and format-string
+           isearch-lazy-count
+           isearch-lazy-count-current
+           (not isearch-error)
+           (not isearch-suspended))
+      (format format-string
+              (if isearch-lazy-highlight-forward
+                  isearch-lazy-count-current
+                (if (eq isearch-lazy-count-current 0)
+                    0
+                  (- isearch-lazy-count-total
+                     isearch-lazy-count-current
+                     -1)))
+              (or isearch-lazy-count-total "?"))
+    ""))
 
 \f
 ;; Searching
@@ -3990,6 +4020,7 @@ isearch-lazy-highlight-error
 (defvar isearch-lazy-count-current nil)
 (defvar isearch-lazy-count-total nil)
 (defvar isearch-lazy-count-hash (make-hash-table))
+(defvar isearch-lazy-count-at-match-overlay nil)
 
 (defun lazy-highlight-cleanup (&optional force procrastinate)
   "Stop lazy highlighting and remove extra highlighting from current buffer.
@@ -4325,17 +4356,52 @@ isearch-lazy-highlight-buffer-update
 		;; not found or zero-length match at the search bound
 		(if (not found)
 		    (setq looping nil
-			  nomore  t))))
-	    (if nomore
-		(when (and isearch-lazy-count isearch-mode (null isearch-message-function))
-		  (unless isearch-lazy-count-total
-		    (setq isearch-lazy-count-total 0))
-		  (setq isearch-lazy-count-current
-			(gethash opoint isearch-lazy-count-hash 0))
-		  (isearch-message))
-	      (setq isearch-lazy-highlight-timer
-		    (run-at-time lazy-highlight-interval nil
-				 'isearch-lazy-highlight-buffer-update)))))))))
+			  nomore  t))))))
+	(if nomore
+	    (when (and isearch-lazy-count isearch-mode (null isearch-message-function))
+	      (unless isearch-lazy-count-total
+		(setq isearch-lazy-count-total 0))
+	      (setq isearch-lazy-count-current
+		    (gethash opoint isearch-lazy-count-hash 0))
+	      (isearch-message))
+	  (setq isearch-lazy-highlight-timer
+		(run-at-time lazy-highlight-interval nil
+			     'isearch-lazy-highlight-buffer-update)))))))
+
+(defun isearch-show-lazy-count-at-match ()
+  "Show the match count just after the end of the currently matched
+line."
+  ;; We try to reuse the overlay as much as possible to remove
+  ;; flickering
+  (unless isearch-lazy-count-at-match-overlay
+    (let ((ov (make-overlay 0 0)))
+      (setq isearch-lazy-count-at-match-overlay ov)
+      ;; see isearch-lazy-highlight-match
+      (overlay-put ov 'priority 1001)
+      (overlay-put ov 'face 'lazy-count-at-match)
+      (unless isearch-lazy-highlight-buffer
+        (overlay-put ov 'window (selected-window)))))
+
+  (let ((ov isearch-lazy-count-at-match-overlay)
+        (pae (point-at-eol))
+        (count (propertize (isearch-lazy-count-format
+                            isearch-lazy-count-at-match-format)
+                           'cursor t)))
+    (unless (and (= (overlay-end ov)
+                    pae)
+                 (eq (overlay-buffer ov)
+                     (current-buffer)))
+      (move-overlay ov pae pae (current-buffer)))
+    (unless (string= (overlay-get ov 'after-string)
+                     count)
+      (overlay-put ov 'after-string count))))
+
+(defun isearch-show-lazy-count-at-match-cleanup ()
+  "Remove the search count used by
+\\[isearch-show-lazy-count-at-match]."
+  (when isearch-lazy-count-at-match-overlay
+    (delete-overlay isearch-lazy-count-at-match-overlay)
+    (setq isearch-lazy-count-at-match-overlay nil)))
 
 (defun isearch-resume (string regexp word forward message case-fold)
   "Resume an incremental search.
-- 
2.30.2


[-- Attachment #2: Type: text/plain, Size: 1203 bytes --]

Stefan Monnier <monnier@iro.umontreal.ca> writes:
> If it's not for everyone, then it should arguably be provided under the
> control of the config var, but that doesn't mean it should be in
> a separate package or relegated to some ELisp snippets for people to
> copy&paste into their init file.
>
> Whether it better belongs alongside `isearch` or `isearch-mb` will
> probably depend on details of how it's implemented.

Here's a patch providing just that for isearch. It could be added to
isearch-mb almost just as easily though it has nothing to do with search
entry.

With regards to an isearch-mb wiki "trick": the same result could be
achieved using `isearch-mode-end-hook` and :after advice on
`isearch-message`.

Whether it becomes a part of isearch or not some feedback would be
appreciated (;

1. Is it right to modify `isearch-lazy-count-format` in this way to
reduce code in `isearch-show-lazy-count-at-match`?

2. Is it right to add a new face for this and if so does this need to be
included in NEWS or other documentation?

3. Should it be extended to allow for custom positioning of the overlay?
Perhaps with a variable like `isearch-lazy-count-at-match-pos-function`?

-- 
Thanks,
Jai

^ permalink raw reply related	[flat|nested] 23+ messages in thread

* Re: Overlay count for isearch
  2022-03-16 11:37             ` Overlay count for isearch (Was: [NonGNU] New package: ctrlf and Questions) Jai Flack
@ 2022-03-16 12:00               ` Augusto Stoffel
  2022-03-18  2:45                 ` Jai Flack
  0 siblings, 1 reply; 23+ messages in thread
From: Augusto Stoffel @ 2022-03-16 12:00 UTC (permalink / raw)
  To: Jai Flack; +Cc: Philip Kaludercic, Stefan Monnier, emacs-devel

Hi Jay,

when the patch proposed for bug#53126 is merged, a new
`lazy-count-update-hook' will be available.  I think you can probably
simplify your implementation by using it.

On Wed, 16 Mar 2022 at 21:37, Jai Flack <jflack@disroot.org> wrote:

> From d3a741f1b782b31f0ba62b5b173b84fbfddf677c Mon Sep 17 00:00:00 2001
> From: Jai Flack <jflack@disroot.org>
> Date: Wed, 16 Mar 2022 20:38:05 +1000
> Subject: [PATCH] New setting for an in-buffer display of isearch match numbers
>
> Exposes this behaviour through 'isearch-lazy-count-at-match' and
> 'isearch-lazy-count-at-match-format'. It relies on
> 'isearch-lazy-count' and 'isearch-lazy-highlight' behaviour for
> counting.
>
> * lisp/isearch.el (isearch-lazy-count-at-match): New variable
> (lazy-count-at-match): New face
> (isearch-show-lazy-count-at-match-format): New variable
> (isearch-done): Call 'isearch-show-lazy-count-at-match-cleanup' when
> appropriate
> (isearch-message): Call 'isearch-show-lazy-count-at-match' when
> appropriate
> (isearch-message-prefix): Update call to 'isearch-lazy-count-format'
> (isearch-message-suffix): Update call to 'isearch-lazy-count-format'
> (isearch-lazy-count-format): Now accepts format strings instead of
> SUFFIX-P
> (isearch-lazy-count-at-match-overlay): New variable
> (isearch-show-lazy-count-at-match): New function
> (isearch-show-lazy-count-at-match-cleanup): New function
> * doc/emacs/search.texi (Search Customizations): Document the
> behaviour
> ---
>  doc/emacs/search.texi |  10 +++
>  etc/NEWS              |   7 +++
>  lisp/isearch.el       | 138 +++++++++++++++++++++++++++++++-----------
>  3 files changed, 119 insertions(+), 36 deletions(-)
>
> diff --git a/doc/emacs/search.texi b/doc/emacs/search.texi
> index f2d82324e9..9994e45535 100644
> --- a/doc/emacs/search.texi
> +++ b/doc/emacs/search.texi
> @@ -2128,6 +2128,16 @@ Search Customizations
>  @vindex lazy-count-suffix-format
>  These two variables determine the format of showing the current and
>  the total number of matches for @code{isearch-lazy-count}.
> +
> +@item isearch-lazy-count-at-match
> +@vindex isearch-lazy-count-at-match
> +Show the current match number and total number of matches just after
> +the currently matched line.
> +
> +@item lazy-count-at-match-format
> +@vindex lazy-count-at-match-format
> +Determines the format for showing the current and the total number of
> +matches for @code{isearch-lazy-count-at-match}.
>  @end table
>  
>  @vindex search-nonincremental-instead
> diff --git a/etc/NEWS b/etc/NEWS
> index f4d8756950..292526d272 100644
> --- a/etc/NEWS
> +++ b/etc/NEWS
> @@ -579,6 +579,13 @@ command accepts the Unicode name of an Emoji (for example, "smiling
>  face" or "heart with arrow"), like 'C-x 8 e e', with minibuffer
>  completion, and adds the Emoji into the search string.
>  
> ++++
> +*** New user options 'isearch-lazy-count-at-match'
> +When non-nil, shows the current match numbers just after the current
> +matches line. Format can be controlled with
> +'isearch-lazy-count-at-match-format'. Requires 'isearch-lazy-count'
> +and 'isearch-lazy-highlight' to be non-nil in order to work.
> +
>  ** New minor mode 'glyphless-display-mode'.
>  This allows an easy way to toggle seeing all glyphless characters in
>  the current buffer.
> diff --git a/lisp/isearch.el b/lisp/isearch.el
> index 8970216398..8abbc56275 100644
> --- a/lisp/isearch.el
> +++ b/lisp/isearch.el
> @@ -362,6 +362,16 @@ isearch-lazy-count
>    :group 'isearch
>    :version "27.1")
>  
> +(defcustom isearch-lazy-count-at-match nil
> +  "Show match numbers near the current matched search.
> +When this option, `isearch-lazy-count' and
> +`isearch-lazy-highlight' are non-nil, show the match numbers (see
> +`isearch-lazy-count') at the end of the current matches line."
> +  :type 'boolean
> +  :group 'lazy-count
> +  :group 'isearch
> +  :version "29.1")
> +
>  ;;; Lazy highlight customization.
>  
>  (defgroup lazy-highlight nil
> @@ -465,6 +475,23 @@ lazy-count-suffix-format
>    :group 'lazy-count
>    :version "27.1")
>  
> +;;; Lazy count at match customization.
> +
> +(defface lazy-count-at-match
> +  '((t (:inherit isearch)))
> +  "Face for the lazy count shown at current match."
> +  :group 'lazy-count)
> +
> +(defcustom isearch-lazy-count-at-match-format " %s/%s"
> +  "Format of the current/total number of matches for the in-buffer
> +display.
> +
> +See `isearch-lazy-count-at-match'."
> +  :type 'boolean
> +  :group 'lazy-count
> +  :group 'isearch
> +  :version "29.1")
> +
>  \f
>  ;; Define isearch help map.
>  
> @@ -1431,6 +1458,8 @@ isearch-done
>    (setq minibuffer-message-timeout isearch-original-minibuffer-message-timeout)
>    (isearch-dehighlight)
>    (lazy-highlight-cleanup lazy-highlight-cleanup)
> +  (when isearch-lazy-count-at-match
> +    (isearch-show-lazy-count-at-match-cleanup))
>    (setq isearch-lazy-highlight-last-string nil)
>    (let ((found-start (window-group-start))
>  	(found-point (point)))
> @@ -3386,7 +3415,10 @@ isearch-message
>  	     (isearch-message-prefix ellipsis isearch-nonincremental)
>  	     m
>  	     (isearch-message-suffix c-q-hack)))
> -    (if c-q-hack m (let ((message-log-max nil)) (message "%s" m)))))
> +    (if c-q-hack m (let ((message-log-max nil)) (message "%s" m))))
> +  ;; Update the in-buffer count too
> +  (when isearch-lazy-count-at-match
> +    (isearch-show-lazy-count-at-match)))
>  
>  (defun isearch--describe-regexp-mode (regexp-function &optional space-before)
>    "Make a string for describing REGEXP-FUNCTION.
> @@ -3477,41 +3509,39 @@ isearch-message-prefix
>  			(concat " [" current-input-method-title "]: "))
>  		     ": ")
>  		   )))
> -    (apply #'propertize (concat (isearch-lazy-count-format)
> +    (apply #'propertize (concat (isearch-lazy-count-format lazy-count-prefix-format)
>                          (upcase (substring m 0 1)) (substring m 1))
>  	   isearch-message-properties)))
>  
>  (defun isearch-message-suffix (&optional c-q-hack)
>    (apply #'propertize (concat (if c-q-hack "^Q" "")
> -		      (isearch-lazy-count-format 'suffix)
> +		              (isearch-lazy-count-format lazy-count-suffix-format)
>  		      (if isearch-error
>  			  (concat " [" isearch-error "]")
>  			"")
>  		      (or isearch-message-suffix-add ""))
>  	 isearch-message-properties))
>  
> -(defun isearch-lazy-count-format (&optional suffix-p)
> -  "Format the current match number and the total number of matches.
> -When SUFFIX-P is non-nil, the returned string is intended for
> -isearch-message-suffix prompt.  Otherwise, for isearch-message-prefix."
> -  (let ((format-string (if suffix-p
> -                           lazy-count-suffix-format
> -                         lazy-count-prefix-format)))
> -    (if (and format-string
> -             isearch-lazy-count
> -             isearch-lazy-count-current
> -             (not isearch-error)
> -             (not isearch-suspended))
> -        (format format-string
> -                (if isearch-lazy-highlight-forward
> -                    isearch-lazy-count-current
> -                  (if (eq isearch-lazy-count-current 0)
> -                      0
> -                    (- isearch-lazy-count-total
> -                       isearch-lazy-count-current
> -                       -1)))
> -                (or isearch-lazy-count-total "?"))
> -      "")))
> +(defun isearch-lazy-count-format (format-string)
> +  "Format the current match number and the total number of matches
> +using FORMAT-STRING. It is given two integer substitutions, the
> +first is the current match number and second the total number of
> +matches."
> +  (if (and format-string
> +           isearch-lazy-count
> +           isearch-lazy-count-current
> +           (not isearch-error)
> +           (not isearch-suspended))
> +      (format format-string
> +              (if isearch-lazy-highlight-forward
> +                  isearch-lazy-count-current
> +                (if (eq isearch-lazy-count-current 0)
> +                    0
> +                  (- isearch-lazy-count-total
> +                     isearch-lazy-count-current
> +                     -1)))
> +              (or isearch-lazy-count-total "?"))
> +    ""))
>  
>  \f
>  ;; Searching
> @@ -3990,6 +4020,7 @@ isearch-lazy-highlight-error
>  (defvar isearch-lazy-count-current nil)
>  (defvar isearch-lazy-count-total nil)
>  (defvar isearch-lazy-count-hash (make-hash-table))
> +(defvar isearch-lazy-count-at-match-overlay nil)
>  
>  (defun lazy-highlight-cleanup (&optional force procrastinate)
>    "Stop lazy highlighting and remove extra highlighting from current buffer.
> @@ -4325,17 +4356,52 @@ isearch-lazy-highlight-buffer-update
>  		;; not found or zero-length match at the search bound
>  		(if (not found)
>  		    (setq looping nil
> -			  nomore  t))))
> -	    (if nomore
> -		(when (and isearch-lazy-count isearch-mode (null isearch-message-function))
> -		  (unless isearch-lazy-count-total
> -		    (setq isearch-lazy-count-total 0))
> -		  (setq isearch-lazy-count-current
> -			(gethash opoint isearch-lazy-count-hash 0))
> -		  (isearch-message))
> -	      (setq isearch-lazy-highlight-timer
> -		    (run-at-time lazy-highlight-interval nil
> -				 'isearch-lazy-highlight-buffer-update)))))))))
> +			  nomore  t))))))
> +	(if nomore
> +	    (when (and isearch-lazy-count isearch-mode (null isearch-message-function))
> +	      (unless isearch-lazy-count-total
> +		(setq isearch-lazy-count-total 0))
> +	      (setq isearch-lazy-count-current
> +		    (gethash opoint isearch-lazy-count-hash 0))
> +	      (isearch-message))
> +	  (setq isearch-lazy-highlight-timer
> +		(run-at-time lazy-highlight-interval nil
> +			     'isearch-lazy-highlight-buffer-update)))))))
> +
> +(defun isearch-show-lazy-count-at-match ()
> +  "Show the match count just after the end of the currently matched
> +line."
> +  ;; We try to reuse the overlay as much as possible to remove
> +  ;; flickering
> +  (unless isearch-lazy-count-at-match-overlay
> +    (let ((ov (make-overlay 0 0)))
> +      (setq isearch-lazy-count-at-match-overlay ov)
> +      ;; see isearch-lazy-highlight-match
> +      (overlay-put ov 'priority 1001)
> +      (overlay-put ov 'face 'lazy-count-at-match)
> +      (unless isearch-lazy-highlight-buffer
> +        (overlay-put ov 'window (selected-window)))))
> +
> +  (let ((ov isearch-lazy-count-at-match-overlay)
> +        (pae (point-at-eol))
> +        (count (propertize (isearch-lazy-count-format
> +                            isearch-lazy-count-at-match-format)
> +                           'cursor t)))
> +    (unless (and (= (overlay-end ov)
> +                    pae)
> +                 (eq (overlay-buffer ov)
> +                     (current-buffer)))
> +      (move-overlay ov pae pae (current-buffer)))
> +    (unless (string= (overlay-get ov 'after-string)
> +                     count)
> +      (overlay-put ov 'after-string count))))
> +
> +(defun isearch-show-lazy-count-at-match-cleanup ()
> +  "Remove the search count used by
> +\\[isearch-show-lazy-count-at-match]."
> +  (when isearch-lazy-count-at-match-overlay
> +    (delete-overlay isearch-lazy-count-at-match-overlay)
> +    (setq isearch-lazy-count-at-match-overlay nil)))
>  
>  (defun isearch-resume (string regexp word forward message case-fold)
>    "Resume an incremental search.
> -- 
> 2.30.2
>
>
> Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> If it's not for everyone, then it should arguably be provided under the
>> control of the config var, but that doesn't mean it should be in
>> a separate package or relegated to some ELisp snippets for people to
>> copy&paste into their init file.
>>
>> Whether it better belongs alongside `isearch` or `isearch-mb` will
>> probably depend on details of how it's implemented.
>
> Here's a patch providing just that for isearch. It could be added to
> isearch-mb almost just as easily though it has nothing to do with search
> entry.
>
> With regards to an isearch-mb wiki "trick": the same result could be
> achieved using `isearch-mode-end-hook` and :after advice on
> `isearch-message`.
>
> Whether it becomes a part of isearch or not some feedback would be
> appreciated (;
>
> 1. Is it right to modify `isearch-lazy-count-format` in this way to
> reduce code in `isearch-show-lazy-count-at-match`?
>
> 2. Is it right to add a new face for this and if so does this need to be
> included in NEWS or other documentation?
>
> 3. Should it be extended to allow for custom positioning of the overlay?
> Perhaps with a variable like `isearch-lazy-count-at-match-pos-function`?



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Overlay count for isearch
  2022-03-16 12:00               ` Overlay count for isearch Augusto Stoffel
@ 2022-03-18  2:45                 ` Jai Flack
  2022-03-18  8:21                   ` Philip Kaludercic
  0 siblings, 1 reply; 23+ messages in thread
From: Jai Flack @ 2022-03-18  2:45 UTC (permalink / raw)
  To: Augusto Stoffel; +Cc: Stefan Monnier, Philip Kaludercic, emacs-devel

Augusto Stoffel <arstoffel@gmail.com> writes:
> when the patch proposed for bug#53126 is merged, a new
> `lazy-count-update-hook' will be available.  I think you can probably
> simplify your implementation by using it.

I would be much happier submitting it somewhere as a package or similar
with that hook instead of requiring advice. Most of this patch is
overlay management (and changing the other isearch count format function
to support this addition) so it would only move a function call
elsewhere.

-- 
Thanks,
Jai



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Overlay count for isearch
  2022-03-18  2:45                 ` Jai Flack
@ 2022-03-18  8:21                   ` Philip Kaludercic
  2022-03-24  1:22                     ` Jai Flack
  0 siblings, 1 reply; 23+ messages in thread
From: Philip Kaludercic @ 2022-03-18  8:21 UTC (permalink / raw)
  To: Jai Flack; +Cc: Augusto Stoffel, Stefan Monnier, emacs-devel

Jai Flack <jflack@disroot.org> writes:

> Augusto Stoffel <arstoffel@gmail.com> writes:
>> when the patch proposed for bug#53126 is merged, a new
>> `lazy-count-update-hook' will be available.  I think you can probably
>> simplify your implementation by using it.
>
> I would be much happier submitting it somewhere as a package or similar
> with that hook instead of requiring advice. Most of this patch is
> overlay management (and changing the other isearch count format function
> to support this addition) so it would only move a function call
> elsewhere.

If you have a Git repository somewhere, we could add it to GNU ELPA.

-- 
	Philip Kaludercic



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Overlay count for isearch
  2022-03-18  8:21                   ` Philip Kaludercic
@ 2022-03-24  1:22                     ` Jai Flack
  2022-03-24  8:31                       ` Juri Linkov
  2022-03-26  3:28                       ` Overlay count for isearch Richard Stallman
  0 siblings, 2 replies; 23+ messages in thread
From: Jai Flack @ 2022-03-24  1:22 UTC (permalink / raw)
  To: Philip Kaludercic; +Cc: Augusto Stoffel, Stefan Monnier, emacs-devel

Philip Kaludercic <philipk@posteo.net> writes:
> If you have a Git repository somewhere, we could add it to GNU ELPA.

That looks like the best way forwards; I'll submit a proposal when it's
ready.

-- 
Thanks,
Jai



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Overlay count for isearch
  2022-03-24  1:22                     ` Jai Flack
@ 2022-03-24  8:31                       ` Juri Linkov
  2022-03-25  1:04                         ` lazy-count-update-hook run with inconsistent point (Was: Overlay count for isearch) Jai Flack
  2022-03-26  3:28                       ` Overlay count for isearch Richard Stallman
  1 sibling, 1 reply; 23+ messages in thread
From: Juri Linkov @ 2022-03-24  8:31 UTC (permalink / raw)
  To: Jai Flack; +Cc: Philip Kaludercic, Augusto Stoffel, Stefan Monnier, emacs-devel

>> If you have a Git repository somewhere, we could add it to GNU ELPA.
>
> That looks like the best way forwards; I'll submit a proposal when it's
> ready.

Feel free to submit requests for changes in the core
that would allow you to hook into the core functionality.
For example, now we added a new hook 'lazy-count-update-hook'
that you can use in your package to display the count overlay
anywhere you want.



^ permalink raw reply	[flat|nested] 23+ messages in thread

* lazy-count-update-hook run with inconsistent point (Was: Overlay count for isearch)
  2022-03-24  8:31                       ` Juri Linkov
@ 2022-03-25  1:04                         ` Jai Flack
  2022-03-25  7:54                           ` lazy-count-update-hook run with inconsistent point Augusto Stoffel
  0 siblings, 1 reply; 23+ messages in thread
From: Jai Flack @ 2022-03-25  1:04 UTC (permalink / raw)
  To: Juri Linkov
  Cc: Philip Kaludercic, Augusto Stoffel, Stefan Monnier, emacs-devel

Juri Linkov <juri@linkov.net> writes:
> Feel free to submit requests for changes in the core
> that would allow you to hook into the core functionality.
> For example, now we added a new hook 'lazy-count-update-hook'
> that you can use in your package to display the count overlay
> anywhere you want.

What do you think about lazy-count-update-hook being run with
inconsistent point? It's called from three points in isearch.el and from
best I can tell, for two of those (in isearch-lazy-highlight-new-loop)
it is always called with point at the current match (start or end
depending on forward or reverse search); however the last call (in
isearch-lazy-highlight-buffer-update) is inside the save-excursion and
so the point is wherever the last overlay has been created.

I can't see any reason for this inconsistency in the UI updating code
(starting line 4338 on 392d66f6f5) so should this be moved outside the
save-excursion or rather documented as unreliable?

Note: my package can use isearch-match-data so this is just a minor
implementation detail.

-- 
Thanks,
Jai



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: lazy-count-update-hook run with inconsistent point
  2022-03-25  1:04                         ` lazy-count-update-hook run with inconsistent point (Was: Overlay count for isearch) Jai Flack
@ 2022-03-25  7:54                           ` Augusto Stoffel
  2022-03-25  8:36                             ` Juri Linkov
  0 siblings, 1 reply; 23+ messages in thread
From: Augusto Stoffel @ 2022-03-25  7:54 UTC (permalink / raw)
  To: Jai Flack; +Cc: Philip Kaludercic, emacs-devel, Stefan Monnier, Juri Linkov

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

Hi Jai,

On Fri, 25 Mar 2022 at 11:04, Jai Flack <jflack@disroot.org> wrote:

> What do you think about lazy-count-update-hook being run with
> inconsistent point? It's called from three points in isearch.el and from
> best I can tell, for two of those (in isearch-lazy-highlight-new-loop)
> it is always called with point at the current match (start or end
> depending on forward or reverse search); however the last call (in
> isearch-lazy-highlight-buffer-update) is inside the save-excursion and
> so the point is wherever the last overlay has been created.
>
> I can't see any reason for this inconsistency in the UI updating code
> (starting line 4338 on 392d66f6f5) so should this be moved outside the
> save-excursion or rather documented as unreliable?

It should be reliable.

> Note: my package can use isearch-match-data so this is just a minor
> implementation detail.

Anyway, that was an oversight.  Does the patch below solve the problem?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Always-run-isearch-lazy-count-update-hook-with-point.patch --]
[-- Type: text/x-patch, Size: 1297 bytes --]

From 6b656aa52dd539c519daab21ccef337366a9eb91 Mon Sep 17 00:00:00 2001
From: Augusto Stoffel <arstoffel@gmail.com>
Date: Fri, 25 Mar 2022 08:46:57 +0100
Subject: [PATCH] Always run 'isearch-lazy-count-update-hook' with point at
 match

* lisp/isearch.el (isearch-lazy-highlight-buffer-update):  Run
'isearch-lazy-count-update-hook' outside of save-excursion, so point
is at the current match.
---
 lisp/isearch.el | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/lisp/isearch.el b/lisp/isearch.el
index 9b311cb49e..6cee39c70a 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -4342,11 +4342,12 @@ isearch-lazy-highlight-buffer-update
 		  (setq isearch-lazy-count-current
 			(gethash opoint isearch-lazy-count-hash 0))
                   (when (and isearch-mode (null isearch-message-function))
-                    (isearch-message))
-		  (run-hooks 'lazy-count-update-hook))
+                    (isearch-message)))
 	      (setq isearch-lazy-highlight-timer
 		    (run-at-time lazy-highlight-interval nil
-				 'isearch-lazy-highlight-buffer-update)))))))))
+				 'isearch-lazy-highlight-buffer-update)))))
+        (when nomore
+          (run-hooks 'lazy-count-update-hook))))))
 
 \f
 ;; Reading from minibuffer with lazy highlight and match count
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* Re: lazy-count-update-hook run with inconsistent point
  2022-03-25  7:54                           ` lazy-count-update-hook run with inconsistent point Augusto Stoffel
@ 2022-03-25  8:36                             ` Juri Linkov
  2022-03-25  9:48                               ` Augusto Stoffel
  0 siblings, 1 reply; 23+ messages in thread
From: Juri Linkov @ 2022-03-25  8:36 UTC (permalink / raw)
  To: Augusto Stoffel; +Cc: Jai Flack, Philip Kaludercic, Stefan Monnier, emacs-devel

>> What do you think about lazy-count-update-hook being run with
>> inconsistent point? It's called from three points in isearch.el and from
>> best I can tell, for two of those (in isearch-lazy-highlight-new-loop)
>> it is always called with point at the current match (start or end
>> depending on forward or reverse search); however the last call (in
>> isearch-lazy-highlight-buffer-update) is inside the save-excursion and
>> so the point is wherever the last overlay has been created.
> ...
> Anyway, that was an oversight.  Does the patch below solve the problem?
> ...
> @@ -4342,11 +4342,12 @@ isearch-lazy-highlight-buffer-update
>  		  (setq isearch-lazy-count-current
>  			(gethash opoint isearch-lazy-count-hash 0))
>                    (when (and isearch-mode (null isearch-message-function))
> -                    (isearch-message))
> -		  (run-hooks 'lazy-count-update-hook))
> +                    (isearch-message)))
>  	      (setq isearch-lazy-highlight-timer
>  		    (run-at-time lazy-highlight-interval nil
> -				 'isearch-lazy-highlight-buffer-update)))))))))
> +				 'isearch-lazy-highlight-buffer-update)))))
> +        (when nomore
> +          (run-hooks 'lazy-count-update-hook))))))

Running the hook was also under another condition:
`(when isearch-lazy-count ...)'.  Shouldn't it be added
to `(when nomore ...)' too?



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: lazy-count-update-hook run with inconsistent point
  2022-03-25  8:36                             ` Juri Linkov
@ 2022-03-25  9:48                               ` Augusto Stoffel
  2022-03-27  5:24                                 ` Jai Flack
  2022-03-27  7:48                                 ` Juri Linkov
  0 siblings, 2 replies; 23+ messages in thread
From: Augusto Stoffel @ 2022-03-25  9:48 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Jai Flack, Philip Kaludercic, Stefan Monnier, emacs-devel

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

On Fri, 25 Mar 2022 at 10:36, Juri Linkov <juri@linkov.net> wrote:

> Running the hook was also under another condition:
> `(when isearch-lazy-count ...)'.  Shouldn't it be added
> to `(when nomore ...)' too?

Ah, of course.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Always-run-isearch-lazy-count-update-hook-with-point.patch --]
[-- Type: text/x-patch, Size: 1322 bytes --]

From 368a29d8357cbd0f36b320d9df12fe534307581a Mon Sep 17 00:00:00 2001
From: Augusto Stoffel <arstoffel@gmail.com>
Date: Fri, 25 Mar 2022 08:46:57 +0100
Subject: [PATCH] Always run 'isearch-lazy-count-update-hook' with point at
 match

* lisp/isearch.el (isearch-lazy-highlight-buffer-update):  Run
'isearch-lazy-count-update-hook' outside of save-excursion, so point
is at the current match.
---
 lisp/isearch.el | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/lisp/isearch.el b/lisp/isearch.el
index 9b311cb49e..05a73edead 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -4342,11 +4342,12 @@ isearch-lazy-highlight-buffer-update
 		  (setq isearch-lazy-count-current
 			(gethash opoint isearch-lazy-count-hash 0))
                   (when (and isearch-mode (null isearch-message-function))
-                    (isearch-message))
-		  (run-hooks 'lazy-count-update-hook))
+                    (isearch-message)))
 	      (setq isearch-lazy-highlight-timer
 		    (run-at-time lazy-highlight-interval nil
-				 'isearch-lazy-highlight-buffer-update)))))))))
+				 'isearch-lazy-highlight-buffer-update)))))
+        (when (and nomore isearch-lazy-count)
+          (run-hooks 'lazy-count-update-hook))))))
 
 \f
 ;; Reading from minibuffer with lazy highlight and match count
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* Re: Overlay count for isearch
  2022-03-24  1:22                     ` Jai Flack
  2022-03-24  8:31                       ` Juri Linkov
@ 2022-03-26  3:28                       ` Richard Stallman
  2022-03-27  5:03                         ` Jai Flack
  1 sibling, 1 reply; 23+ messages in thread
From: Richard Stallman @ 2022-03-26  3:28 UTC (permalink / raw)
  To: Jai Flack; +Cc: philipk, arstoffel, monnier, emacs-devel

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

  > > If you have a Git repository somewhere, we could add it to GNU ELPA.

  > That looks like the best way forwards; I'll submit a proposal when it's
  > ready.

Please look at https://www.gnu.org/software/repo-criteria-evaluation.html
to choose a repo that respects users' freedom and avoids miseducation
about licenses.

-- 
Dr Richard Stallman (https://stallman.org)
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)





^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: Overlay count for isearch
  2022-03-26  3:28                       ` Overlay count for isearch Richard Stallman
@ 2022-03-27  5:03                         ` Jai Flack
  0 siblings, 0 replies; 23+ messages in thread
From: Jai Flack @ 2022-03-27  5:03 UTC (permalink / raw)
  To: Richard Stallman; +Cc: emacs-devel

Richard Stallman <rms@gnu.org> writes:

> [[[ To any NSA and FBI agents reading my email: please consider    ]]]
> [[[ whether defending the US Constitution against all enemies,     ]]]
> [[[ foreign or domestic, requires you to follow Snowden's example. ]]]
>
>   > > If you have a Git repository somewhere, we could add it to GNU ELPA.
>
>   > That looks like the best way forwards; I'll submit a proposal when it's
>   > ready.
>
> Please look at https://www.gnu.org/software/repo-criteria-evaluation.html
> to choose a repo that respects users' freedom and avoids miseducation
> about licenses.

I would like to host (or at least mirror) my Emacs packages on Savannah;
does a GNU ELPA package belong on savannah.gnu.org as I've signed
copyright to the FSF or savannah.nongnu.org as it's not being maintained
as a GNU project?

-- 
Thanks,
Jai



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: lazy-count-update-hook run with inconsistent point
  2022-03-25  9:48                               ` Augusto Stoffel
@ 2022-03-27  5:24                                 ` Jai Flack
  2022-03-27  7:48                                 ` Juri Linkov
  1 sibling, 0 replies; 23+ messages in thread
From: Jai Flack @ 2022-03-27  5:24 UTC (permalink / raw)
  To: Augusto Stoffel
  Cc: Juri Linkov, Philip Kaludercic, Stefan Monnier, emacs-devel

Augusto Stoffel <arstoffel@gmail.com> writes:

> On Fri, 25 Mar 2022 at 10:36, Juri Linkov <juri@linkov.net> wrote:
>
>> Running the hook was also under another condition:
>> `(when isearch-lazy-count ...)'.  Shouldn't it be added
>> to `(when nomore ...)' too?
>
> Ah, of course.

That looks good.

-- 
Thanks,
Jai



^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: lazy-count-update-hook run with inconsistent point
  2022-03-25  9:48                               ` Augusto Stoffel
  2022-03-27  5:24                                 ` Jai Flack
@ 2022-03-27  7:48                                 ` Juri Linkov
  1 sibling, 0 replies; 23+ messages in thread
From: Juri Linkov @ 2022-03-27  7:48 UTC (permalink / raw)
  To: Augusto Stoffel; +Cc: Jai Flack, Philip Kaludercic, Stefan Monnier, emacs-devel

>> Running the hook was also under another condition:
>> `(when isearch-lazy-count ...)'.  Shouldn't it be added
>> to `(when nomore ...)' too?
>
> Ah, of course.

Thanks, pushed.



^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2022-03-27  7:48 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-23 11:56 [NonGNU] New package: ctrlf and Questions jflack
2022-02-23 18:33 ` Augusto Stoffel
2022-02-23 19:40   ` Philip Kaludercic
2022-02-23 20:59     ` Augusto Stoffel
2022-02-24 10:36       ` Jai Flack
2022-02-26 11:02         ` Augusto Stoffel
2022-02-27  4:02           ` Stefan Monnier
2022-03-16 11:37             ` Overlay count for isearch (Was: [NonGNU] New package: ctrlf and Questions) Jai Flack
2022-03-16 12:00               ` Overlay count for isearch Augusto Stoffel
2022-03-18  2:45                 ` Jai Flack
2022-03-18  8:21                   ` Philip Kaludercic
2022-03-24  1:22                     ` Jai Flack
2022-03-24  8:31                       ` Juri Linkov
2022-03-25  1:04                         ` lazy-count-update-hook run with inconsistent point (Was: Overlay count for isearch) Jai Flack
2022-03-25  7:54                           ` lazy-count-update-hook run with inconsistent point Augusto Stoffel
2022-03-25  8:36                             ` Juri Linkov
2022-03-25  9:48                               ` Augusto Stoffel
2022-03-27  5:24                                 ` Jai Flack
2022-03-27  7:48                                 ` Juri Linkov
2022-03-26  3:28                       ` Overlay count for isearch Richard Stallman
2022-03-27  5:03                         ` Jai Flack
2022-03-05  4:39           ` [NonGNU] New package: ctrlf and Questions Jai Flack
  -- strict thread matches above, loose matches on Subject: below --
2022-02-23  8:04 Jai Flack

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