From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Augusto Stoffel Newsgroups: gmane.emacs.devel Subject: Re: [ELPA?] Controlling Isearch from the minibuffer Date: Fri, 14 May 2021 19:30:15 +0200 Message-ID: <878s4hxly0.fsf@gmail.com> References: <87zgx5cz33.fsf@gmail.com> <87o8djohqf.fsf@mail.linkov.net> <87eeeenxqq.fsf@gmail.com> <87h7jath3m.fsf@mail.linkov.net> <87mtt0wj37.fsf@gmail.com> <87cztvx4dc.fsf@mail.linkov.net> <87bl9fr7xh.fsf@gmail.com> <87tun6n12v.fsf@mail.linkov.net> <87lf8i8kba.fsf_-_@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5483"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) Cc: emacs-devel@gnu.org To: Juri Linkov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri May 14 19:49:09 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lhbvx-0001I4-7C for ged-emacs-devel@m.gmane-mx.org; Fri, 14 May 2021 19:49:09 +0200 Original-Received: from localhost ([::1]:59422 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lhbvw-0004Zs-8j for ged-emacs-devel@m.gmane-mx.org; Fri, 14 May 2021 13:49:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37200) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lhbdp-0001Z0-3c for emacs-devel@gnu.org; Fri, 14 May 2021 13:30:26 -0400 Original-Received: from mail-ej1-x62d.google.com ([2a00:1450:4864:20::62d]:45761) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lhbdi-00075Q-70 for emacs-devel@gnu.org; Fri, 14 May 2021 13:30:24 -0400 Original-Received: by mail-ej1-x62d.google.com with SMTP id c22so17591483ejd.12 for ; Fri, 14 May 2021 10:30:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=CsHY+H2U/smfvruUNuN9UD6naIQmxNsPXUOCHXiEHh0=; b=SZCAMe0i3oN5Sw1QMaTOBPdIJ9fYYIgVWJcCKIS+xpsbqIuYbvmNSe1kGafHh0HJop N77mMIQ3oBzS8B5FHwpywSpVByoG56+XKofjTiya3Xf8z9r9ViNkZJTI81g7K5n/Oezd BBHgfhnZdEDT8aG/67icBtBzgQjkrg/eHwh1A9oEkzemb0tVD8nfdaPPh9Nv++ZfAyby f5swU4uUa/iqRZ20Tp8PqF1FJTcG43gKXSqzpRh0NwRWZXSHHEQHwjkf8MMQm0ROumSS 0eSUZPp2wO5bzWMt+nLaRHWYd9/eY21h9jBFYgabWtpy6duN+X72QuJAiqQm0eyDKhAw 6cLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=CsHY+H2U/smfvruUNuN9UD6naIQmxNsPXUOCHXiEHh0=; b=OyseH51Wl208PxYJWHmpPnTieFYaaN/D30rlvz/mIAiMgtejxKQTJPI9pJBvw8L6Es 2REPBo9tM26Bei4e/V8CpS3i7j0jM5IkBxbfd5tMZcqtZ7yNECCz2r8Eofncso1T2b6/ w2MoEl3SC6E3zXsjsP0AQoZnLW62Sh/s4NJCdMh+shj5sax5+V94mxkyz6TNtWAAM8SJ B3tkytQFhmEVanlbD2azIKp5ncjAwh2u8H6wkAKWCb4Z2U7wJPaYP2HOzGHw4DqqOjSw 9UAichDD2tX7dZw9d0Yd+L3f1l1fdHmfsyx8WGAjvt3X08HGnCL/2YC9aNw7UcOkWlTP Q80Q== X-Gm-Message-State: AOAM532TIGszSeniiEzHwfl94nY0W2hJ0sRsL6Mq2IrM6FCiqJDCN55b MrSiYf0JvdSNFYyXKhGZRlJp1B/MfCc= X-Google-Smtp-Source: ABdhPJwmbsqSIVSBZR9fwIoP0Bq4VNga2gesXZahDLcGk4db+L88t8Qy9MJIGL11zSyPwHmizFPNCQ== X-Received: by 2002:a17:906:29ce:: with SMTP id y14mr49549017eje.189.1621013415893; Fri, 14 May 2021 10:30:15 -0700 (PDT) Original-Received: from ars3 ([2a02:908:2211:8540::68a]) by smtp.gmail.com with ESMTPSA id n11sm4088244ejg.43.2021.05.14.10.30.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 May 2021 10:30:15 -0700 (PDT) In-Reply-To: <87lf8i8kba.fsf_-_@gmail.com> (Augusto Stoffel's message of "Thu, 13 May 2021 22:12:25 +0200") Received-SPF: pass client-ip=2a00:1450:4864:20::62d; envelope-from=arstoffel@gmail.com; helo=mail-ej1-x62d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:269290 Archived-At: --=-=-= Content-Type: text/plain On Thu, 13 May 2021 at 22:12, Augusto Stoffel 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. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Don-t-give-special-treatment-to-the-isearch-message-.patch >From b0867c7b7cb445dc2a8b84acc225d36b8f3ed073 Mon Sep 17 00:00:00 2001 From: Augusto Stoffel 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 --=-=-=--