From unknown Wed Jun 18 23:09:36 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#40337 <40337@debbugs.gnu.org> To: bug#40337 <40337@debbugs.gnu.org> Subject: Status: 28.0.50; Enable case-fold-search in hi-lock Reply-To: bug#40337 <40337@debbugs.gnu.org> Date: Thu, 19 Jun 2025 06:09:36 +0000 retitle 40337 28.0.50; Enable case-fold-search in hi-lock reassign 40337 emacs submitter 40337 Juri Linkov severity 40337 normal tag 40337 fixed thanks From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 30 18:53:55 2020 Received: (at submit) by debbugs.gnu.org; 30 Mar 2020 22:53:55 +0000 Received: from localhost ([127.0.0.1]:35235 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jJ3I3-0002tE-FF for submit@debbugs.gnu.org; Mon, 30 Mar 2020 18:53:55 -0400 Received: from lists.gnu.org ([209.51.188.17]:55324) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jJ3I1-0002t2-GT for submit@debbugs.gnu.org; Mon, 30 Mar 2020 18:53:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55475) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jJ3I0-0001BW-5O for bug-gnu-emacs@gnu.org; Mon, 30 Mar 2020 18:53:53 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=BAYES_50,RCVD_IN_DNSWL_LOW, URIBL_BLOCKED autolearn=disabled version=3.3.2 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jJ3Hy-00020x-FY for bug-gnu-emacs@gnu.org; Mon, 30 Mar 2020 18:53:52 -0400 Received: from relay8-d.mail.gandi.net ([217.70.183.201]:53299) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jJ3Hy-0001nn-9S for bug-gnu-emacs@gnu.org; Mon, 30 Mar 2020 18:53:50 -0400 X-Originating-IP: 91.129.102.97 Received: from mail.gandi.net (m91-129-102-97.cust.tele2.ee [91.129.102.97]) (Authenticated sender: juri@linkov.net) by relay8-d.mail.gandi.net (Postfix) with ESMTPSA id 55F5A1BF203 for ; Mon, 30 Mar 2020 22:53:45 +0000 (UTC) From: Juri Linkov To: bug-gnu-emacs@gnu.org Subject: 28.0.50; Enable case-fold-search in hi-lock Organization: LINKOV.NET Date: Tue, 31 Mar 2020 01:32:55 +0300 Message-ID: <87a73xtsqw.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 217.70.183.201 X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) X-Debbugs-Cc: Stefan Monnier A new defcustom hi-lock-case-fold-search is intended to fix the long-standing deficiency in hi-lock.el to avoid such ugly hacks as in hi-lock-process-phrase: ;; FIXME fragile; better to just bind case-fold-search? (Bug#7161) (setq mod-phrase (replace-regexp-in-string "\\(^\\|\\s-\\)\\([a-z]\\)" (lambda (m) (format "%s[%s%s]" (match-string 1 m) (upcase (match-string 2 m)) (match-string 2 m))) phrase)) and in isearch--highlight-regexp-or-lines: ;; Turn isearch-string into a case-insensitive ;; regexp. (mapconcat (lambda (c) (let ((s (string c))) (if (string-match "[[:alpha:]]" s) (format "[%s%s]" (upcase s) (downcase s)) (regexp-quote s)))) isearch-string "") Also these hacks fail when hi-lock is called from isearch by isearch-highlight-regexp when regexp-based char-fold is enabled - hi-lock highlights less matches than are lazy-highlighted in isearch, it doesn't take into account the value of isearch-case-fold-search and these hacks are unable to change the regexp generated by char-fold. But when a new option hi-lock-case-fold-search is enabled, it updates font-lock-keywords-case-fold-search that makes hi-lock matches case-insensitive: diff --git a/lisp/hi-lock.el b/lisp/hi-lock.el index de258935e1..9394e2e157 100644 --- a/lisp/hi-lock.el +++ b/lisp/hi-lock.el @@ -135,6 +135,11 @@ hi-lock-file-patterns-policy ;; It can have a function value. (put 'hi-lock-file-patterns-policy 'risky-local-variable t) +(defcustom hi-lock-case-fold-search t + "Non-nil means the patterns for `font-lock' are case-insensitive." + :type 'boolean + :version "28.1") + (defcustom hi-lock-auto-select-face nil "Non-nil means highlighting commands do not prompt for the face to use. Instead, each hi-lock command will cycle through the faces in @@ -394,6 +399,7 @@ hi-lock-mode (progn (define-key-after menu-bar-edit-menu [hi-lock] (cons "Regexp Highlighting" hi-lock-menu)) + (setq-local font-lock-keywords-case-fold-search hi-lock-case-fold-search) (hi-lock-find-patterns) (add-hook 'font-lock-mode-hook 'hi-lock-font-lock-hook nil t) ;; Remove regexps from font-lock-keywords (bug#13891). From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 30 23:05:10 2020 Received: (at 40337) by debbugs.gnu.org; 31 Mar 2020 03:05:11 +0000 Received: from localhost ([127.0.0.1]:35361 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jJ7DC-0007KV-La for submit@debbugs.gnu.org; Mon, 30 Mar 2020 23:05:10 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:51316) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jJ7DA-0007KE-Ti for 40337@debbugs.gnu.org; Mon, 30 Mar 2020 23:05:09 -0400 Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 3C3EC811C7; Mon, 30 Mar 2020 23:05:03 -0400 (EDT) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 926B481133; Mon, 30 Mar 2020 23:05:01 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1585623901; bh=x5+VZL5KIQumMXWSlQw1zGXt6AcZIAZXjkmoupcsGSM=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=Zs5Ab9P8Bn2w/+zWtOJPfWnp7JXnpOJjOwDbMQ2X8B6rRjpooMB+nL/qiWc5Ly6Ug UqVRBAMus/uw0xRjwU9qsDlzH76F7PNr/Jr3cD8lDv2flBcs+Dj+ftueSF2393hP4P JtzBgxIQsztYRAOXwpvlm3LK/QW30Ida6393RRCsSz+yXIHqRjedAjiIAoPswuUYNK /ZceUxt6ariof8Xh/hFWnGjyW/w1PRaIVMg1zODaO4VQ+8dNwJYKeRvnop3hdOJF4C dVu0t1+tpPJXiboYLVOWN2gdOBK0YjU5hx7mZakOMvIRge6a/yrFyCQ4tD07L7LGbw TjEh4ww9uNjuw== Received: from alfajor (unknown [104.247.241.114]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 182361205CC; Mon, 30 Mar 2020 23:05:01 -0400 (EDT) From: Stefan Monnier To: Juri Linkov Subject: Re: bug#40337: 28.0.50; Enable case-fold-search in hi-lock Message-ID: References: <87a73xtsqw.fsf@mail.linkov.net> Date: Mon, 30 Mar 2020 23:05:00 -0400 In-Reply-To: <87a73xtsqw.fsf@mail.linkov.net> (Juri Linkov's message of "Tue, 31 Mar 2020 01:32:55 +0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL 0.138 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 40337 Cc: 40337@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > + (setq-local font-lock-keywords-case-fold-search hi-lock-case-fold-search) This affects all the font-lock-keywords, so it's likely to mess things up for the non-hi-lock keywords. I think we should change the patterns added to `font-lock-keywords` instead, such that they do (let ((case-fold-search hi-lock-case-fold-search)) <...>) around the corresponding regexp search. Stefan From debbugs-submit-bounces@debbugs.gnu.org Thu Apr 02 17:52:13 2020 Received: (at 40337) by debbugs.gnu.org; 2 Apr 2020 21:52:14 +0000 Received: from localhost ([127.0.0.1]:40870 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jK7kz-0007tw-Bs for submit@debbugs.gnu.org; Thu, 02 Apr 2020 17:52:13 -0400 Received: from relay8-d.mail.gandi.net ([217.70.183.201]:38125) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jK7kx-0007tV-3k for 40337@debbugs.gnu.org; Thu, 02 Apr 2020 17:52:12 -0400 X-Originating-IP: 91.129.99.85 Received: from mail.gandi.net (m91-129-99-85.cust.tele2.ee [91.129.99.85]) (Authenticated sender: juri@linkov.net) by relay8-d.mail.gandi.net (Postfix) with ESMTPSA id 918071BF210; Thu, 2 Apr 2020 21:52:03 +0000 (UTC) From: Juri Linkov To: Stefan Monnier Subject: Re: bug#40337: 28.0.50; Enable case-fold-search in hi-lock Organization: LINKOV.NET References: <87a73xtsqw.fsf@mail.linkov.net> Date: Fri, 03 Apr 2020 00:31:38 +0300 In-Reply-To: (Stefan Monnier's message of "Mon, 30 Mar 2020 23:05:00 -0400") Message-ID: <87pncpa8il.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 40337 Cc: 40337@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) --=-=-= Content-Type: text/plain >> + (setq-local font-lock-keywords-case-fold-search hi-lock-case-fold-search) > > This affects all the font-lock-keywords, so it's likely to mess things > up for the non-hi-lock keywords. > > I think we should change the patterns added to `font-lock-keywords` > instead, such that they do > > (let ((case-fold-search hi-lock-case-fold-search)) <...>) > > around the corresponding regexp search. I tried this, and it works well. Then instead of adding defcustom I copied all related details from occur to highlight-regexp/highlight-symbol-at-point and from isearch-occur to isearch-highlight-regexp to make occur/hi-lock identical in regard how they handle case-folding (docstrings were copied too). There is one remaining case that is unclear - whether to use case-fold-search in hi-lock-process-phrase. Its comment says: ;; FIXME fragile; better to just bind case-fold-search? (Bug#7161) But according to docstring of highlight-phrase: When called interactively, replace whitespace in user-provided regexp with arbitrary whitespace, and make initial lower-case letters case-insensitive, before highlighting with `hi-lock-set-pattern'. I'm not sure if "make initial lower-case letters case-insensitive" the same as this code (if (and case-fold-search search-upper-case) (isearch-no-upper-case-p regexp t) case-fold-search) shared between occur and hi-lock in this patch: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=hi-lock-case-fold.patch diff --git a/lisp/hi-lock.el b/lisp/hi-lock.el index de258935e1..243be13405 100644 --- a/lisp/hi-lock.el +++ b/lisp/hi-lock.el @@ -434,6 +434,9 @@ hi-lock-line-face-buffer Interactively, prompt for REGEXP using `read-regexp', then FACE. Use the global history list for FACE. +If REGEXP contains upper case characters (excluding those preceded by `\\') +and `search-upper-case' is non-nil, the matching is case-sensitive. + Use Font lock mode, if enabled, to highlight REGEXP. Otherwise, use overlays for highlighting. If overlays are used, the highlighting will not update as you type." @@ -447,7 +450,10 @@ hi-lock-line-face-buffer (hi-lock-set-pattern ;; The \\(?:...\\) grouping construct ensures that a leading ^, +, * or ? ;; or a trailing $ in REGEXP will be interpreted correctly. - (concat "^.*\\(?:" regexp "\\).*\\(?:$\\)\n?") face)) + (concat "^.*\\(?:" regexp "\\).*\\(?:$\\)\n?") face nil + (if (and case-fold-search search-upper-case) + (isearch-no-upper-case-p regexp t) + case-fold-search))) ;;;###autoload @@ -460,6 +466,9 @@ hi-lock-face-buffer corresponding SUBEXP (interactively, the prefix argument) of REGEXP. If SUBEXP is omitted or nil, the entire REGEXP is highlighted. +If REGEXP contains upper case characters (excluding those preceded by `\\') +and `search-upper-case' is non-nil, the matching is case-sensitive. + Use Font lock mode, if enabled, to highlight REGEXP. Otherwise, use overlays for highlighting. If overlays are used, the highlighting will not update as you type." @@ -471,7 +480,11 @@ hi-lock-face-buffer current-prefix-arg)) (or (facep face) (setq face 'hi-yellow)) (unless hi-lock-mode (hi-lock-mode 1)) - (hi-lock-set-pattern regexp face subexp)) + (hi-lock-set-pattern + regexp face subexp + (if (and case-fold-search search-upper-case) + (isearch-no-upper-case-p regexp t) + case-fold-search))) ;;;###autoload (defalias 'highlight-phrase 'hi-lock-face-phrase-buffer) @@ -507,6 +520,9 @@ hi-lock-face-symbol-at-point unless you use a prefix argument. Uses `find-tag-default-as-symbol-regexp' to retrieve the symbol at point. +If REGEXP contains upper case characters (excluding those preceded by `\\') +and `search-upper-case' is non-nil, the matching is case-sensitive. + This uses Font lock mode if it is enabled; otherwise it uses overlays, in which case the highlighting will not update as you type." (interactive) @@ -516,7 +532,11 @@ hi-lock-face-symbol-at-point (face (hi-lock-read-face-name))) (or (facep face) (setq face 'hi-yellow)) (unless hi-lock-mode (hi-lock-mode 1)) - (hi-lock-set-pattern regexp face))) + (hi-lock-set-pattern + regexp face nil + (if (and case-fold-search search-upper-case) + (isearch-no-upper-case-p regexp t) + case-fold-search)))) (defun hi-lock-keyword->face (keyword) (cadr (cadr (cadr keyword)))) ; Keyword looks like (REGEXP (0 'FACE) ...). @@ -713,14 +733,17 @@ hi-lock-read-face-name (add-to-list 'hi-lock-face-defaults face t)) (intern face))) -(defun hi-lock-set-pattern (regexp face &optional subexp) +(defun hi-lock-set-pattern (regexp face &optional subexp case-fold) "Highlight SUBEXP of REGEXP with face FACE. If omitted or nil, SUBEXP defaults to zero, i.e. the entire -REGEXP is highlighted." +REGEXP is highlighted. Non-nil CASE-FOLD ignores case." ;; Hashcons the regexp, so it can be passed to remove-overlays later. (setq regexp (hi-lock--hashcons regexp)) (setq subexp (or subexp 0)) - (let ((pattern (list regexp (list subexp (list 'quote face) 'prepend))) + (let ((pattern (list (lambda (limit) + (let ((case-fold-search case-fold)) + (re-search-forward regexp limit t))) + (list subexp (list 'quote face) 'prepend))) (no-matches t)) ;; Refuse to highlight a text that is already highlighted. (if (assoc regexp hi-lock-interactive-patterns) @@ -740,14 +763,15 @@ hi-lock-set-pattern (+ range-max (max 0 (- (point-min) range-min)))))) (save-excursion (goto-char search-start) - (while (re-search-forward regexp search-end t) - (when no-matches (setq no-matches nil)) - (let ((overlay (make-overlay (match-beginning subexp) - (match-end subexp)))) - (overlay-put overlay 'hi-lock-overlay t) - (overlay-put overlay 'hi-lock-overlay-regexp regexp) - (overlay-put overlay 'face face)) - (goto-char (match-end 0))) + (let ((case-fold-search case-fold)) + (while (re-search-forward regexp search-end t) + (when no-matches (setq no-matches nil)) + (let ((overlay (make-overlay (match-beginning subexp) + (match-end subexp)))) + (overlay-put overlay 'hi-lock-overlay t) + (overlay-put overlay 'hi-lock-overlay-regexp regexp) + (overlay-put overlay 'face face)) + (goto-char (match-end 0)))) (when no-matches (add-to-list 'hi-lock--unused-faces (face-name face)) (setq hi-lock-interactive-patterns diff --git a/lisp/isearch.el b/lisp/isearch.el index 7625ec12b5..1f06c3ba5a 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el @@ -2382,22 +2382,12 @@ isearch--highlight-regexp-or-lines (funcall isearch-regexp-function isearch-string)) (isearch-regexp-function (word-search-regexp isearch-string)) (isearch-regexp isearch-string) - ((if (and (eq isearch-case-fold-search t) - search-upper-case) - (isearch-no-upper-case-p - isearch-string isearch-regexp) - isearch-case-fold-search) - ;; Turn isearch-string into a case-insensitive - ;; regexp. - (mapconcat - (lambda (c) - (let ((s (string c))) - (if (string-match "[[:alpha:]]" s) - (format "[%s%s]" (upcase s) (downcase s)) - (regexp-quote s)))) - isearch-string "")) (t (regexp-quote isearch-string))))) - (funcall hi-lock-func regexp (hi-lock-read-face-name))) + (let ((case-fold-search isearch-case-fold-search) + ;; Set `search-upper-case' to nil to not call + ;; `isearch-no-upper-case-p' in `hi-lock'. + (search-upper-case nil)) + (funcall hi-lock-func regexp (hi-lock-read-face-name)))) (and isearch-recursive-edit (exit-recursive-edit))) (defun isearch-highlight-regexp () --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Thu Apr 02 19:02:46 2020 Received: (at 40337) by debbugs.gnu.org; 2 Apr 2020 23:02:46 +0000 Received: from localhost ([127.0.0.1]:40911 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jK8rG-0000h7-1H for submit@debbugs.gnu.org; Thu, 02 Apr 2020 19:02:46 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:7630) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jK8rD-0000gP-9O for 40337@debbugs.gnu.org; Thu, 02 Apr 2020 19:02:43 -0400 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 8EB8B44FBD6; Thu, 2 Apr 2020 19:02:37 -0400 (EDT) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 5468844FBD2; Thu, 2 Apr 2020 19:02:35 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1585868555; bh=U6gKWI7UdR3UQk65hyF+M9JDvh3cX61unTGcTK9cMBw=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=b2SRM4oIObwum1Wg8/t/Y13r3FCqFauDYrZID9VAZhfcjRcDCxtUvDEigG6XCezzt kmeKi7jxVEYmVsan091BZKRK61h/3JFqiKp8EH5adi30by6599WP7vTW1ZScwhp9RV Bb9JlQ8Ifcbu0+YUKB4CLhQtxROYphCbUpFFvLtFzzsJcJOZ4wQ6gOVtBNcQS49kmu SwHkDRkvgb2qxDO2bSc9/68yZpiguuzdMq/dT8zTDOoBmBby+nUBQws0+GrPWSOvUy s5oN/psrbNGuc9nWAZlkq/5w6BGWyMJDYNcM6R49b0l/+O2f75T6az5YsQ/E8xB+ly nrNiZWPOz1tSg== Received: from alfajor (unknown [104.247.241.114]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id B0E4C12055F; Thu, 2 Apr 2020 19:02:34 -0400 (EDT) From: Stefan Monnier To: Juri Linkov Subject: Re: bug#40337: 28.0.50; Enable case-fold-search in hi-lock Message-ID: References: <87a73xtsqw.fsf@mail.linkov.net> <87pncpa8il.fsf@mail.linkov.net> Date: Thu, 02 Apr 2020 19:02:33 -0400 In-Reply-To: <87pncpa8il.fsf@mail.linkov.net> (Juri Linkov's message of "Fri, 03 Apr 2020 00:31:38 +0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL 0.109 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 40337 Cc: 40337@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > I tried this, and it works well. Then instead of adding defcustom I copied > all related details from occur to highlight-regexp/highlight-symbol-at-point > and from isearch-occur to isearch-highlight-regexp to make occur/hi-lock > identical in regard how they handle case-folding (docstrings were copied too). Great, the patch looks good. > There is one remaining case that is unclear - whether to use > case-fold-search in hi-lock-process-phrase. Its comment says: > > ;; FIXME fragile; better to just bind case-fold-search? (Bug#7161) > > But according to docstring of highlight-phrase: > > When called interactively, replace whitespace in user-provided > regexp with arbitrary whitespace, and make initial lower-case > letters case-insensitive, before highlighting with `hi-lock-set-pattern'. > > I'm not sure if "make initial lower-case letters case-insensitive" > the same as this code > > (if (and case-fold-search search-upper-case) > (isearch-no-upper-case-p regexp t) > case-fold-search) > > shared between occur and hi-lock in this patch: I think it's a good interpretation of that docstring. If needed we could additionally tweak the docstring to clarify the behavior. Stefan > diff --git a/lisp/hi-lock.el b/lisp/hi-lock.el > index de258935e1..243be13405 100644 > --- a/lisp/hi-lock.el > +++ b/lisp/hi-lock.el > @@ -434,6 +434,9 @@ hi-lock-line-face-buffer > Interactively, prompt for REGEXP using `read-regexp', then FACE. > Use the global history list for FACE. > > +If REGEXP contains upper case characters (excluding those preceded by `\\') > +and `search-upper-case' is non-nil, the matching is case-sensitive. > + > Use Font lock mode, if enabled, to highlight REGEXP. Otherwise, > use overlays for highlighting. If overlays are used, the > highlighting will not update as you type." > @@ -447,7 +450,10 @@ hi-lock-line-face-buffer > (hi-lock-set-pattern > ;; The \\(?:...\\) grouping construct ensures that a leading ^, +, * or ? > ;; or a trailing $ in REGEXP will be interpreted correctly. > - (concat "^.*\\(?:" regexp "\\).*\\(?:$\\)\n?") face)) > + (concat "^.*\\(?:" regexp "\\).*\\(?:$\\)\n?") face nil > + (if (and case-fold-search search-upper-case) > + (isearch-no-upper-case-p regexp t) > + case-fold-search))) > > > ;;;###autoload > @@ -460,6 +466,9 @@ hi-lock-face-buffer > corresponding SUBEXP (interactively, the prefix argument) of REGEXP. > If SUBEXP is omitted or nil, the entire REGEXP is highlighted. > > +If REGEXP contains upper case characters (excluding those preceded by `\\') > +and `search-upper-case' is non-nil, the matching is case-sensitive. > + > Use Font lock mode, if enabled, to highlight REGEXP. Otherwise, > use overlays for highlighting. If overlays are used, the > highlighting will not update as you type." > @@ -471,7 +480,11 @@ hi-lock-face-buffer > current-prefix-arg)) > (or (facep face) (setq face 'hi-yellow)) > (unless hi-lock-mode (hi-lock-mode 1)) > - (hi-lock-set-pattern regexp face subexp)) > + (hi-lock-set-pattern > + regexp face subexp > + (if (and case-fold-search search-upper-case) > + (isearch-no-upper-case-p regexp t) > + case-fold-search))) > > ;;;###autoload > (defalias 'highlight-phrase 'hi-lock-face-phrase-buffer) > @@ -507,6 +520,9 @@ hi-lock-face-symbol-at-point > unless you use a prefix argument. > Uses `find-tag-default-as-symbol-regexp' to retrieve the symbol at point. > > +If REGEXP contains upper case characters (excluding those preceded by `\\') > +and `search-upper-case' is non-nil, the matching is case-sensitive. > + > This uses Font lock mode if it is enabled; otherwise it uses overlays, > in which case the highlighting will not update as you type." > (interactive) > @@ -516,7 +532,11 @@ hi-lock-face-symbol-at-point > (face (hi-lock-read-face-name))) > (or (facep face) (setq face 'hi-yellow)) > (unless hi-lock-mode (hi-lock-mode 1)) > - (hi-lock-set-pattern regexp face))) > + (hi-lock-set-pattern > + regexp face nil > + (if (and case-fold-search search-upper-case) > + (isearch-no-upper-case-p regexp t) > + case-fold-search)))) > > (defun hi-lock-keyword->face (keyword) > (cadr (cadr (cadr keyword)))) ; Keyword looks like (REGEXP (0 'FACE) ...). > @@ -713,14 +733,17 @@ hi-lock-read-face-name > (add-to-list 'hi-lock-face-defaults face t)) > (intern face))) > > -(defun hi-lock-set-pattern (regexp face &optional subexp) > +(defun hi-lock-set-pattern (regexp face &optional subexp case-fold) > "Highlight SUBEXP of REGEXP with face FACE. > If omitted or nil, SUBEXP defaults to zero, i.e. the entire > -REGEXP is highlighted." > +REGEXP is highlighted. Non-nil CASE-FOLD ignores case." > ;; Hashcons the regexp, so it can be passed to remove-overlays later. > (setq regexp (hi-lock--hashcons regexp)) > (setq subexp (or subexp 0)) > - (let ((pattern (list regexp (list subexp (list 'quote face) 'prepend))) > + (let ((pattern (list (lambda (limit) > + (let ((case-fold-search case-fold)) > + (re-search-forward regexp limit t))) > + (list subexp (list 'quote face) 'prepend))) > (no-matches t)) > ;; Refuse to highlight a text that is already highlighted. > (if (assoc regexp hi-lock-interactive-patterns) > @@ -740,14 +763,15 @@ hi-lock-set-pattern > (+ range-max (max 0 (- (point-min) range-min)))))) > (save-excursion > (goto-char search-start) > - (while (re-search-forward regexp search-end t) > - (when no-matches (setq no-matches nil)) > - (let ((overlay (make-overlay (match-beginning subexp) > - (match-end subexp)))) > - (overlay-put overlay 'hi-lock-overlay t) > - (overlay-put overlay 'hi-lock-overlay-regexp regexp) > - (overlay-put overlay 'face face)) > - (goto-char (match-end 0))) > + (let ((case-fold-search case-fold)) > + (while (re-search-forward regexp search-end t) > + (when no-matches (setq no-matches nil)) > + (let ((overlay (make-overlay (match-beginning subexp) > + (match-end subexp)))) > + (overlay-put overlay 'hi-lock-overlay t) > + (overlay-put overlay 'hi-lock-overlay-regexp regexp) > + (overlay-put overlay 'face face)) > + (goto-char (match-end 0)))) > (when no-matches > (add-to-list 'hi-lock--unused-faces (face-name face)) > (setq hi-lock-interactive-patterns > diff --git a/lisp/isearch.el b/lisp/isearch.el > index 7625ec12b5..1f06c3ba5a 100644 > --- a/lisp/isearch.el > +++ b/lisp/isearch.el > @@ -2382,22 +2382,12 @@ isearch--highlight-regexp-or-lines > (funcall isearch-regexp-function isearch-string)) > (isearch-regexp-function (word-search-regexp isearch-string)) > (isearch-regexp isearch-string) > - ((if (and (eq isearch-case-fold-search t) > - search-upper-case) > - (isearch-no-upper-case-p > - isearch-string isearch-regexp) > - isearch-case-fold-search) > - ;; Turn isearch-string into a case-insensitive > - ;; regexp. > - (mapconcat > - (lambda (c) > - (let ((s (string c))) > - (if (string-match "[[:alpha:]]" s) > - (format "[%s%s]" (upcase s) (downcase s)) > - (regexp-quote s)))) > - isearch-string "")) > (t (regexp-quote isearch-string))))) > - (funcall hi-lock-func regexp (hi-lock-read-face-name))) > + (let ((case-fold-search isearch-case-fold-search) > + ;; Set `search-upper-case' to nil to not call > + ;; `isearch-no-upper-case-p' in `hi-lock'. > + (search-upper-case nil)) > + (funcall hi-lock-func regexp (hi-lock-read-face-name)))) > (and isearch-recursive-edit (exit-recursive-edit))) > > (defun isearch-highlight-regexp () From debbugs-submit-bounces@debbugs.gnu.org Sun Apr 05 19:36:05 2020 Received: (at 40337) by debbugs.gnu.org; 5 Apr 2020 23:36:05 +0000 Received: from localhost ([127.0.0.1]:46884 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jLEo8-0004sg-Nk for submit@debbugs.gnu.org; Sun, 05 Apr 2020 19:36:05 -0400 Received: from relay1-d.mail.gandi.net ([217.70.183.193]:9829) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jLEo6-0004rh-Er for 40337@debbugs.gnu.org; Sun, 05 Apr 2020 19:36:03 -0400 X-Originating-IP: 91.129.99.85 Received: from mail.gandi.net (m91-129-99-85.cust.tele2.ee [91.129.99.85]) (Authenticated sender: juri@linkov.net) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id 3A707240004; Sun, 5 Apr 2020 23:35:54 +0000 (UTC) From: Juri Linkov To: Stefan Monnier Subject: Re: bug#40337: 28.0.50; Enable case-fold-search in hi-lock Organization: LINKOV.NET References: <87a73xtsqw.fsf@mail.linkov.net> <87pncpa8il.fsf@mail.linkov.net> Date: Mon, 06 Apr 2020 02:12:13 +0300 In-Reply-To: (Stefan Monnier's message of "Thu, 02 Apr 2020 19:02:33 -0400") Message-ID: <87mu7ptsqm.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 40337 Cc: 40337@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit > I think it's a good interpretation of that docstring. If needed > we could additionally tweak the docstring to clarify the behavior. While testing I found a problem: using 'unhighlight-regexp' ('M-s h u') displays too long prompt: Regexp to unhighlight (default (closure ((case-fold . t) (subexp . 0) (face . hi-yellow) (regexp . foo) t) (limit) (let ((case-fold-search case-fold)) (re-search-forward regexp limit t)))): Then I tried to construct a closure *after* adding a plain regexp to hi-lock-interactive-patterns, i.e. immediately in font-lock-add-keywords. But this poses another problem: it's not easy to find a closure by regexp in font-lock-keywords for removing a keyword by font-lock-remove-keywords in 'unhighlight-regexp'. I tried the patch below, and sometimes it works, but I know it's horribly ugly, and it's a wrong direction to search the regexp in the lexical environment of a closure. Maybe then better to add an intermediate mapping to hi-lock like there is in isearch: isearch-message vs isearch-string, where isearch-message is user-facing representaion, and isearch-string contains internal data. This could help to solve another existing problem of using hi-lock from isearch in char-fold mode, where unhighlight-regexp displays unreadable prompt too: Regexp to unhighlight (default \(?:ḟ\|[fᶠḟⓕf𝐟𝑓𝒇𝒻𝓯𝔣𝕗𝖋𝖿𝗳𝘧𝙛𝚏]\)): --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=hi-lock-remove-keywords.patch diff --git a/lisp/hi-lock.el b/lisp/hi-lock.el index de258935e1..9173b66b7f 100644 --- a/lisp/hi-lock.el +++ b/lisp/hi-lock.el @@ -625,7 +645,12 @@ hi-lock-unface-buffer ;; calls font-lock-set-defaults). This is yet-another bug in ;; font-lock-add/remove-keywords, which we circumvent here by ;; testing `font-lock-fontified' (bug#19796). - (if font-lock-fontified (font-lock-remove-keywords nil (list keyword))) + (when font-lock-fontified + (font-lock-remove-keywords nil (list keyword)) + (dolist (k font-lock-keywords) + (when (and (consp k) (consp (car k)) (eq (caar k) 'closure) + (equal (car keyword) (cdr (assq 'regexp (cadr (car k)))))) + (font-lock-remove-keywords nil (list k))))) (setq hi-lock-interactive-patterns (delq keyword hi-lock-interactive-patterns)) (remove-overlays @@ -728,7 +753,13 @@ hi-lock-set-pattern (push pattern hi-lock-interactive-patterns) (if (and font-lock-mode (font-lock-specified-p major-mode)) (progn - (font-lock-add-keywords nil (list pattern) t) + (font-lock-add-keywords + nil (list (cons + (lambda (limit) + (let ((case-fold-search case-fold)) + (re-search-forward (car pattern) limit t))) + (cdr pattern))) + t) (font-lock-flush)) (let* ((range-min (- (point) (/ hi-lock-highlight-range 2))) (range-max (+ (point) (/ hi-lock-highlight-range 2))) --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Mon Apr 06 20:40:30 2020 Received: (at 40337) by debbugs.gnu.org; 7 Apr 2020 00:40:30 +0000 Received: from localhost ([127.0.0.1]:49386 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jLcI1-00020J-PV for submit@debbugs.gnu.org; Mon, 06 Apr 2020 20:40:30 -0400 Received: from relay6-d.mail.gandi.net ([217.70.183.198]:47749) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jLcHz-0001zo-L6 for 40337@debbugs.gnu.org; Mon, 06 Apr 2020 20:40:28 -0400 X-Originating-IP: 91.129.99.85 Received: from mail.gandi.net (m91-129-99-85.cust.tele2.ee [91.129.99.85]) (Authenticated sender: juri@linkov.net) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id 387BDC0003; Tue, 7 Apr 2020 00:40:19 +0000 (UTC) From: Juri Linkov To: Stefan Monnier Subject: Re: bug#40337: 28.0.50; Enable case-fold-search in hi-lock Organization: LINKOV.NET References: <87a73xtsqw.fsf@mail.linkov.net> <87pncpa8il.fsf@mail.linkov.net> <87mu7ptsqm.fsf@mail.linkov.net> Date: Tue, 07 Apr 2020 03:08:11 +0300 In-Reply-To: <87mu7ptsqm.fsf@mail.linkov.net> (Juri Linkov's message of "Mon, 06 Apr 2020 02:12:13 +0300") Message-ID: <875zeci0zx.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 40337 Cc: 40337@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) --=-=-= Content-Type: text/plain > Maybe then better to add an intermediate mapping to hi-lock > like there is in isearch: isearch-message vs isearch-string, > where isearch-message is user-facing representaion, > and isearch-string contains internal data. This patch adds a new variable hi-lock-interactive-lighters (where the word 'lighter' refers to minor mode's lighters) that holds a mapping from either isearch-string or manually entered regexp to a closure used in font-lock-keywords: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=hi-lock-interactive-lighters.patch diff --git a/lisp/hi-lock.el b/lisp/hi-lock.el index de258935e1..abdf45a243 100644 --- a/lisp/hi-lock.el +++ b/lisp/hi-lock.el @@ -233,6 +233,10 @@ hi-lock-interactive-patterns "Patterns provided to hi-lock by user. Should not be changed.") (put 'hi-lock-interactive-patterns 'permanent-local t) +(defvar-local hi-lock-interactive-lighters nil + "Lighters for `hi-lock-interactive-patterns'.") +(put 'hi-lock-interactive-lighters 'permanent-local t) + (define-obsolete-variable-alias 'hi-lock-face-history 'hi-lock-face-defaults "23.1") (defvar hi-lock-face-defaults @@ -403,7 +407,8 @@ hi-lock-mode hi-lock-file-patterns) (when hi-lock-interactive-patterns (font-lock-remove-keywords nil hi-lock-interactive-patterns) - (setq hi-lock-interactive-patterns nil)) + (setq hi-lock-interactive-patterns nil + hi-lock-interactive-lighters nil)) (when hi-lock-file-patterns (font-lock-remove-keywords nil hi-lock-file-patterns) (setq hi-lock-file-patterns nil)) @@ -434,6 +439,9 @@ hi-lock-line-face-buffer Interactively, prompt for REGEXP using `read-regexp', then FACE. Use the global history list for FACE. +If REGEXP contains upper case characters (excluding those preceded by `\\') +and `search-upper-case' is non-nil, the matching is case-sensitive. + Use Font lock mode, if enabled, to highlight REGEXP. Otherwise, use overlays for highlighting. If overlays are used, the highlighting will not update as you type." @@ -447,19 +455,25 @@ hi-lock-line-face-buffer (hi-lock-set-pattern ;; The \\(?:...\\) grouping construct ensures that a leading ^, +, * or ? ;; or a trailing $ in REGEXP will be interpreted correctly. - (concat "^.*\\(?:" regexp "\\).*\\(?:$\\)\n?") face)) + (concat "^.*\\(?:" regexp "\\).*\\(?:$\\)\n?") face nil + (if (and case-fold-search search-upper-case) + (isearch-no-upper-case-p regexp t) + case-fold-search))) ;;;###autoload (defalias 'highlight-regexp 'hi-lock-face-buffer) ;;;###autoload -(defun hi-lock-face-buffer (regexp &optional face subexp) +(defun hi-lock-face-buffer (regexp &optional face subexp lighter) "Set face of each match of REGEXP to FACE. Interactively, prompt for REGEXP using `read-regexp', then FACE. Use the global history list for FACE. Limit face setting to the corresponding SUBEXP (interactively, the prefix argument) of REGEXP. If SUBEXP is omitted or nil, the entire REGEXP is highlighted. +If REGEXP contains upper case characters (excluding those preceded by `\\') +and `search-upper-case' is non-nil, the matching is case-sensitive. + Use Font lock mode, if enabled, to highlight REGEXP. Otherwise, use overlays for highlighting. If overlays are used, the highlighting will not update as you type." @@ -471,7 +485,12 @@ hi-lock-face-buffer current-prefix-arg)) (or (facep face) (setq face 'hi-yellow)) (unless hi-lock-mode (hi-lock-mode 1)) - (hi-lock-set-pattern regexp face subexp)) + (hi-lock-set-pattern + regexp face subexp + (if (and case-fold-search search-upper-case) + (isearch-no-upper-case-p regexp t) + case-fold-search) + lighter)) ;;;###autoload (defalias 'highlight-phrase 'hi-lock-face-phrase-buffer) @@ -507,6 +526,9 @@ hi-lock-face-symbol-at-point unless you use a prefix argument. Uses `find-tag-default-as-symbol-regexp' to retrieve the symbol at point. +If REGEXP contains upper case characters (excluding those preceded by `\\') +and `search-upper-case' is non-nil, the matching is case-sensitive. + This uses Font lock mode if it is enabled; otherwise it uses overlays, in which case the highlighting will not update as you type." (interactive) @@ -516,7 +538,11 @@ hi-lock-face-symbol-at-point (face (hi-lock-read-face-name))) (or (facep face) (setq face 'hi-yellow)) (unless hi-lock-mode (hi-lock-mode 1)) - (hi-lock-set-pattern regexp face))) + (hi-lock-set-pattern + regexp face nil + (if (and case-fold-search search-upper-case) + (isearch-no-upper-case-p regexp t) + case-fold-search)))) (defun hi-lock-keyword->face (keyword) (cadr (cadr (cadr keyword)))) ; Keyword looks like (REGEXP (0 'FACE) ...). @@ -586,12 +612,13 @@ hi-lock-unface-buffer 'keymap (cons "Select Pattern to Unhighlight" (mapcar (lambda (pattern) - (list (car pattern) + (list pattern (format - "%s (%s)" (car pattern) + "%s (%s)" (or (car (rassq pattern hi-lock-interactive-lighters)) + (car pattern)) (hi-lock-keyword->face pattern)) (cons nil nil) - (car pattern))) + pattern)) hi-lock-interactive-patterns)))) ;; If the user clicks outside the menu, meaning that they ;; change their mind, x-popup-menu returns nil, and @@ -606,13 +633,29 @@ hi-lock-unface-buffer ;; Infer the regexp to un-highlight based on cursor position. (let* ((defaults (or (hi-lock--regexps-at-point) (mapcar #'car hi-lock-interactive-patterns)))) + (setq defaults + (mapcar (lambda (default) + (or (car (rassq default + (mapcar (lambda (a) + (cons (car a) (cadr a))) + hi-lock-interactive-lighters))) + default)) + defaults)) (list (completing-read (if (null defaults) "Regexp to unhighlight: " (format "Regexp to unhighlight (default %s): " (car defaults))) - hi-lock-interactive-patterns + (mapcar (lambda (pattern) + (cons (or (car (rassq pattern hi-lock-interactive-lighters)) + (car pattern)) + (cdr pattern))) + hi-lock-interactive-patterns) nil t nil nil defaults)))))) + + (when (assoc regexp hi-lock-interactive-lighters) + (setq regexp (cadr (assoc regexp hi-lock-interactive-lighters)))) + (dolist (keyword (if (eq regexp t) hi-lock-interactive-patterns (list (assoc regexp hi-lock-interactive-patterns)))) (when keyword @@ -628,6 +671,8 @@ hi-lock-unface-buffer (if font-lock-fontified (font-lock-remove-keywords nil (list keyword))) (setq hi-lock-interactive-patterns (delq keyword hi-lock-interactive-patterns)) + (setq hi-lock-interactive-lighters + (rassq-delete-all keyword hi-lock-interactive-lighters)) (remove-overlays nil nil 'hi-lock-overlay-regexp (hi-lock--hashcons (car keyword))) (font-lock-flush)))) @@ -713,19 +758,23 @@ hi-lock-read-face-name (add-to-list 'hi-lock-face-defaults face t)) (intern face))) -(defun hi-lock-set-pattern (regexp face &optional subexp) +(defun hi-lock-set-pattern (regexp face &optional subexp case-fold lighter) "Highlight SUBEXP of REGEXP with face FACE. If omitted or nil, SUBEXP defaults to zero, i.e. the entire -REGEXP is highlighted." +REGEXP is highlighted. Non-nil CASE-FOLD ignores case." ;; Hashcons the regexp, so it can be passed to remove-overlays later. (setq regexp (hi-lock--hashcons regexp)) (setq subexp (or subexp 0)) - (let ((pattern (list regexp (list subexp (list 'quote face) 'prepend))) + (let ((pattern (list (lambda (limit) + (let ((case-fold-search case-fold)) + (re-search-forward regexp limit t))) + (list subexp (list 'quote face) 'prepend))) (no-matches t)) ;; Refuse to highlight a text that is already highlighted. (if (assoc regexp hi-lock-interactive-patterns) (add-to-list 'hi-lock--unused-faces (face-name face)) (push pattern hi-lock-interactive-patterns) + (push (cons (or lighter regexp) pattern) hi-lock-interactive-lighters) (if (and font-lock-mode (font-lock-specified-p major-mode)) (progn (font-lock-add-keywords nil (list pattern) t) @@ -737,7 +786,8 @@ hi-lock-set-pattern (- range-min (max 0 (- range-max (point-max)))))) (search-end (min (point-max) - (+ range-max (max 0 (- (point-min) range-min)))))) + (+ range-max (max 0 (- (point-min) range-min))))) + (case-fold-search case-fold)) (save-excursion (goto-char search-start) (while (re-search-forward regexp search-end t) @@ -751,7 +801,9 @@ hi-lock-set-pattern (when no-matches (add-to-list 'hi-lock--unused-faces (face-name face)) (setq hi-lock-interactive-patterns - (cdr hi-lock-interactive-patterns))))))))) + (cdr hi-lock-interactive-patterns) + hi-lock-interactive-lighters + (cdr hi-lock-interactive-lighters))))))))) (defun hi-lock-set-file-patterns (patterns) "Replace file patterns list with PATTERNS and refontify." diff --git a/lisp/isearch.el b/lisp/isearch.el index 7625ec12b5..9038c5e67b 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el @@ -2382,22 +2382,12 @@ isearch--highlight-regexp-or-lines (funcall isearch-regexp-function isearch-string)) (isearch-regexp-function (word-search-regexp isearch-string)) (isearch-regexp isearch-string) - ((if (and (eq isearch-case-fold-search t) - search-upper-case) - (isearch-no-upper-case-p - isearch-string isearch-regexp) - isearch-case-fold-search) - ;; Turn isearch-string into a case-insensitive - ;; regexp. - (mapconcat - (lambda (c) - (let ((s (string c))) - (if (string-match "[[:alpha:]]" s) - (format "[%s%s]" (upcase s) (downcase s)) - (regexp-quote s)))) - isearch-string "")) (t (regexp-quote isearch-string))))) - (funcall hi-lock-func regexp (hi-lock-read-face-name))) + (let ((case-fold-search isearch-case-fold-search) + ;; Set `search-upper-case' to nil to not call + ;; `isearch-no-upper-case-p' in `hi-lock'. + (search-upper-case nil)) + (funcall hi-lock-func regexp (hi-lock-read-face-name) isearch-string))) (and isearch-recursive-edit (exit-recursive-edit))) (defun isearch-highlight-regexp () @@ -2405,14 +2395,18 @@ isearch-highlight-regexp The arguments passed to `highlight-regexp' are the regexp from the last search and the face from `hi-lock-read-face-name'." (interactive) - (isearch--highlight-regexp-or-lines 'highlight-regexp)) + (isearch--highlight-regexp-or-lines + #'(lambda (regexp face lighter) + (highlight-regexp regexp face nil lighter)))) (defun isearch-highlight-lines-matching-regexp () "Exit Isearch mode and call `highlight-lines-matching-regexp'. The arguments passed to `highlight-lines-matching-regexp' are the regexp from the last search and the face from `hi-lock-read-face-name'." (interactive) - (isearch--highlight-regexp-or-lines 'highlight-lines-matching-regexp)) + (isearch--highlight-regexp-or-lines + #'(lambda (regexp face _lighter) + (highlight-lines-matching-regexp regexp face)))) (defun isearch-delete-char () --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Mon Apr 06 23:33:42 2020 Received: (at 40337) by debbugs.gnu.org; 7 Apr 2020 03:33:42 +0000 Received: from localhost ([127.0.0.1]:49425 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jLeze-00034O-7J for submit@debbugs.gnu.org; Mon, 06 Apr 2020 23:33:42 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:10768) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jLezb-00033w-Li for 40337@debbugs.gnu.org; Mon, 06 Apr 2020 23:33:40 -0400 Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 68BE7100B69; Mon, 6 Apr 2020 23:33:34 -0400 (EDT) Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 44167100B45; Mon, 6 Apr 2020 23:33:32 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1586230412; bh=khTcxYQMRP9K/3yoTiZlLD6aHdSPzD4lRsNyFphkIwQ=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=GduTstdIkZ+toL9JxopgqphSAJxepzstGEoCz0WecHC5oOXLwhV5Y2BC076InuLNY 7dYOxBFCi160PVe3Mx+g85du4OlsrhD7O/zPJN72VrswHrqnugd7zZ0+nyMI7+kFFc eRj95RarTrlv/t/7TqI48X5WODVI9WGTWfku7PP6DFNFiRCkO1F5euZ8sklnKvFfdg LurVjuaT4MhYiWbYnV7hqn+7sWtoec1BIhsM+8IojymJg/cyKJt23YdE1X2mAcNUjJ RiNIPzmNNPUwfPyggY0ZbsjwhcF+982101GxqdYf+6ryuSbmrYSXUwfyJXsUgKAgYT NbIWOZWr4eKHA== Received: from alfajor (unknown [104.247.241.114]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id BEFC81203C7; Mon, 6 Apr 2020 23:33:31 -0400 (EDT) From: Stefan Monnier To: Juri Linkov Subject: Re: bug#40337: 28.0.50; Enable case-fold-search in hi-lock Message-ID: References: <87a73xtsqw.fsf@mail.linkov.net> <87pncpa8il.fsf@mail.linkov.net> <87mu7ptsqm.fsf@mail.linkov.net> Date: Mon, 06 Apr 2020 23:33:30 -0400 In-Reply-To: <87mu7ptsqm.fsf@mail.linkov.net> (Juri Linkov's message of "Mon, 06 Apr 2020 02:12:13 +0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL 0.146 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 40337 Cc: 40337@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > Maybe then better to add an intermediate mapping to hi-lock > like there is in isearch: isearch-message vs isearch-string, > where isearch-message is user-facing representaion, > and isearch-string contains internal data. Sounds good. Stefan From debbugs-submit-bounces@debbugs.gnu.org Sat Apr 11 19:46:29 2020 Received: (at 40337) by debbugs.gnu.org; 11 Apr 2020 23:46:29 +0000 Received: from localhost ([127.0.0.1]:57188 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jNPpV-0000rb-En for submit@debbugs.gnu.org; Sat, 11 Apr 2020 19:46:29 -0400 Received: from relay2-d.mail.gandi.net ([217.70.183.194]:48321) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jNPpU-0000r8-8C; Sat, 11 Apr 2020 19:46:28 -0400 X-Originating-IP: 91.129.99.85 Received: from mail.gandi.net (m91-129-99-85.cust.tele2.ee [91.129.99.85]) (Authenticated sender: juri@linkov.net) by relay2-d.mail.gandi.net (Postfix) with ESMTPSA id AA34840006; Sat, 11 Apr 2020 23:46:20 +0000 (UTC) From: Juri Linkov To: Stefan Monnier Subject: Re: bug#40337: 28.0.50; Enable case-fold-search in hi-lock Organization: LINKOV.NET References: <87a73xtsqw.fsf@mail.linkov.net> <87pncpa8il.fsf@mail.linkov.net> <87mu7ptsqm.fsf@mail.linkov.net> Date: Sun, 12 Apr 2020 02:45:16 +0300 In-Reply-To: (Stefan Monnier's message of "Mon, 06 Apr 2020 23:33:30 -0400") Message-ID: <871rot37ub.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 40337 Cc: 40337@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) tags 40337 fixed close 40337 28.0.50 quit >> Maybe then better to add an intermediate mapping to hi-lock >> like there is in isearch: isearch-message vs isearch-string, >> where isearch-message is user-facing representaion, >> and isearch-string contains internal data. > > Sounds good. So I pushed everything to master. From debbugs-submit-bounces@debbugs.gnu.org Sat Apr 11 23:18:02 2020 Received: (at 40337) by debbugs.gnu.org; 12 Apr 2020 03:18:02 +0000 Received: from localhost ([127.0.0.1]:57265 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jNT8E-0007sS-Av for submit@debbugs.gnu.org; Sat, 11 Apr 2020 23:18:02 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:44866) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jNT8C-0007s3-8U for 40337@debbugs.gnu.org; Sat, 11 Apr 2020 23:18:01 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 0D95D160054; Sat, 11 Apr 2020 20:17:54 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id VwpBNduE8_Gq; Sat, 11 Apr 2020 20:17:53 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 2784C160068; Sat, 11 Apr 2020 20:17:53 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id kSVy7LUiTZYc; Sat, 11 Apr 2020 20:17:53 -0700 (PDT) Received: from [192.168.1.9] (cpe-23-242-74-103.socal.res.rr.com [23.242.74.103]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id E12CF160054; Sat, 11 Apr 2020 20:17:52 -0700 (PDT) To: Juri Linkov From: Paul Eggert Subject: Re: bug#40337: 28.0.50; Enable case-fold-search in hi-lock Organization: UCLA Computer Science Department Message-ID: <578c8ddc-220d-0fed-7ddf-844c27317101@cs.ucla.edu> Date: Sat, 11 Apr 2020 20:17:49 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 40337 Cc: 40337@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > So I pushed everything to master. This change causes the hi-lock-bug26666 test to fail on my Fedora 31 x86-64 host. (cd test && make lisp/hi-lock-tests) outputs: make[1]: Entering directory '/home/eggert/src/gnu/emacs/static-checking/test' GEN lisp/hi-lock-tests.log Running 2 tests (2020-04-11 20:16:12-0700, selector `(not (tag :unstable))') Test hi-lock-bug26666 backtrace: signal(ert-test-failed (((should (equal hi-lock--unused-faces (cdr f ert-fail(((should (equal hi-lock--unused-faces (cdr faces))) :form ( (if (unwind-protect (setq value-2 (apply fn-0 args-1)) (setq form-de (let (form-description-4) (if (unwind-protect (setq value-2 (apply f (let ((value-2 'ert-form-evaluation-aborted-3)) (let (form-descripti (let* ((fn-0 #'equal) (args-1 (condition-case err (let ((signal-hook (progn (insert "a A b B\n") (let* ((vnew #'(lambda (_prompt _coll _x (unwind-protect (progn (insert "a A b B\n") (let* ((vnew #'(lambda ( (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (let ((temp-buffer (generate-new-buffer " *temp*"))) (save-current-b (let ((faces hi-lock-face-defaults)) (let ((temp-buffer (generate-ne (closure (t) nil (let ((faces hi-lock-face-defaults)) (let ((temp-bu ert--run-test-internal(#s(ert--test-execution-info :test #s(ert-test ert-run-test(#s(ert-test :name hi-lock-bug26666 :documentation "Test ert-run-or-rerun-test(#s(ert--stats :selector (not (tag :unstable)) ert-run-tests((not (tag :unstable)) #f(compiled-function (event-type ert-run-tests-batch((not (tag :unstable))) ert-run-tests-batch-and-exit((not (tag :unstable))) eval((ert-run-tests-batch-and-exit '(not (tag :unstable))) t) command-line-1(("-L" ":." "-l" "ert" "-l" "lisp/hi-lock-tests.el" "- command-line() normal-top-level() Test hi-lock-bug26666 condition: (ert-test-failed ((should (equal hi-lock--unused-faces (cdr faces))) :form (equal ("hi-green" "hi-blue" "hi-salmon" "hi-aquamarine" "hi-black-b" "hi-blue-b" "hi-red-b" "hi-green-b" "hi-black-hb") ("hi-pink" "hi-green" "hi-blue" "hi-salmon" "hi-aquamarine" "hi-black-b" "hi-blue-b" "hi-red-b" "hi-green-b" "hi-black-hb")) :value nil :explanation (proper-lists-of-different-length 9 10 ("hi-green" "hi-blue" "hi-salmon" "hi-aquamarine" "hi-black-b" "hi-blue-b" "hi-red-b" "hi-green-b" "hi-black-hb") ("hi-pink" "hi-green" "hi-blue" "hi-salmon" "hi-aquamarine" "hi-black-b" "hi-blue-b" "hi-red-b" "hi-green-b" "hi-black-hb") first-mismatch-at 0))) FAILED 1/2 hi-lock-bug26666 (0.000209 sec) passed 2/2 hi-lock-test-set-pattern (0.000104 sec) Ran 2 tests, 1 results as expected, 1 unexpected (2020-04-11 20:16:13-0700, 0.102481 sec) 1 unexpected results: FAILED hi-lock-bug26666 Makefile:182: recipe for target 'lisp/hi-lock-tests.log' failed make[1]: *** [lisp/hi-lock-tests.log] Error 1 make[1]: Leaving directory '/home/eggert/src/gnu/emacs/static-checking/test' Makefile:248: recipe for target 'lisp/hi-lock-tests' failed make: *** [lisp/hi-lock-tests] Error 2 From debbugs-submit-bounces@debbugs.gnu.org Sun Apr 12 19:42:34 2020 Received: (at 40337) by debbugs.gnu.org; 12 Apr 2020 23:42:35 +0000 Received: from localhost ([127.0.0.1]:59023 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jNmFG-0006qS-OG for submit@debbugs.gnu.org; Sun, 12 Apr 2020 19:42:34 -0400 Received: from relay5-d.mail.gandi.net ([217.70.183.197]:33211) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jNmFE-0006qE-3o for 40337@debbugs.gnu.org; Sun, 12 Apr 2020 19:42:33 -0400 X-Originating-IP: 91.129.99.85 Received: from mail.gandi.net (m91-129-99-85.cust.tele2.ee [91.129.99.85]) (Authenticated sender: juri@linkov.net) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 7BCCE1C0003; Sun, 12 Apr 2020 23:42:23 +0000 (UTC) From: Juri Linkov To: Paul Eggert Subject: Re: bug#40337: 28.0.50; Enable case-fold-search in hi-lock Organization: LINKOV.NET References: <578c8ddc-220d-0fed-7ddf-844c27317101@cs.ucla.edu> Date: Mon, 13 Apr 2020 02:41:55 +0300 In-Reply-To: <578c8ddc-220d-0fed-7ddf-844c27317101@cs.ucla.edu> (Paul Eggert's message of "Sat, 11 Apr 2020 20:17:49 -0700") Message-ID: <87sgh8clvg.fsf@mail.linkov.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 40337 Cc: 40337@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) > This change causes the hi-lock-bug26666 test to fail on my Fedora 31 x86-64 > host. (cd test && make lisp/hi-lock-tests) outputs: Oh, I completely forgot there is a test for hi-lock added in bug#26666. Now fixed this test, and also added a new test specially for case-fold. From unknown Wed Jun 18 23:09:36 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Mon, 11 May 2020 11:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator