From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#22541: 25.0.50; highlight-regexp from isearch has is case-sensitive even if case-fold is active Date: Tue, 25 Apr 2017 23:52:06 +0300 Organization: LINKOV.NET Message-ID: <87mvb4yzux.fsf@localhost> References: <87si1a2tod.fsf@secretsauce.net> <8760x7vyui.fsf@mail.linkov.net> <87vapwipy4.fsf@calancha-pc> <87shkyems1.fsf@localhost> <87pog112pp.fsf@calancha-pc> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1493153959 12104 195.159.176.226 (25 Apr 2017 20:59:19 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 25 Apr 2017 20:59:19 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (x86_64-pc-linux-gnu) Cc: 22541@debbugs.gnu.org, Dima Kogan To: Tino Calancha Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Apr 25 22:59:14 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d37YG-0002zy-06 for geb-bug-gnu-emacs@m.gmane.org; Tue, 25 Apr 2017 22:59:12 +0200 Original-Received: from localhost ([::1]:51365 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d37YL-0007fK-Fm for geb-bug-gnu-emacs@m.gmane.org; Tue, 25 Apr 2017 16:59:17 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40172) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d37Y9-0007dT-UV for bug-gnu-emacs@gnu.org; Tue, 25 Apr 2017 16:59:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d37Y6-00041A-SG for bug-gnu-emacs@gnu.org; Tue, 25 Apr 2017 16:59:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:41976) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d37Y6-000416-PW for bug-gnu-emacs@gnu.org; Tue, 25 Apr 2017 16:59:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1d37Y6-00048n-Gg for bug-gnu-emacs@gnu.org; Tue, 25 Apr 2017 16:59: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, 25 Apr 2017 20:59:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22541 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 22541-submit@debbugs.gnu.org id=B22541.149315391515874 (code B ref 22541); Tue, 25 Apr 2017 20:59:02 +0000 Original-Received: (at 22541) by debbugs.gnu.org; 25 Apr 2017 20:58:35 +0000 Original-Received: from localhost ([127.0.0.1]:40173 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d37Xf-00047y-1L for submit@debbugs.gnu.org; Tue, 25 Apr 2017 16:58:35 -0400 Original-Received: from sub3.mail.dreamhost.com ([69.163.253.7]:47685 helo=homiemail-a17.g.dreamhost.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d37Xc-00047j-La for 22541@debbugs.gnu.org; Tue, 25 Apr 2017 16:58:33 -0400 Original-Received: from homiemail-a17.g.dreamhost.com (localhost [127.0.0.1]) by homiemail-a17.g.dreamhost.com (Postfix) with ESMTP id 9CD892B207F; Tue, 25 Apr 2017 13:58:30 -0700 (PDT) Original-Received: from localhost.linkov.net (m83-179-141-227.cust.tele2.ee [83.179.141.227]) (Authenticated sender: jurta@jurta.org) by homiemail-a17.g.dreamhost.com (Postfix) with ESMTPA id 8BEB92B207D; Tue, 25 Apr 2017 13:58:29 -0700 (PDT) In-Reply-To: <87pog112pp.fsf@calancha-pc> (Tino Calancha's message of "Tue, 25 Apr 2017 14:22:10 +0900") 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: 208.118.235.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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:131981 Archived-At: > I updated the patch to make work `hi-lock-unface-buffer'. I added test= s > as well. > > Note that in interactive calls the case fold is determined with the > variables `search-upper-case' and `case-fold-search'. This way it beha= ves > as `isearch-forward-regexp'. > Before this bug case fold was determined _just_ with `case-fold-search'= . > Do you prefer avoid `search-upper-case' in this case? Since =E2=80=98search-upper-case=E2=80=99 is used by other commands such = as =E2=80=98occur=E2=80=99 and =E2=80=98perform-replace=E2=80=99, I think =E2=80=98hi-lock=E2=80=99 shou= ld use it as well. >>>From 7cad27c0fcc39add8679d0893010c4fdb3ed507a Mon Sep 17 00:00:00 2001 > From: Juri Linkov > Date: Tue, 25 Apr 2017 14:17:23 +0900 > Subject: [PATCH] highlight-regexp: Honor case-fold-search > ... > Co-authored-by: Tino Calancha I recommend to commit first my old patch, and then later your changes ove= r it. > -(defun hi-lock-face-buffer (regexp &optional face) > +(defun hi-lock-face-buffer (regexp &optional face case-fold) > ... > + (let* ((reg > + (hi-lock-regexp-okay > + (read-regexp "Regexp to highlight" 'regexp-history-last))) > + (face (hi-lock-read-face-name)) > + (fold > + (if search-upper-case > + (isearch-no-upper-case-p reg t) > + case-fold-search))) > + (list reg face fold))) Small thing, but for readability in the interactive spec better to use the same variable names as argument names: (list regexp face case-fold) > -(defun hi-lock-set-pattern (regexp face) > - "Highlight REGEXP with face FACE." > +(defun hi-lock-set-pattern (regexp face &optional case-fold) > + "Highlight REGEXP with face FACE. > +If optional arg CASE-FOLD is non-nil, then bind `case-fold-search' to = it." > ;; Hashcons the regexp, so it can be passed to remove-overlays later= . > (setq regexp (hi-lock--hashcons regexp)) > - (let ((pattern (list regexp (list 0 (list 'quote face) 'prepend)))) > + (let ((pattern (list (if (eq case-fold 'undefined) > + regexp > + (cons regexp > + (byte-compile > + `(lambda (limit) > + (let ((case-fold-search ,case-fold)) > + (re-search-forward ,regexp limit t)))))= ) > + (list 0 (list 'quote face) 'prepend)))) Do you need to remember also the value of =E2=80=98case-fold-search=E2=80= =99 (together with =E2=80=98regexp=E2=80=99)? > @@ -1950,7 +1950,12 @@ isearch-highlight-regexp > (regexp-quote s)))) > isearch-string "")) > (t (regexp-quote isearch-string))))) > - (hi-lock-face-buffer regexp (hi-lock-read-face-name))) > + (hi-lock-face-buffer regexp (hi-lock-read-face-name) > + (if (and (eq isearch-case-fold-search t) > + search-upper-case) > + (isearch-no-upper-case-p > + isearch-string isearch-regexp) > + isearch-case-fold-search))) > (and isearch-recursive-edit (exit-recursive-edit))) If this works reliably, then we could remove that ugly hack from =E2=80=98isearch-highlight-regexp=E2=80=99, I mean the one with the = comment =E2=80=9CTurn isearch-string into a case-insensitive regexp=E2=80=9D.