all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Augusto Stoffel <arstoffel@gmail.com>
To: Juri Linkov <juri@linkov.net>
Cc: emacs-devel@gnu.org
Subject: Re: [ELPA?] Controlling Isearch from the minibuffer
Date: Fri, 14 May 2021 19:30:15 +0200	[thread overview]
Message-ID: <878s4hxly0.fsf@gmail.com> (raw)
In-Reply-To: <87lf8i8kba.fsf_-_@gmail.com> (Augusto Stoffel's message of "Thu,  13 May 2021 22:12:25 +0200")

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

On Thu, 13 May 2021 at 22:12, Augusto Stoffel <arstoffel@gmail.com> wrote:

>>> Setting `isearch-message-function' is of no help, because there are some
>>> tests for `(null isearch-message-function)' as well as some explicit
>>> calls to `(isearch-message)' in isearch.el.  As far as I can see, there
>>> is no alternative to modifying the function `isearch-message' itself.
>>
>> Tests for `(null isearch-message-function)' were added as a temporary
>> workaround until lazy count will be implemented in the minibuffer.
>> We need to remove these workarounds anyway.  So using isearch-message-function
>> should be the right thing to do.
>
> Okay, that' a low hanging fruit then.

I've attached a patch.  I can't see any deleterious effect for the
minibuffer and comint, which are the two places that set
`isearch-message-function' in Emacs.

This change is in preparation for adding lazy count in `query-replace',
`isearch-edit-string', etc.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Don-t-give-special-treatment-to-the-isearch-message-.patch --]
[-- Type: text/x-patch, Size: 6593 bytes --]

From b0867c7b7cb445dc2a8b84acc225d36b8f3ed073 Mon Sep 17 00:00:00 2001
From: Augusto Stoffel <arstoffel@gmail.com>
Date: Fri, 14 May 2021 11:58:35 +0200
Subject: [PATCH] Don't give special treatment to the isearch-message function

* lisp/isearch.el (isearch-message): defer to isearch-message-function
if non-nil.
(isearch-mode-end-hook-quit, isearch-update, with-isearch-suspended,
isearch-del-char, isearch-search-and-update, isearch-ring-adjust,
isearch-lazy-highlight-new-loop,
isearch-lazy-highlight-buffer-update):  Just call `isearch-message',
no need to check isearch-message-function anymore.
---
 lisp/isearch.el | 55 +++++++++++++++++++++++++------------------------
 1 file changed, 28 insertions(+), 27 deletions(-)

diff --git a/lisp/isearch.el b/lisp/isearch.el
index 536c76ea5d..5db9ba9e4d 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -211,7 +211,8 @@ isearch-mode-end-hook-quit
 
 (defvar isearch-message-function nil
   "Function to call to display the search prompt.
-If nil, use function `isearch-message'.")
+If non-nil, the function `isearch-message' calls this function,
+with the same arguments, to do its job.")
 
 (defvar isearch-wrap-function nil
   "Function to call to wrap the search when search is failed.
@@ -1343,7 +1344,7 @@ isearch-update
 	   (null executing-kbd-macro))
       (progn
         (if (not (input-pending-p))
-          (funcall (or isearch-message-function #'isearch-message)))
+          (isearch-message))
         (if (and isearch-slow-terminal-mode
                  (not (or isearch-small-window
                           (pos-visible-in-window-group-p))))
@@ -1731,7 +1732,7 @@ with-isearch-suspended
             (isearch-update-from-string-properties isearch-string)
 
 	    ;; Restore the minibuffer message before moving point.
-            (funcall (or isearch-message-function #'isearch-message) nil t)
+            (isearch-message nil t)
 
 	    ;; Set point at the start (end) of old match if forward (backward),
 	    ;; so after exiting minibuffer isearch resumes at the start (end)
@@ -2504,7 +2505,7 @@ isearch-del-char
           isearch-message (mapconcat 'isearch-text-char-description
                                      isearch-string "")))
   ;; Do the following before moving point.
-  (funcall (or isearch-message-function #'isearch-message) nil t)
+  (isearch-message nil t)
   ;; Use the isearch-other-end as new starting point to be able
   ;; to find the remaining part of the search string again.
   ;; This is like what `isearch-search-and-update' does,
@@ -2765,7 +2766,7 @@ isearch-search-and-update
 		    (isearch-no-upper-case-p isearch-string isearch-regexp))))
       ;; Not regexp, not reverse, or no match at point.
       ;; Do the following before moving point.
-      (funcall (or isearch-message-function #'isearch-message) nil t)
+      (isearch-message nil t)
       (if (and isearch-other-end (not isearch-adjusted))
 	  (goto-char (if isearch-forward isearch-other-end
 		       (min isearch-opoint
@@ -3187,7 +3188,7 @@ isearch-ring-adjust
   (isearch-ring-adjust1 advance)
   (if search-ring-update
       (progn
-        (funcall (or isearch-message-function #'isearch-message) nil t)
+        (isearch-message nil t)
 	(isearch-search)
 	(isearch-push-state)
 	(isearch-update))
@@ -3267,22 +3268,24 @@ isearch-message
   ;; circumstances are when follow-mode is active, the search string
   ;; spans two (or several) windows, and the message about to be
   ;; displayed will cause the echo area to expand.
-  (let ((cursor-in-echo-area ellipsis)
-	(m isearch-message)
-	(fail-pos (isearch-fail-pos t)))
-    ;; Highlight failed part
-    (when fail-pos
-      (setq m (copy-sequence m))
-      (add-text-properties fail-pos (length m) '(face isearch-fail) m)
-      ;; Highlight failed trailing whitespace
-      (when (string-match " +$" m)
-	(add-text-properties (match-beginning 0) (match-end 0)
-			     '(face trailing-whitespace) m)))
-    (setq m (concat
-	     (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 isearch-message-function
+      (funcall isearch-message-function c-q-hack ellipsis)
+    (let ((cursor-in-echo-area ellipsis)
+	  (m isearch-message)
+	  (fail-pos (isearch-fail-pos t)))
+      ;; Highlight failed part
+      (when fail-pos
+        (setq m (copy-sequence m))
+        (add-text-properties fail-pos (length m) '(face isearch-fail) m)
+        ;; Highlight failed trailing whitespace
+        (when (string-match " +$" m)
+	  (add-text-properties (match-beginning 0) (match-end 0)
+			       '(face trailing-whitespace) m)))
+      (setq m (concat
+	       (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))))))
 
 (defun isearch--describe-regexp-mode (regexp-function &optional space-before)
   "Make a string for describing REGEXP-FUNCTION.
@@ -3940,7 +3943,7 @@ isearch-lazy-highlight-new-loop
 			         isearch-lazy-highlight-window-end))))))
     ;; something important did indeed change
     (lazy-highlight-cleanup t (not (equal isearch-string ""))) ;stop old timer
-    (when (and isearch-lazy-count isearch-mode (null isearch-message-function))
+    (when isearch-lazy-count
       (when (or (equal isearch-string "")
                 ;; Check if this place was reached by a condition above
                 ;; other than changed window boundaries (that shouldn't
@@ -4010,9 +4013,7 @@ isearch-lazy-highlight-new-loop
                                    lazy-highlight-initial-delay)
                                  nil
                                  'isearch-lazy-highlight-start))))
-  ;; Update the current match number only in isearch-mode and
-  ;; unless isearch-mode is used specially with isearch-message-function
-  (when (and isearch-lazy-count isearch-mode (null isearch-message-function))
+  (when isearch-lazy-count
     ;; Update isearch-lazy-count-current only when it was already set
     ;; at the end of isearch-lazy-highlight-buffer-update
     (when isearch-lazy-count-current
@@ -4220,7 +4221,7 @@ isearch-lazy-highlight-buffer-update
 		    (setq looping nil
 			  nomore  t))))
 	    (if nomore
-		(when (and isearch-lazy-count isearch-mode (null isearch-message-function))
+		(when isearch-lazy-count
 		  (unless isearch-lazy-count-total
 		    (setq isearch-lazy-count-total 0))
 		  (setq isearch-lazy-count-current
-- 
2.31.1


  parent reply	other threads:[~2021-05-14 17:30 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-08 10:13 [WIP PATCH] Controlling Isearch from the minibuffer Augusto Stoffel
2021-05-09 13:36 ` Alan Mackenzie
2021-05-09 17:58   ` Augusto Stoffel
2021-05-10 19:51     ` Alan Mackenzie
2021-05-11  9:00       ` Augusto Stoffel
2021-05-11 15:34         ` [External] : " Drew Adams
2021-05-11 18:31           ` Juri Linkov
2021-05-11 19:38             ` Drew Adams
2021-05-12  6:45           ` Augusto Stoffel
2021-05-12 12:44             ` Stefan Monnier
2021-05-12 15:31               ` Drew Adams
2021-05-12 22:17                 ` Kévin Le Gouguec
2021-05-12 23:07                   ` Drew Adams
2021-05-13 15:12                     ` Kévin Le Gouguec
2021-05-12 21:09               ` Augusto Stoffel
2021-05-12 15:30             ` Drew Adams
2021-05-09 19:09   ` Juri Linkov
2021-05-09 19:05 ` Juri Linkov
2021-05-10 20:24   ` Augusto Stoffel
2021-05-10 21:17     ` Juri Linkov
2021-05-12  6:40       ` Augusto Stoffel
2021-05-12 17:13         ` Juri Linkov
2021-05-12 20:52           ` Augusto Stoffel
2021-05-13 16:31             ` Juri Linkov
2021-05-13 20:12               ` [ELPA?] " Augusto Stoffel
2021-05-14  1:17                 ` Jean Louis
2021-05-14  8:36                   ` Augusto Stoffel
2021-05-14 17:30                 ` Augusto Stoffel [this message]
2021-05-14 18:20                   ` Juri Linkov
2021-05-16 11:00                     ` Augusto Stoffel
2021-05-16 18:19                       ` Juri Linkov
2021-05-25 20:50                         ` Juri Linkov
2021-05-29 11:48                           ` Augusto Stoffel
2021-05-14 18:18                 ` Juri Linkov
2021-05-16 18:12                   ` Juri Linkov
2021-05-16 18:49                     ` Augusto Stoffel
2021-05-21  9:09                       ` Augusto Stoffel
2021-05-21 10:25                         ` Eli Zaretskii
2021-05-21 11:56                           ` Augusto Stoffel
2021-05-21 12:31                             ` Eli Zaretskii
2021-05-21 12:49                               ` Augusto Stoffel
2021-05-21 15:05                               ` Stefan Monnier
2021-05-21 15:09                                 ` 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=878s4hxly0.fsf@gmail.com \
    --to=arstoffel@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=juri@linkov.net \
    /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.