From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#40216: 28.0.50; Misinformation in isearch char-fold Date: Wed, 25 Mar 2020 01:00:18 +0200 Organization: LINKOV.NET Message-ID: <87y2rppddp.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="68728"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) To: 40216@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Mar 25 00:04:26 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1jGsaw-000HlW-5L for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 25 Mar 2020 00:04:26 +0100 Original-Received: from localhost ([::1]:56342 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jGsav-0000dK-7I for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 24 Mar 2020 19:04:25 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48412) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jGsaa-0000d5-Ah for bug-gnu-emacs@gnu.org; Tue, 24 Mar 2020 19:04:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jGsaY-0006ps-H7 for bug-gnu-emacs@gnu.org; Tue, 24 Mar 2020 19:04:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:49761) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jGsaY-0006pb-B3 for bug-gnu-emacs@gnu.org; Tue, 24 Mar 2020 19:04:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jGsaY-00006e-54 for bug-gnu-emacs@gnu.org; Tue, 24 Mar 2020 19:04:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 24 Mar 2020 23:04:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 40216 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.1585091014369 (code B ref -1); Tue, 24 Mar 2020 23:04:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 24 Mar 2020 23:03:34 +0000 Original-Received: from localhost ([127.0.0.1]:55734 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jGsa6-00005s-Jc for submit@debbugs.gnu.org; Tue, 24 Mar 2020 19:03:34 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:39340) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jGsa2-00005U-33 for submit@debbugs.gnu.org; Tue, 24 Mar 2020 19:03:30 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48340) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jGsZz-0000ct-Ub for bug-gnu-emacs@gnu.org; Tue, 24 Mar 2020 19:03:28 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jGsZy-0006Sb-DS for bug-gnu-emacs@gnu.org; Tue, 24 Mar 2020 19:03:27 -0400 Original-Received: from relay9-d.mail.gandi.net ([217.70.183.199]:38243) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jGsZy-0006R1-6F for bug-gnu-emacs@gnu.org; Tue, 24 Mar 2020 19:03:26 -0400 X-Originating-IP: 91.129.96.173 Original-Received: from mail.gandi.net (m91-129-96-173.cust.tele2.ee [91.129.96.173]) (Authenticated sender: juri@linkov.net) by relay9-d.mail.gandi.net (Postfix) with ESMTPSA id C491EFF802; Tue, 24 Mar 2020 23:03:21 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:177695 Archived-At: --=-=-= Content-Type: text/plain Tags: patch When the size of the generated regexp in char-fold isearch mode reaches a certain limit, it silently falls back to literal search without notifying the user about this fact. Thus uninformed users might miss some search hits. Here is the patch that instead of returning a quoted string in char-fold-to-regexp when it reaches some arbitrary limit, instead of this it toggles the literal search mode explicitly, tries to find the next occurrence in literal mode, and displays the message about switching search mode for 2 seconds: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=isearch-literal-char-fold.patch diff --git a/lisp/char-fold.el b/lisp/char-fold.el index f8a303956e..34561a2efe 100644 --- a/lisp/char-fold.el +++ b/lisp/char-fold.el @@ -370,11 +377,7 @@ char-fold-to-regexp (setq i (1+ i))) (when (> spaces 0) (push (char-fold--make-space-string spaces) out)) - (let ((regexp (apply #'concat (nreverse out)))) - ;; Limited by `MAX_BUF_SIZE' in `regex-emacs.c'. - (if (> (length regexp) 5000) - (regexp-quote string) - regexp)))) + (apply #'concat (nreverse out)))) ;;; Commands provided for completeness. diff --git a/lisp/isearch.el b/lisp/isearch.el index ddf9190dc6..7625ec12b5 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el @@ -2011,15 +2011,16 @@ regexp (defvar isearch-message-properties minibuffer-prompt-properties "Text properties that are added to the isearch prompt.") -(defun isearch--momentary-message (string) - "Print STRING at the end of the isearch prompt for 1 second." +(defun isearch--momentary-message (string &optional seconds) + "Print STRING at the end of the isearch prompt for 1 second. +The optional argument SECONDS overrides the number of seconds." (let ((message-log-max nil)) (message "%s%s%s" (isearch-message-prefix nil isearch-nonincremental) isearch-message (apply #'propertize (format " [%s]" string) isearch-message-properties))) - (sit-for 1)) + (sit-for (or seconds 1))) (isearch-define-mode-toggle lax-whitespace " " nil "In ordinary search, toggles the value of the variable @@ -3443,7 +3444,10 @@ isearch-search (string-match "\\`Regular expression too big" isearch-error)) (cond (isearch-regexp-function - (setq isearch-error "Too many words")) + (setq isearch-error nil) + (setq isearch-regexp-function nil) + (isearch-search-and-update) + (isearch--momentary-message "Too many words; switched to literal mode" 2)) ((and isearch-lax-whitespace search-whitespace-regexp) (setq isearch-error "Too many spaces for whitespace matching")))))) --=-=-=--