GNU bug report logs - #50766
Regexp paren pairs in query-replace-regexp prompt should be highlighted

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Severity: wishlist; Reported by: ndame <laszlomail@HIDDEN>; dated Thu, 23 Sep 2021 17:01:01 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 50766 <at> debbugs.gnu.org:


Received: (at 50766) by debbugs.gnu.org; 2 Oct 2021 09:02:07 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Oct 02 05:02:07 2021
Received: from localhost ([127.0.0.1]:57812 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mWauF-0003DK-Er
	for submit <at> debbugs.gnu.org; Sat, 02 Oct 2021 05:02:07 -0400
Received: from quimby.gnus.org ([95.216.78.240]:35054)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <larsi@HIDDEN>) id 1mWauD-0003Cn-8r
 for 50766 <at> debbugs.gnu.org; Sat, 02 Oct 2021 05:02:06 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org;
 s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date:
 References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:
 Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender:
 Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:
 List-Subscribe:List-Post:List-Owner:List-Archive;
 bh=YsOFNR9AQpVh0NgOUXgZJb9fBl6/FlDFwC/t2UMTALw=; b=LVFxyM5r3HastoQkm1F7uiEYkK
 pMqqyvZPaR6V52leaA8mu4tgpmg8d+7n5bxzcajc2HFf35JXaxrHlqo/t3mcVEKOi8SnVNwt/gff4
 cWw75wkoi/9HudwaYT2F5z23hrphigmRj45Ji1v0ZL5FbtxCfgg8D7lxndLFnJUaL8DQ=;
Received: from [84.212.220.105] (helo=elva)
 by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.92) (envelope-from <larsi@HIDDEN>)
 id 1mWau4-0005PP-UI; Sat, 02 Oct 2021 11:01:59 +0200
From: Lars Ingebrigtsen <larsi@HIDDEN>
To: martin rudalics <rudalics@HIDDEN>
Subject: Re: bug#50766: Regexp paren pairs in query-replace-regexp prompt
 should be highlighted
References: <1LWmgMt-iOZcz0k2N5IVTqgDu922CLEd8GATVBsqdQfVeBzIGEaVuORC9k0SXORQDkpqc8BO3zxOPFbQeMMhNHQmOvcvIOpOpoWL8CAVUq8=@protonmail.com>
 <87bl4jxacl.fsf@HIDDEN>
 <atDsN91XbGZS6ecbC5yOWe2GothSwxFFxxiDQzgAxgA667yjW5TBvcbMYRWgfxfdqJ5D5MnndE5Ac-Kcg9J4DFBlNWZq-gTyPYiMCSQqGAo=@protonmail.com>
 <877df5tqyj.fsf@HIDDEN>
 <oTLxP6KkO1yT3-D-VFh7hv5OTCQhVkuuQkMJfBrhT-0iM_ABsCci7cZzLcFgv-FDCJYP5Swz7d6e7-JtFj4nNeIR0RVdQiH1naGihdidELc=@protonmail.com>
 <87h7e5gtk0.fsf@HIDDEN>
 <f5746c2c-81f7-f3a0-773e-937a42dcc84b@HIDDEN>
 <87ilyhw6si.fsf@HIDDEN>
 <a708f0e1-c716-1643-24bf-4ba7038100b2@HIDDEN>
Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAACBj
 SFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAG1BMVEV9aoWzs7nd3OP8
 /Pikq9OVPGRPXqGau0f///87stifAAAAAWJLR0QIht6VegAAAAd0SU1FB+UKAgg4JE9r+SkAAAGw
 SURBVDjLlZSxbuMwDIaVwPZsuclljSi23e17ADdHeI4H3eweUu42Cuj1S6aFqhTxcBoChJ+o/ycp
 2Wws6Op+LmPvhgU0AL67D+7GFXQrwP8vWIl3RtZmR/QH6ARHa20CIYTzX+YTDESP8icBfhNABMDy
 sw9jAgOX56DVK8DyIYFfTDacAFBB1h1zluPDFuCJL7fA2gbqB68xmzfBxBhnyXAtQF02cPQ3YARN
 8ftgQg6Wuhyv02r3IQezhMrt73L00GbgEHUvnqXqEY5jmYCTs1vwrjZ2AzW45EpFn+fDUvVMSJS6
 rTOH2LiF+6nY9QXllyE24JaKiAbmSwI7OIgt9z5MRLuKOQGykoA0E6sGc9KwcQE3Y8SBtyiH+cyV
 yLgFdLZ5dxvQ0t0s0pPYzVwdYvMJqKccvFx7hQpOYvdbI2qCuhIgBjIgCYgUUQFmrj7fjTqTecie
 pHHRnXLhUJXEWsqohEjB/9Qq9pmGYXqRghXTjauCpyuopooVfN/2il8FTBITkM1jY/tX7E0hZRdI
 Wa/SLf75cNaBXwHrz3ntA7C9Tq31d4FfA53mtF+Rry0fCyDtq2U8hFsAAAAldEVYdGRhdGU6Y3Jl
 YXRlADIwMjEtMTAtMDJUMDg6NTY6MzYrMDA6MDAyZiGmAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDIx
 LTEwLTAyVDA4OjU2OjM2KzAwOjAwQzuZGgAAAABJRU5ErkJggg==
X-Now-Playing: Liquid Liquid's _Cavern Remix_: "Scraper (Psychonauts Remix)"
Date: Sat, 02 Oct 2021 11:01:56 +0200
In-Reply-To: <a708f0e1-c716-1643-24bf-4ba7038100b2@HIDDEN> (martin rudalics's
 message of "Fri, 1 Oct 2021 17:00:03 +0200")
Message-ID: <87k0ivvlyz.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 @@CONTACT_ADDRESS@@ for details.
 Content preview: martin rudalics <rudalics@HIDDEN> writes: > With
 'blink-matching-paren'
 on do C-M-% and type [)]. People who use > 'blink-matching-paren' do not
 type complex regexps. We do indeed -- we just live with the bogus warnings
 from Emacs. 
 Content analysis details:   (-2.9 points, 5.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -1.0 ALL_TRUSTED            Passed through trusted hosts only via SMTP
 -1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%
 [score: 0.0000]
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 50766
Cc: ndame <laszlomail@HIDDEN>, 50766 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

martin rudalics <rudalics@HIDDEN> writes:

> With 'blink-matching-paren' on do C-M-% and type [)].  People who use
> 'blink-matching-paren' do not type complex regexps.

We do indeed -- we just live with the bogus warnings from Emacs.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#50766; Package emacs. Full text available.

Message received at 50766 <at> debbugs.gnu.org:


Received: (at 50766) by debbugs.gnu.org; 1 Oct 2021 15:00:32 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Oct 01 11:00:32 2021
Received: from localhost ([127.0.0.1]:57097 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mWK1V-0006k4-PK
	for submit <at> debbugs.gnu.org; Fri, 01 Oct 2021 11:00:32 -0400
Received: from mout.gmx.net ([212.227.15.19]:38971)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <rudalics@HIDDEN>) id 1mWK1R-0006jp-BX
 for 50766 <at> debbugs.gnu.org; Fri, 01 Oct 2021 11:00:28 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net;
 s=badeba3b8450; t=1633100417;
 bh=mYWjGjhUXTmKg3jQuNHj7pBdFrU8qz66BSwkiS2ZDd8=;
 h=X-UI-Sender-Class:Subject:To:Cc:References:From:Date:In-Reply-To;
 b=GUnYX5GM7899fCrPC/mWkdsgZrj6zAfagTpigtinwDfI69vVAx7bUhwTEBrkhNYMC
 mIhsIbrH8/iRBTMTI504VS5keQrjYlWzhVSPv1RI0u7nycmlTXxmjq5sDTKS5LFxhL
 QLrbjSFCFJfR460j2gfUHFfjaLyM9VA8rqs+wMaA=
X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c
Received: from [192.168.1.102] ([212.95.5.169]) by mail.gmx.net (mrgmx005
 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MWzfv-1mL6qH2VGj-00XJn4; Fri, 01
 Oct 2021 17:00:16 +0200
Subject: Re: bug#50766: Regexp paren pairs in query-replace-regexp prompt
 should be highlighted
To: ndame <laszlomail@HIDDEN>, Lars Ingebrigtsen <larsi@HIDDEN>
References: <1LWmgMt-iOZcz0k2N5IVTqgDu922CLEd8GATVBsqdQfVeBzIGEaVuORC9k0SXORQDkpqc8BO3zxOPFbQeMMhNHQmOvcvIOpOpoWL8CAVUq8=@protonmail.com>
 <87bl4jxacl.fsf@HIDDEN>
 <atDsN91XbGZS6ecbC5yOWe2GothSwxFFxxiDQzgAxgA667yjW5TBvcbMYRWgfxfdqJ5D5MnndE5Ac-Kcg9J4DFBlNWZq-gTyPYiMCSQqGAo=@protonmail.com>
 <877df5tqyj.fsf@HIDDEN>
 <oTLxP6KkO1yT3-D-VFh7hv5OTCQhVkuuQkMJfBrhT-0iM_ABsCci7cZzLcFgv-FDCJYP5Swz7d6e7-JtFj4nNeIR0RVdQiH1naGihdidELc=@protonmail.com>
 <87h7e5gtk0.fsf@HIDDEN> <f5746c2c-81f7-f3a0-773e-937a42dcc84b@HIDDEN>
 <87ilyhw6si.fsf@HIDDEN>
 <1yqlcMml0l3wVdGLY1Z2JY5i9dsiJwkc19jcWETHoeEhfraWDi2lKO8u9B3wKdVZ6wJxOF3eTe4DJd-qq-jMAJ-kiIpyMqanJNYdhmrLZ2g=@protonmail.com>
From: martin rudalics <rudalics@HIDDEN>
Message-ID: <bd2e0a87-1029-fdbf-4978-51018bc2f854@HIDDEN>
Date: Fri, 1 Oct 2021 17:00:15 +0200
MIME-Version: 1.0
In-Reply-To: <1yqlcMml0l3wVdGLY1Z2JY5i9dsiJwkc19jcWETHoeEhfraWDi2lKO8u9B3wKdVZ6wJxOF3eTe4DJd-qq-jMAJ-kiIpyMqanJNYdhmrLZ2g=@protonmail.com>
Content-Type: multipart/mixed; boundary="------------A908D8939D78C4D46252684E"
Content-Language: en-US
X-Provags-ID: V03:K1:UcHvEc/GQ5YhHgBDdvlsbA1fSZZdnrLHZ8pbP0xsuffYyof5f+3
 mkTh+2Mj24S2/b+PQqecixfyI8r1W3TfApo8sSQqf1iK9WmYGi7rY8ZVLn6395A9bLy820K
 cjFwPnPVP/pSeEeqkXdMq1kVD3YSD4gG1obVnQMugBVpWMbKGiDuOW2nU1dCPKIJZIqT9qu
 A8G4dIkcpBos/0wc+5zVA==
X-Spam-Flag: NO
X-UI-Out-Filterresults: notjunk:1;V03:K0:6a77ar1VKM0=:EZy8cqrdZkRJk34ie/zWDD
 fRuTLn8xfz2gNGYOE3Zl+XzWbDQ5Lp1FdzzUiT0UV9PRmYDRj1asrvJE2OVh9I+zc7+stEIuE
 adS0YoWqU5LYqoWeEKQnklkpKmKGCtJ23mQArHDbP5/K38g8H/D3zqEpfS9j2nQynRdNUIelo
 tRbmBnxBSm+sdWT19ab/jF7RubXJxEBNz3xlOjJcMuNe93KNqmHKfZyeKmp6IZZSzWh6+8hvr
 bSFp+b9h2G9tEnKC+34n8y1JMkLkjhmRJkixgY3Lyu7HFaEt5ghloscqBOPoO/I4Fydp4ubCS
 5p1bKAmRGZDMZ70lT/cSgdSlyINW3K4W571oIvxCJL06Ko6uKMkm8ItgYUk9Y/V8vJcsOTsC2
 OpFxD1KunIHe2H1A7EEw0qaG0HOgY9iyFHqd74//0/086c1hZzAqtFagxLlUzW3xZ0vgy72wG
 ZbRrTzZ7oBnT6fdizBvaE+OlIuqbKF+TDfHE8U+OUDqmC6iy9Q4kWleZ/w+D3PFE3vPcXpCq3
 jepH/acwuwHDd9hfkCBGAfxB05Fs+MDZsTCausPsOzL4ZT40xusppPvSoazAdO8WKLt4x24CJ
 joJhNxTmV2aoD6u7eIfAqsFDjRIbxrWXKgpbB5OkRuKWOqTmdoqgwxZeWWU2IK7ji6hCmR2Wd
 6xSXNnsPy9BmahtCF3JiXPgPaJv3VvxyPK54k0iQFr7qFSc+2jPS+QrkKvgQ2WOzDgg9j1Uo/
 jambWphNDpQWksOgf49KU0IliLGrJLBcmFQp/Eex/ZSczTzNir06McbJfCBUd7AXa3/OOZlBU
 Q6MxkRS26rPLeBJKeX3PB9GoYk/DvsjZV+lfOVASK5CBBw6KhmTidgQGmvk0znX1LsK9sLq4P
 4bwXyVRIia6Ta33a6tAPEU96E1DB98pRkIU31nguEq3Q7IGVau/0iV/+H8+3bLLWWAyKECPcE
 gPfTEAOBx6GzK39QTC+wZP4QXLj5I4VG1u0ERHcVSh/56u/71UzY/MxRVpRzxOm8Qsdnfdlfa
 6YsgEVW19W5BGG0FOmGJgLUoxVI1ggwRDXZN3HBw1mziLWwW9sNDi/xBW6jOm01fyDIsHeZDn
 5H66QKj7/jUBl0=
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 50766
Cc: 50766 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

This is a multi-part message in MIME format.
--------------A908D8939D78C4D46252684E
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit

 > I wonder if it could be a generic feature which besides working in the
 > minibuffer for regexps would also work when typing escaped parens in
 > in strings, e.g. when using a string regexp in a program:
 >
 >     "stuff ( \\(  ) "
 >
 > Here it could indicate the mismatching parens.

I can only offer you my old regexp-lock-mode (attached).  In an .el
buffer do M-x turn-on-regexp-lock-mode and tell me how it works.

martin

--------------A908D8939D78C4D46252684E
Content-Type: text/x-emacs-lisp;
 name="regexp-lock.el"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="regexp-lock.el"

;;; regexp-lock.el --- minor mode for highlighting Emacs Lisp regexps

;; Copyright (C) 2005 Martin Rudalics

;; Time-stamp: "2021-10-01 12:10:57 martin"
;; Author: Martin Rudalics <rudalics@HIDDEN>
;; Keywords: regular expressions
;; Version: 0.1

;; regexp-lock.el is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.

;; regexp-lock.el is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;;; Commentary:

;; Regexp Lock is a minor mode for highlighting regular expressions in Emacs
;; Lisp mode.

;; `regexp-lock-mode' turns on/off Regexp Lock in the current buffer.  For
;; further information consult the documentation of `regexp-lock-mode'.

;; To turn on Regexp Lock in any Emacs Lisp file you open, add the lines
;;   (require 'regexp-lock)
;;   (add-hook 'emacs-lisp-mode-hook 'turn-on-regexp-lock-mode)
;; to your .emacs.

;;; Code:

;; _____________________________________________________________________________
;;
;;;                      Faces and customizable variables
;; _____________________________________________________________________________
;;
(defgroup regexp-lock nil
  "Highlight regular expressions in Lisp modes."
  :version "22.1"
  :group 'font-lock)

(defface regexp-lock-regexp
  '((((class color)) :background "Grey87")
    (t :underline t))
  "Face for highlighting regexp at point."
  :group 'regexp-lock)

(defface regexp-lock-group
  '((((class color)) :bold t :foreground "Black" :background "Orange")
    (t :bold t))
  "Face for highlighting group numbers in regexp at point."
  :group 'regexp-lock)

(defface regexp-lock-match
  '((((class color)) :background "Turquoise1")
    (t :underline t))
  "Face for highlighting match of regexp at point."
  :group 'regexp-lock)

(defface regexp-lock-match-group
  '((((class color)) :bold t :foreground "Black" :background "Turquoise1")
    (t :bold t))
  "Face for highlighting group numbers in match of regexp at point."
  :group 'regexp-lock)

(defface regexp-lock-match-other
  '((((class color)) :background "PaleTurquoise1")
    (t :underline t))
  "Face for highlighting other matches of regexp at point."
  :group 'regexp-lock)

(defcustom regexp-lock-minor-mode-string nil
  "*String to display in mode line when Regexp Lock is enabled."
  :type '(choice string (const :tag "none" nil))
  :group 'regexp-lock)

(defcustom regexp-lock-regexp-string
  "\\\\\\\\[](|)>}`'=_sSwWcCbB0-9]\\|\\[\\(?:[ ^:]\\|\\\\[tnf]\\)\\|\\][*+?]"
  "*Strings matching this regexp are considered regexp subexpressions.

This regexp is used to discriminate strings representing regular
expressions from \"ordinary\" strings.  The default value has Regexp
Lock search for one of the following:

- two backslashes preceding any of the characters expected in regexp
  backslash constructs but \"[\", \"{\" and \"<\" - the latter being
  excluded because the corresponding constructs have a special meaning
  in `substitute-command-keys'

- a left bracket followed by a space, a caret, a colon, or a backslash
  that precedes one of the characters \"t\", \"n\", or \"f\"

- a right bracket followed by one of \"*\", \"+\", or \"?\"

If any of these items is present in a string, that individual string is
considered part of a regular expression.  If, moreover, the string
literally appears within the argument list of a `concat' or `mapconcat',
all components of that list are considered regular expressions too."
  :type 'regexp
  :group 'regexp-lock)

(defcustom regexp-lock-redo-delay 0.1
  "*Time in seconds Regexp Lock waits before refontifying text.

By default, Regexp Lock refontifies text in order to correctly assign
the text properties of all regexps displayed.  When the value of this
variable is nil Regexp Lock never refontifies text.  As a consequence
regexps may appear improperly fontified after a buffer has been altered,
scrolled, or is displayed for the first time."
  :type '(choice (const :tag "never" nil) (number :tag "seconds"))
  :set (lambda (symbol value)
         (set-default symbol value)
         (when (boundp 'regexp-lock-redo-timer)
           (when regexp-lock-redo-timer
             (cancel-timer regexp-lock-redo-timer)
             (setq regexp-lock-redo-timer nil))
           (when value
             (setq regexp-lock-redo-timer
                   (run-with-idle-timer value t 'regexp-lock-redo)))))
  :group 'regexp-lock)

(defcustom regexp-lock-pause nil
  "*Time in seconds Regexp Lock pauses during refontifying and rechecking.

When the value of this variable is nil `regexp-lock-redo' and
`regexp-lock-recheck' never pause."
  :type '(choice (const :tag "never" nil) (number :tag "seconds"))
  :group 'regexp-lock)

(defcustom regexp-lock-redo-size 500
  "*Number of characters Regexp Lock refontifies without pause."
  :type 'integer
  :group 'regexp-lock)

(defcustom regexp-lock-recheck-delay 1
  "*Time in seconds Regexp Lock waits before rechecking.

Rechecking is needed since refontification \(`regexp-lock-redo'\) can
not tell whether a multi-line string that matches - or does not match -
`regexp-lock-regexp-string' did so in earlier fontifications too.  The
function `regexp-lock-recheck' periodically checks strings whether they
\(still\) qualify as regexp subexpressions.  It does so by searching
windows for `regexp-lock-regexp-string' and requesting refontification
whenever the semantics of a string might have changed.  If the value of
regexp-lock-recheck-delay is nil no rechecking is done.

In practice, the semantics of expressions change rarely.  A noticeable
exception occurs when you compose a regexp spanning multiple lines and
the first match for `regexp-lock-regexp-string' does not occur on the
first lines."
  :type '(choice (const :tag "never" nil) (number :tag "seconds"))
  :set (lambda (symbol value)
         (set-default symbol value)
         (when (boundp 'regexp-lock-recheck-timer)
           (when regexp-lock-recheck-timer
             (cancel-timer regexp-lock-recheck-timer)
             (setq regexp-lock-recheck-timer nil))
           (when value
             (setq regexp-lock-recheck-timer
                   (run-with-idle-timer value t 'regexp-lock-recheck)))))
  :group 'regexp-lock)

(defcustom regexp-lock-show-priority 1000
  "*Priority of overlays highlighting the regexp at point.

Regexp Lock uses this priority for overlays highlighting the regexp at
point and group numbers."
  :type 'integer
  :group 'regexp-lock)

(defcustom regexp-lock-show-delay 0.2
  "*Time in seconds to wait before highlighting the regexp at point.

Regexp Lock waits this many seconds before highlighting the regexp at
point and any group numbers.  A value of nil means that no such
highlighting is performed."
  :type '(choice (const :tag "never" nil) (number :tag "seconds"))
  :set (lambda (symbol value)
         (set-default symbol value)
         (when (boundp 'regexp-lock-show-timer)
           (when regexp-lock-show-timer
             (cancel-timer regexp-lock-show-timer))
           (setq regexp-lock-show-timer nil)
           (when value
             (setq regexp-lock-show-timer
                   (run-with-idle-timer value t 'regexp-lock-show)))))
  :group 'regexp-lock)

(defcustom regexp-lock-match-before-group "{"
  "*String displayed before group number of matching expression.

Matching the regexp at point has Regexp Lock display group numbers of
corresponding regexp subexpressions.  These numbers are indicated with
the help of overlays appearing before and after the match.  If two or
more subexpressions match at the same position, you may discriminate
them more easily by displaying this string before any group number."
  :type 'string
  :group 'regexp-lock)

(defcustom regexp-lock-match-after-group "}"
  "*String displayed after group number of matching expression.

Matching the regexp at point has Regexp Lock display group numbers of
corresponding regexp subexpressions.  These numbers are indicated with
the help of overlays appearing before and after the match.  If two or
more subexpressions match at the same position, you may discriminate
them more easily by displaying this string after any group number."
  :type 'string
  :group 'regexp-lock)

(defcustom regexp-lock-hook nil
  "Hook run after Regexp Lock has been turned on or off."
  :type 'hook
  :group 'regexp-lock)

;; _____________________________________________________________________________
;;
;;;                              Mode definitions
;; _____________________________________________________________________________
;;
(define-minor-mode regexp-lock-mode
  "Toggle Regexp Lock.

Regexp Lock is a minor mode for highlighting regular expressions in
Emacs Lisp mode.  When activated, it has font-lock modify syntactic
properties and appearance of regexp constituents as follows:

- Ordinary brackets, parentheses, and semicolons are assigned the
  `symbol' syntax-table property.  As a consequence, `forward-sexp' and
  `backward-sexp' within strings will skip parenthesized groups and
  alternatives in a more intuitive way.  `blink-matching-open' and
  `show-paren-mode' will not falsely indicate mismatching parens.

- Brackets delimiting character alternatives are highlighted with
  `font-lock-regexp-grouping-construct' face.  Special parentheses and
  brackets that don't match are signaled with `font-lock-warning-face'.

- Highlight the regular expression at point with `regexp-lock-regexp'
  face.  Also overlay the backslashes used to escape subgroup delimiting
  parens with the associated group number.  Group numbers are displayed
  with `regexp-lock-group' face.  These overlays are installed whenever
  `point' is immediately before or after a string or subgroup delimiter
  of the regexp at point.

The commands \\[regexp-lock-match-next] and \\[regexp-lock-match-prev]
can be used to highlight the next respectively previous expression
matching the regexp at point in another window.  These commands use
`eval' to evaluate the regexp at point.  For the current match they
highlight:

- The entire match `(match-string 0)' with `regexp-lock-match' face.

- Group numbers corresponding to subgroup matches are highlighted with
  `regexp-lock-match-group' face.  In addition, the strings specified by
  `regexp-lock-match-before-group' and `regexp-lock-match-after-group'
  are used to separate group numbers.

Matches before and after the current match are highlighted with
`regexp-lock-match-other' face.  If necessary, Regexp Lock splits the
selected window in order to display matches.  Initially, matches are
shown for the buffer containing the regexp at point.  Matches for any
other buffer can be shown by switching to that buffer in the window
displaying matches.

Finally, Regexp Lock provides a function `regexp-lock-increment' which
permits to in-/decrement arguments of `match-beginning' or `match-end'
within the region.


Caveats:

- Regexp Lock uses a number of heuristics to detect regexps.  Hence you
  will occasionally see ordinary strings highlighted as regexps as well
  as regexps highlighted as ordinary strings.  In some cases customizing
  the variable `regexp-lock-regexp-string' might help.

- Regexp Lock analyzes regular expressions literally.  Hence if you
  write something like

  \(defvar foo \"\\\\(\") \(defvar bar (concat foo \"bar\\\\)\"))

  Regexp Lock is not able to indicate group numbers correctly and will
  additionally issue two warnings.

- Regexp Lock expects that a regexp produced by `regexp-opt' is
  contained in a grouping construct iff the second argument of
  regexp-opt is present and does not equal one of the character
  sequences `nil' or `()'.

- Regexp Lock does not recognize expressions constructed by `rx' or
  `sregex'.

- Regexp Lock consumes processor resources.  On battery-powered systems
  you should turn it off whenever you don't need it."
  :lighter regexp-lock-minor-mode-string
  :group 'regexp-lock
  :keymap '(("\C-c(" . regexp-lock-match-next)
            ("\C-c)" . regexp-lock-match-prev)
            ("\C-c#" . regexp-lock-increment))
  (if regexp-lock-mode
      (regexp-lock-activate)
    (regexp-lock-deactivate))
  (run-hooks 'regexp-lock-hook))

(defun turn-on-regexp-lock-mode ()
  "Unequivocally turn on `regexp-lock-mode'."
  (interactive)
  (regexp-lock-mode 1))

;; _____________________________________________________________________________
;;
;;;                          Local definitions
;; _____________________________________________________________________________
;;
(defvar regexp-lock-redo t
  "When non-nil refontify this buffer.")

(defvar regexp-lock-redo-timer nil
  "Idle timer for `regexp-lock-redo'.")

(defvar regexp-lock-recheck t
  "When non-nil recheck this buffer.")

(defvar regexp-lock-recheck-timer nil
  "Idle timer for `regexp-lock-recheck'.")

(defvar regexp-lock-overlays nil
  "Overlays used by `regexp-lock-show'.")

(defvar regexp-lock-show-timer nil
  "Idle timer for `regexp-lock-show'.")

(defvar regexp-lock-match-regexp nil
  "`regexp-lock-match' searches for this regexp.")

(defvar regexp-lock-match-window nil
  "`regexp-lock-match' display matches in this window.")

(defvar regexp-lock-match-buffer nil
  "`regexp-lock-match-window' displays this buffer.")

(defvar regexp-lock-match-overlays nil
  "Overlays that highlight matches in `regexp-lock-match-window'.")

(defvar regexp-lock-match-from (make-marker)
  "Marker for match begin in `regexp-lock-match-buffer'.")

(defvar regexp-lock-match-to (make-marker)
  "Marker for match end in `regexp-lock-match-buffer'.")

(eval-when-compile
  (defmacro save-regexp-lock (&rest body)
    "Eval BODY with match-data, excursion, restrictions saved, buffer widened."
    `(save-match-data
       (save-excursion
         (save-restriction
           (widen)
           (progn ,@body)))))
  (put 'save-regexp-lock 'lisp-indent-function 0)
  (def-edebug-spec save-regexp-lock let)
  (defmacro with-regexp-lock (&rest body)
    "Eval BODY, preserving current buffer's modified and undo states."
    (let ((modified (make-symbol "modified")))
      `(let ((,modified (buffer-modified-p))
             (buffer-undo-list t)
             (inhibit-read-only t)
             (inhibit-point-motion-hooks t)
             (inhibit-modification-hooks t)
             deactivate-mark
             buffer-file-name
             buffer-file-truename)
	 (unwind-protect
	     (progn ,@body)
	   (unless ,modified
	     (restore-buffer-modified-p nil))))))
  (put 'with-regexp-lock 'lisp-indent-function 0)
  (def-edebug-spec with-regexp-lock let))

(defsubst regexp-lock-string-face-p (face)
  "Return t when character at `point' has `font-lock-string-face' face property."
  (or (and (listp face)
           (memq 'font-lock-string-face face))
      (eq face 'font-lock-string-face)))

(defsubst regexp-lock-syntactic-face-p (face)
  "Return t when face property at `point' indicates syntactic context.

More precisely, return t when character at point has one of
`font-lock-string-face', `font-lock-comment-face', or
`font-lock-doc-face' face property."
  (or (and (listp face)
           (or (memq 'font-lock-string-face face)
               (memq 'font-lock-comment-face face)
               (memq 'font-lock-doc-face face)))
      (memq face '(font-lock-string-face
                   font-lock-comment-face
                   font-lock-doc-face))))

;; the following function is commented out in font-lock.el
(defun remove-text-property (start end property &optional object)
 "Remove a property from text from START to END.
Argument PROPERTY is the property to remove.
Optional argument OBJECT is the string or buffer containing the text.
Return t if the property was actually removed, nil otherwise."
 (remove-text-properties start end (list property) object))

;; the following function is commented out in font-lock.el
(defun remove-single-text-property (start end prop value &optional object)
 "Remove a specific property value from text from START to END.
Arguments PROP and VALUE specify the property and value to remove.  The
resulting property values are not equal to VALUE nor lists containing VALUE.
Optional argument OBJECT is the string or buffer containing the text."
 (let ((start (text-property-not-all start end prop nil object)) next prev)
   (while start
     (setq next (next-single-property-change start prop object end)
	    prev (get-text-property start prop object))
     (cond ((and (symbolp prev) (eq value prev))
	     (remove-text-property start next prop object))
	    ((and (listp prev) (memq value prev))
	     (let ((new (delq value prev)))
	       (cond ((null new)
		      (remove-text-property start next prop object))
		     ((= (length new) 1)
		      (put-text-property start next prop (car new) object))
		     (t
		      (put-text-property start next prop new object))))))
     (setq start (text-property-not-all next end prop nil object)))))

;; _____________________________________________________________________________
;;
;;;                        Activate / Deactivate
;; _____________________________________________________________________________
;;
(defun regexp-lock-activate ()
  "Activate Regexp Lock in current buffer."
  (if (not (memq major-mode
                 '(emacs-lisp-mode lisp-mode lisp-interaction-mode reb-mode)))
      (error "Regexp Lock can be used in Lisp modes only")
    ;; turn on font-lock if necessary and integrate ourselves
    (unless font-lock-mode (font-lock-mode 1))
    (set (make-local-variable 'font-lock-extra-managed-props)
         (append font-lock-extra-managed-props
                 (list 'syntax-table 'regexp-lock)))
    (font-lock-add-keywords nil '(regexp-lock-fontify . nil) t)
    (font-lock-unfontify-buffer)
    (save-restriction
      (widen)
      (with-regexp-lock
        (remove-text-properties (point-min) (point-max) '(fontified t))))
    ;; syntax properties
    (set (make-local-variable 'parse-sexp-lookup-properties) t)
    ;; hooks
    (add-hook 'after-change-functions 'regexp-lock-after-change nil t)
    (add-hook 'window-scroll-functions 'regexp-lock-window-redo t t)
    (add-hook 'window-size-change-functions 'regexp-lock-frame-redo)
    (add-hook 'change-major-mode-hook 'regexp-lock-deactivate nil t)
    ;; redo-timer
    (when regexp-lock-redo-timer
      (cancel-timer regexp-lock-redo-timer)
      (setq regexp-lock-redo-timer nil))
    (when regexp-lock-redo-delay
      (setq regexp-lock-redo-timer
            (run-with-idle-timer regexp-lock-redo-delay t 'regexp-lock-redo)))
    (set (make-local-variable 'regexp-lock-redo) nil)
    ;; recheck-timer
    (when regexp-lock-recheck-timer
      (cancel-timer regexp-lock-recheck-timer)
      (setq regexp-lock-recheck-timer nil))
    (when regexp-lock-recheck-delay
      (setq regexp-lock-recheck-timer
            (run-with-idle-timer
             regexp-lock-recheck-delay t 'regexp-lock-recheck)))
    (set (make-local-variable 'regexp-lock-recheck) nil)
    ;; show-timer
    (when regexp-lock-show-timer
      (cancel-timer regexp-lock-show-timer)
      (setq regexp-lock-show-timer nil))
    (when regexp-lock-show-delay
      (setq regexp-lock-show-timer
            (run-with-idle-timer regexp-lock-show-delay t 'regexp-lock-show)))))

(defun regexp-lock-deactivate ()
  "Deactivate Regexp Lock in current buffer."
  ;; syntax properties
  (setq parse-sexp-lookup-properties nil)
  ;; local hooks
  (remove-hook 'after-change-functions 'regexp-lock-after-change)
  (remove-hook 'window-scroll-functions 'regexp-lock-window-redo)
  (remove-hook 'change-major-mode-hook 'regexp-lock-deactivate)
  (remove-hook 'pre-command-hook 'regexp-lock-match-pre-command)
  ;; redo
  (with-regexp-lock
    (remove-text-properties (point-min) (point-max) '(regexp-lock-redo nil)))
  ;; font lock
  (font-lock-unfontify-buffer)
  (setq font-lock-extra-managed-props
        (delq 'syntax-table
              (delq 'regexp-lock
                    font-lock-extra-managed-props)))
  (font-lock-remove-keywords nil '(regexp-lock-fontify . nil))
  (save-restriction
    (widen)
    (with-regexp-lock
      (remove-text-properties (point-min) (point-max) '(fontified t))))
  (unless (catch 'found
            (dolist (buffer (buffer-list))
              (when (with-current-buffer buffer regexp-lock-mode)
                (throw 'found t))))
    ;; markers
    (set-marker regexp-lock-match-from nil)
    (set-marker regexp-lock-match-to nil)
    ;; global hook
    (remove-hook 'window-size-change-functions 'regexp-lock-frame-redo)
    ;; redo-timer
    (when regexp-lock-redo-timer
      (cancel-timer regexp-lock-redo-timer)
      (setq regexp-lock-redo-timer nil))
    ;; recheck-timer
    (when regexp-lock-recheck-timer
      (cancel-timer regexp-lock-recheck-timer)
      (setq regexp-lock-recheck-timer nil))
    ;; show-timer
    (when regexp-lock-show-timer
      (cancel-timer regexp-lock-show-timer)
      (setq regexp-lock-show-timer nil))))

;; _____________________________________________________________________________
;;
;;;                           Text Properties
;; _____________________________________________________________________________
;;
(defun regexp-lock-after-change (start end old-len)
  "Mark text after buffer change to trigger `regexp-lock-redo'."
  (when regexp-lock-mode
    (with-regexp-lock
      (save-excursion
        (goto-char start)
        (if (save-match-data
              (save-excursion
                (beginning-of-line)
                (re-search-forward
                 regexp-lock-regexp-string (max end (line-end-position)) t)))
            (put-text-property
             (line-beginning-position) (min (max end (1+ start)) (point-max))
             'regexp-lock-redo 2)
          (put-text-property
           (line-beginning-position) (min (max end (1+ start)) (point-max))
           'regexp-lock-redo t))
        (setq regexp-lock-redo t)))))

(defun regexp-lock-window-redo (window start)
  "Mark text after window scroll to trigger `regexp-lock-redo'."
  (with-current-buffer (window-buffer window)
    (when regexp-lock-mode
      (setq regexp-lock-redo t))))

(defun regexp-lock-frame-redo (frame)
  "Mark text after window size change to trigger `regexp-lock-redo'."
  ;; Use frame-first-window since selected-window may be on a different frame.
  (with-selected-window (frame-first-window frame)
    (dolist (window (window-list frame 'nominibuf))
      (with-current-buffer (window-buffer window)
        (when regexp-lock-mode
          (setq regexp-lock-redo t))))))

(defun regexp-lock-redo ()
  "Refontify with Regexp Lock.

Currently this operates on all windows of the selected frame."
  (catch 'input
    (let ((current-buffer (current-buffer))
          (current-point (point))
          (current-point-min (point-min))
          (current-point-max (point-max)))
      (dolist (window (window-list nil 'nominibuf))
        (with-current-buffer (window-buffer window)
          (when (and regexp-lock-mode regexp-lock-redo font-lock-mode)
            (let ((window-start (window-start window))
                  (window-end (window-end window))
                  (parse-sexp-ignore-comments t))
              (save-regexp-lock
               (let* ((bod (save-excursion
                             ;; bod is the last beginning-of-defun
                             ;; preceding start of window or point-min
                             (goto-char window-start)
                             (or (condition-case nil
                                     (progn
                                       (beginning-of-defun)
                                       (line-beginning-position))
                                   (error (point-min)))
                                 (point-min))))
                      (eod (save-excursion
                             ;; eod is the first end-of-defun following
                             ;; end of window or point-max
                             (goto-char window-end)
                             (or (condition-case nil
                                     (progn
                                       (beginning-of-defun -1)
                                       (max window-end
                                            (line-beginning-position)))
                                   (error (point-max)))
                                 (point-max))))
                      ;; from is the first redo position between bod
                      ;; and eod
                      (from (min (or (text-property-any
                                      bod eod 'regexp-lock-redo t)
                                     eod)
                                 (or (text-property-any
                                      bod eod 'fontified nil)
                                     eod)))
                      to)
                 (when (and from (< from eod))
                   (save-excursion
                     (goto-char from)
                     (setq from (line-beginning-position)))
                   ;; adjust from
                   (when (or (< from bod)
                             (and (> from bod)
                                  (not (get-text-property
                                        (1- from) 'fontified))))
                     ;; refontify from bod
                     (setq from bod))
                   ;; initialize to
                   (when (or (< from window-end)
                             (not (equal (get-text-property
                                          (1- from) 'regexp-lock)
                                         (get-text-property
                                          from 'regexp-lock))))
                     (setq to (min (save-excursion
                                     (goto-char
                                      (+ from regexp-lock-redo-size))
                                     (line-beginning-position 2))
                                   eod))
                     ;; fontify
                     (while (and (< from to)
                                 (or (not regexp-lock-pause)
                                     (save-excursion
                                       (with-current-buffer current-buffer
                                         (save-restriction
                                           (goto-char current-point)
                                           (narrow-to-region
                                            current-point-min
                                            current-point-max)
                                           (sit-for regexp-lock-pause))))
                                     (throw 'input t)))
                       (with-regexp-lock
                         ;; record the following two properties _now_
                         ;; since font-lock may fontify past to
                         (let ((fontified-at-to
                                (get-text-property to 'fontified))
                               (lock-at-to
                                (get-text-property to 'regexp-lock)))
                           (put-text-property from to 'fontified t)
                           (if jit-lock-mode
                               ;; as jit-lock-fontify-now
                               (condition-case err
                                   (run-hook-with-args
                                    'jit-lock-functions from to)
                                 (quit (put-text-property
                                        from to 'fontified nil)
                                       (funcall
                                        'signal (car err) (cdr err))))
                             ;; plain font-lock-fontify-region
                             (font-lock-fontify-region from to))
                           (remove-text-properties
                            from to '(regexp-lock-redo nil))
                           (setq from to)
                           (when (and (< to eod)
                                      (or (not fontified-at-to)
                                          (not (equal (get-text-property
                                                       (1- to) 'regexp-lock)
                                                      lock-at-to))))
                             (put-text-property
                              to (min (1+ to) (point-max))
                              'regexp-lock-redo t)
                             (setq to (min (save-excursion
                                             (goto-char
                                              (+ to regexp-lock-redo-size))
                                             (line-beginning-position 2))
                                           eod))))))))))
              ;; keep the following always _within_ the outermost
              ;; let to avoid that other idle timers get confused
              (timer-activate-when-idle regexp-lock-show-timer t)
              (setq regexp-lock-redo nil)
              (setq regexp-lock-recheck t))))
        (or (not regexp-lock-pause)
            (sit-for regexp-lock-pause)
            (throw 'input t))))))

(defsubst regexp-lock-set-redo (from to)
  "Set `regexp-lock-redo' from `regexp-lock-recheck'.

This sets the `regexp-lock-redo' text-property at FROM as well as the
buffer-local value of `regexp-lock-redo' to t.  Values are set if a
match for `regexp-lock-regexp-string' is found before TO and the
`regexp-lock' text-property at FROM is not set or no match before TO
exists and the `regexp-lock' text-property is set."
  (if (re-search-forward regexp-lock-regexp-string to 'to)
      ;; match for regexp-lock-regexp-string
      (unless (get-text-property from 'regexp-lock)
        ;; regexp-lock not set, redo
        (with-regexp-lock
          (put-text-property from (1+ from) 'regexp-lock-redo t))
        (setq regexp-lock-redo t))
    ;; no match for regexp-lock-regexp-string
    (when (get-text-property from 'regexp-lock)
      ;; regexp-lock set, redo
      (with-regexp-lock
        (put-text-property from (1+ from) 'regexp-lock-redo t))
      (setq regexp-lock-redo t))))

(defun regexp-lock-recheck ()
  "Recheck windows with Regexp Lock.

Currently this operates on all windows of the selected frame."
  (catch 'input
    (let ((current-buffer (current-buffer))
          (current-point (point))
          (current-point-min (point-min))
          (current-point-max (point-max)))
      (dolist (window (window-list nil 'nominibuf))
        (with-current-buffer (window-buffer window)
          (when (and regexp-lock-mode regexp-lock-recheck font-lock-mode)
            (let ((window-start (window-start window))
                  (window-end (window-end window))
                  (parse-sexp-ignore-comments t))
              (save-regexp-lock
               (let* ((from (save-excursion
                              ;; from is the last beginning-of-defun
                              ;; preceding start of window or point-min
                              (goto-char window-start)
                              (or (condition-case nil
                                      (progn
                                        (beginning-of-defun)
                                        (line-beginning-position))
                                    (error (point-min)))
                                  (point-min))))
                      to face)
                 ;; check iff from has been already fontified
                 (when (get-text-property from 'fontified)
                   (goto-char from)
                   (while (re-search-forward "\\(\"\\)\
\\|(\\(\\(?:map\\)?concat\\)\\>\
\\|(\\(re-search-\\(?:for\\|back\\)ward\\|looking-\\(?:at\\|back\\)\\|string-match\\|replace-regexp-in-string\
\\|message\\|error\\|skip-\\(?:syntax\\|chars\\)-\\(?:for\\|back\\)ward\\|search-\\(?:for\\|back\\)ward\\)\\>"
                                             window-end 'window-end)
                     (setq face (get-text-property
                                 (or (match-end 1) (match-beginning 0))
                                 'face))
                     (cond
                      ((match-beginning 1)
                       ;; double-quote
                       (cond
                        ((and (regexp-lock-string-face-p face)
                              (save-excursion
                                (condition-case nil
                                    (progn
                                      (setq from (match-beginning 1))
                                      (goto-char from)
                                      (forward-sexp)
                                      (setq to (point)))
                                  (error nil))))
                         (regexp-lock-set-redo from to)
                         (goto-char (min to window-end)))
                        ((and (or (and (listp face)
                                       (memq 'font-lock-doc-face face))
                                  (eq 'font-lock-doc-face face))
                              (save-excursion
                                (condition-case nil
                                    (progn
                                      (goto-char (match-beginning 1))
                                      (forward-sexp)
                                      (setq to (point)))
                                  (error nil))))
                         ;; doc-string, skip
                         (goto-char (min to window-end)))))
                      ((match-beginning 2)
                       ;; concat, mapconcat
                       (when (and (not (regexp-lock-syntactic-face-p face))
                                  (save-excursion
                                    (condition-case nil
                                        (progn
                                          (setq from (match-beginning 0))
                                          (goto-char from)
                                          (forward-sexp)
                                          (setq to (point)))
                                      (error nil)))
                                  (goto-char from))
                         (regexp-lock-set-redo from to)
                         (goto-char (min to window-end))))
                      ((match-beginning 3)
                       ;; re-search- / looking- / string-match /
                       ;; replace-regexp-in-string /
                       ;; message / error / search- / skip-syntax- /
                       ;; skip-chars-, skip
                       (if (and (not (regexp-lock-syntactic-face-p face))
                                (save-excursion
                                  (condition-case nil
                                      (progn
                                        (goto-char (match-beginning 0))
                                        (forward-sexp)
                                        (setq to (point)))
                                    (error nil))))
                           (goto-char (min to window-end))
                         (goto-char (min (point) window-end)))))))
                 (setq regexp-lock-recheck nil)
                 (when regexp-lock-redo
                   ;; activate regexp-lock-redo-timer
                   (timer-activate-when-idle
                    regexp-lock-redo-timer t)))))))))
    (or (not regexp-lock-pause)
        (sit-for regexp-lock-pause)
        (throw 'input t))))

(defun regexp-lock-fontify (bound)
  "Fontify region from `point' to BOUND."
  (let ((lock (unless (= (point) (point-min))
                (get-text-property (1- (point)) 'regexp-lock)))
        ;; `lock' - the `regexp-lock' text property - is interpreted as:
        ;; nil - no regexp around point (nil is not stored as text property)
        ;; 0 - the following sexp is a regexp
        ;; 1 - within a regexp-string that is not argument of a `concat'
        ;; >= 2 - within a `concat' that has at least one regexp argument
        ;; within a character alternative values are negative
        (from (point))
        (parse-sexp-ignore-comments t)
        to face)
    (while (< (point) bound)
      (catch 'lock
        (if lock
            (while (re-search-forward
                    "\\(^\\s(\\)\\|\\(\"\\)\\|\\(?:\\\\\\\\\\)\\(?:\\(?:\\\\\\\\\\)\\|\\([()]\\)\\|\\(|\\)\\|\\(\\[\\)\\|\\(\\]\\)\\)\
\\|\\(\\\\[][()]\\)\\|\\(\\[:[a-zA-Z]+:\\]\\)\\|\\(\\[\\)\\|\\(\\]\\)\\|\\(;\\)\\|\\((\\)\\|\\()\\)\\|`\\(\\sw\\sw+\\)'" bound 'bound)
              (setq face (get-text-property (1- (point)) 'face))
              (cond
               ((match-beginning 1)
                ;; paren in column zero, throw
                (put-text-property from (match-beginning 1) 'regexp-lock lock)
                (setq lock nil)
                (throw 'lock nil))
               ((match-beginning 2)
                ;; double-quote, ignore for lock not in {-1,0,1}
                (cond
                 ((zerop lock)
                  ;; start new regexp-string
                  (put-text-property from (match-beginning 2) 'regexp-lock 0)
                  (setq from (match-beginning 2))
                  (goto-char (1+ from))
                  (setq lock 1))
                 ((and (or (= lock 1) (= lock -1))
                       ;; the following skips adjacent double-quotes as in
                       ;; "string1""string2" which should not do much harm
                       (regexp-lock-string-face-p face)
                       (or (= (point) bound) ; fails with escaped `"' at eob
                           (not (regexp-lock-string-face-p
                                 (get-text-property (point) 'face)))))
                  ;; terminate current regexp-string
                  (put-text-property from (point) 'regexp-lock lock)
                  (when (= lock -1)
                    ;; unclosed character alternative, warn
                    (put-text-property
                     (1- (point)) (point) 'face 'font-lock-warning-face))
                  (setq lock nil)
                  (throw 'lock nil))))
               ((and (match-beginning 12)
                     (not (regexp-lock-syntactic-face-p face)))
                ;; non-syntactic left paren, expects lock not in {-1,1}
                (put-text-property from (match-beginning 12) 'regexp-lock lock)
                (setq from (match-beginning 12))
                (cond
                 ((>= lock 2) (setq lock (1+ lock)))
                 ((<= lock -2) (setq lock (1- lock)))
                 ((zerop lock) (setq lock 2))
                 (t (setq lock nil)     ; looses
                    (throw 'lock nil))))
               ((and (match-beginning 13)
                     (not (regexp-lock-syntactic-face-p face)))
                ;; non-syntactic right paren, expects lock not in {-1,1}
                (put-text-property from (match-end 13) 'regexp-lock lock)
                (setq from (match-end 13))
                (cond
                 ((> lock 2) (setq lock (1- lock)))
                 ((< lock -2) (setq lock (1+ lock)))
                 (t (when (= lock -2)
                      ;; unclosed character alternative, warn
                      (put-text-property
                       (1- (point)) (point) 'face 'font-lock-warning-face))
                    (setq lock nil)     ; end of sexp or looser
                    (throw 'lock nil))))
               ((regexp-lock-string-face-p face)
                ;; matches below are valid within strings only
                (cond
                 ((match-beginning 3)   ; \\( or \\)
                  (when (< lock 0)
                    ;; within character alternative, set symbol syntax
                    (put-text-property (1- (point)) (point) 'syntax-table '(3))
                    ;; remove faces that are silly here
                    (remove-single-text-property
                     (match-beginning 0) (1- (match-end 0))
                     'face 'font-lock-regexp-backslash)
                    (remove-single-text-property
                     (1- (match-end 0)) (match-end 0)
                     'face 'font-lock-regexp-grouping-construct)))
                 ((match-beginning 4)   ; \\|
                  (when (< lock 0)
                    ;; within character alternative remove regexp-lock faces
                    (remove-single-text-property
                     (match-beginning 0) (1- (match-end 0))
                     'face 'font-lock-regexp-backslash)
                    (remove-single-text-property
                     (1- (match-end 0)) (match-end 0)
                     'face 'font-lock-regexp-grouping-construct)))
                 ((match-beginning 5)   ; \\[
                  (let ((face (get-text-property (point) 'face)))
                    (when (and (listp face)
                               (memq 'font-lock-constant-face face))
                      ;; remove font-lock-constant-face
                      (remove-single-text-property
                       (point) (next-single-property-change
                                (point) 'face nil (line-end-position))
                       'face 'font-lock-constant-face)))
                  (if (< lock 0)
                      ;; within character alternative, reread bracket
                      (goto-char (1- (point)))
                    ;; not within character alternative, set symbol syntax
                    (put-text-property
                     (1- (point)) (point) 'syntax-table '(3))))
                 ((match-beginning 6)   ; \\]
                  (if (< lock 0)
                      ;; within character alternative, reread bracket
                      (goto-char (1- (point)))
                    ;; not within character alternative, set symbol syntax
                    (put-text-property
                     (1- (point)) (point) 'syntax-table '(3))))
                 ((match-beginning 7)   ; escaped parenthesis or bracket
                  ;; set symbol syntax for backslash and reread paren
                  (put-text-property
                   (match-beginning 0) (1+ (match-beginning 0))
                   'syntax-table '(3))
                  (goto-char (1+ (match-beginning 0))))
                 ((match-beginning 8))
                 ;; POSIX character class, skip
                 ((match-beginning 9)   ; [
                  (let ((face (get-text-property (point) 'face)))
                    (when (and (listp face)
                               (memq 'font-lock-constant-face face))
                      ;; remove font-lock-constant-face
                      (remove-single-text-property
                       (point) (next-single-property-change
                                (point) 'face nil (line-end-position))
                       'face 'font-lock-constant-face)))
                  (if (< lock 0)
                      ;; within character alternative, set symbol syntax
                      (put-text-property
                       (1- (point)) (point) 'syntax-table '(3))
                    ;; start new character alternative
                    (put-text-property from (1- (point)) 'regexp-lock lock)
                    (setq from (1- (point)))
                    (setq lock (- lock))
                    (font-lock-prepend-text-property
                     (match-beginning 9) (match-end 9)
                     'face 'font-lock-regexp-grouping-construct)
                    (when (looking-at "\\(?:\\\\?\\^\\)?\\\\?\\(\\]\\)")
                      ;; non-special right bracket, set symbol syntax
                      (put-text-property
                       (match-beginning 1) (match-end 1) 'syntax-table '(3))
                      (goto-char (match-end 1)))))
                 ((match-beginning 10)  ; ]
                  (if (> lock 0)
                      ;; not within character alternative, warn
                      (font-lock-prepend-text-property
                       (match-beginning 10) (match-end 10)
                       'face 'font-lock-warning-face)
                    ;; terminate alternative
                    (font-lock-prepend-text-property
                     (match-beginning 10) (match-end 10)
                     'face 'font-lock-regexp-grouping-construct)
                    (put-text-property from (point) 'regexp-lock lock)
                    (setq from (point))
                    (setq lock (- lock))))
                 ((or (match-beginning 11)
                      (match-beginning 12)
                      (match-beginning 13)) ; (;), set symbol syntax
                  (put-text-property (1- (point)) (point) 'syntax-table '(3)))
                 ((match-beginning 14)  ; `..', remove constant face property
                  (remove-single-text-property
                   (match-beginning 0) (match-end 0)
                   'face 'font-lock-constant-face))))))
          ;; no lock
          (while (re-search-forward "\\(\"\\)\
\\|(\\(re-search-\\(?:for\\|back\\)ward\\|looking-\\(?:at\\|back\\)\\|string-match\\|replace-regexp-in-string\\)\\>\
\\|(\\(\\(?:map\\)?concat\\)\\>\
\\|(\\(message\\|error\\|skip-\\(?:syntax\\|chars\\)-\\(?:for\\|back\\)ward\\|search-\\(?:for\\|back\\)ward\\)\\>"
                                    bound 'bound)
            (setq face (get-text-property
                        (or (match-end 1) (match-beginning 0)) 'face))
            (cond
             ((match-beginning 1)
              ;; double-quote, search for `regexp-lock-regexp-string'
              (cond
               ((and (regexp-lock-string-face-p face)
                     (save-excursion
                       (condition-case nil
                           (progn
                             (setq from (match-beginning 1))
                             (goto-char from)
                             (forward-sexp)
                             (setq to (point)))
                         (error nil))))
                (if (re-search-forward regexp-lock-regexp-string to t)
                    ;; plain string matching `regexp-lock-regexp-string'
                    (progn
                      (setq lock 1)
                      (goto-char (1+ from))
                      (throw 'lock nil))
                  ;; plain string that does not match, skip
                  (goto-char (min to bound))))
               ((and (or (and (listp face) (memq 'font-lock-doc-face face))
                         (eq 'font-lock-doc-face face))
                     (save-excursion
                       (condition-case nil
                           (progn
                             (goto-char (match-beginning 1))
                             (forward-sexp)
                             (setq to (point)))
                         (error nil))))
                ;; doc-string, skip
                (goto-char (min to bound)))))
             ((match-beginning 2)
              ;; re-search- / looking- / string-match / replace-regexp-in-string
              (unless (regexp-lock-syntactic-face-p face)
                (setq from (match-end 2))
                (setq lock 0)
                (throw 'lock nil)))
             ((match-beginning 3)
              ;; concat / mapconcat, search arguments for
              ;; `regexp-lock-regexp-string'
              (if (and (not (regexp-lock-syntactic-face-p face))
                       (save-excursion
                         (condition-case nil
                             (progn
                               (setq from (match-beginning 0))
                               (goto-char from)
                               (forward-sexp)
                               (setq to (point)))
                           (error nil)))
                       (goto-char from)
                       (re-search-forward
                        (concat regexp-lock-regexp-string
                                "\\|regexp-opt") to 'to))
                  (progn
                    (setq lock 2)
                    (goto-char (1+ from))
                    (throw 'lock nil))
                (goto-char (min (point) bound))))
             ((match-beginning 4)
              ;; message / error / search- / skip-syntax- / skip-chars-, skip
              (if (and (not (regexp-lock-syntactic-face-p face))
                       (save-excursion
                         (condition-case nil
                             (progn
                               (goto-char (match-beginning 0))
                               (forward-sexp)
                               (setq to (point)))
                           (error nil))))
                  (goto-char (min to bound))
                (goto-char (min (point) bound)))))))))
    (when lock (put-text-property from bound 'regexp-lock lock))))

;; _____________________________________________________________________________
;;
;;;                              Overlays
;; _____________________________________________________________________________
;;
(defun regexp-lock-show ()
  "Display numbers of regular expression groups.

Groups considered are subexpressions enclosed by escaped parentheses
`\\(' and `\\)'.  Shy groups are not counted.  Group numbers overlay one
or both backslashes of any `\\(' and `\\)' of the same regexp with the
number of the group.  Overlays are highlighted whenever `point' is
before the left or after the right parenthesis of an `\\(' or `\\)'.
Hence the group enclosed by `\1(...\1)', for example, represents the
subexpression matching `(match-string 1)'.  Overlays are also shown when
`point' is before a double-quote beginning, or after a double-quote
terminating a string that is part of the regular expression.

Group numbers are displayed whenever Emacs becomes idle after a delay of
`regexp-lock-show-delay' seconds.  Group numbers are highlighted with
`regexp-lock-group' face."
  (when regexp-lock-overlays
    (dolist (overlay regexp-lock-overlays)
      (delete-overlay overlay))
    (setq regexp-lock-overlays nil))
  (when (and regexp-lock-mode
             (not (eq (selected-window) regexp-lock-match-window))
             (or (and (< 2 (point))     ; \\^(
                      (< (point) (point-max))
                      (char-equal (char-after) ?\( )
                      (get-text-property (1- (point)) 'regexp-lock)
                      (> (get-text-property (1- (point)) 'regexp-lock) 0)
                      (char-equal (char-before) ?\\ )
                      (char-equal (char-before (1- (point))) ?\\ ))
                 (and (< 3 (point))     ; \\)^
                      (char-equal (char-before) ?\) )
                      (get-text-property (1- (point)) 'regexp-lock)
                      (> (get-text-property (1- (point)) 'regexp-lock) 0)
                      (char-equal (char-before (1- (point))) ?\\ )
                      (char-equal (char-before (- (point) 2)) ?\\ ))
                 (and (< (point) (point-max)) ; ^"
                      (char-equal (char-after) ?\" )
                      (get-text-property (point) 'regexp-lock)
                      (regexp-lock-string-face-p
                       (get-text-property (point) 'face))
                      (or (= (point) (point-min))
                          (not (regexp-lock-string-face-p
                                (get-text-property (1- (point)) 'face)))))
                 (and (< 3 (point))     ; "^
                      (char-equal (char-before) ?\" )
                      (get-text-property (1- (point)) 'regexp-lock)
                      (regexp-lock-string-face-p
                       (get-text-property (1- (point)) 'face))
                      (or (= (point) (point-max))
                          (not (regexp-lock-string-face-p
                                (get-text-property (point) 'face)))))))
    (save-match-data
      (save-excursion
        (let* ((at (point)) (groups nil) (number 0) (total 0)
               (from at) (to at)
               (parse-sexp-ignore-comments t))
          ;; search beginning and end, tedious
          (while (and (> from (point-min))
                      (get-text-property (1- from) 'regexp-lock)
                      (not (zerop (get-text-property (1- from) 'regexp-lock)))
                      (setq from (previous-single-property-change
                                  (point) 'regexp-lock nil (point-min)))
                      (goto-char from)))
          (goto-char at)
          (while (and (< to (point-max))
                      (get-text-property to 'regexp-lock)
                      (setq to (next-single-property-change
                                (point) 'regexp-lock nil (point-max)))
                      (goto-char to)))
          ;; make overlay for group zero
          (let ((overlay (make-overlay from to)))
            (overlay-put overlay 'face 'regexp-lock-regexp)
            (overlay-put overlay 'window (selected-window))
            (overlay-put overlay 'cursor t)
            (overlay-put overlay 'priority regexp-lock-show-priority)
            (setq regexp-lock-overlays (cons overlay regexp-lock-overlays)))
          ;; using a fixed-size vector here would avoid consing but
          ;; introduce an upper limit on the number of groupings
          (goto-char from)
          (while (re-search-forward "\\(?:\\\\\\\\\\)\\(?:\\(?:\\\\\\\\\\)\\|\\((\\(\\?:\\)?\\)\\|\\()\\)\\)\\|\\(regexp-opt\\)" to t)
            (cond
             ((and (match-beginning 4)  ; (regexp-opt ...)
                   (not (regexp-lock-syntactic-face-p (match-beginning 4))))
              (save-match-data
                (let (at-too)           ; Re-search from here.
                  (when (save-excursion
                          (goto-char (match-end 4))
                          (condition-case nil
                              (progn
                                (forward-sexp)
                                (forward-comment (buffer-size))
                                (setq at-too (point))
                                ;; Anything but `nil' and `()' counts as non-nil.
                                (when (looking-at "\\(?:nil\\|()\\)")
                                  (goto-char (match-end 0))
                                  (forward-comment (buffer-size)))
                                (and (looking-at "[^)]")))
                            (error nil)))
                    (setq total (1+ total)))
                  (when at-too (goto-char at-too)))))
             ((or (not (regexp-lock-string-face-p
                        (get-text-property (1- (point)) 'face)))
                  (< (get-text-property (1- (point)) 'regexp-lock) 0)))
             ((match-beginning 2)       ; \\(?:
              (setq groups (cons 0 groups)))
             ((match-beginning 1)       ; \\(
              (setq number (1+ total))
              (setq total (1+ total))
              (let* ((number-string (number-to-string number))
                     (length (min (length number-string) 2))
                     (overlay (make-overlay
                               (- (match-beginning 1) length)
                               (match-beginning 1))))
                (overlay-put overlay 'display
                             (propertize number-string 'face 'regexp-lock-group))
                (overlay-put overlay 'window (selected-window))
                (overlay-put overlay 'cursor t)
                (overlay-put overlay 'priority regexp-lock-show-priority)
                (setq regexp-lock-overlays (cons overlay regexp-lock-overlays)))
              (setq groups (cons number groups)))
             ((match-beginning 3)       ; \\)
              (cond
               (groups
                (setq number (car groups))
                (unless (zerop number)
                  (let* ((number-string (number-to-string number))
                         (length (min (length number-string) 2))
                         (overlay (make-overlay
                                   (- (match-beginning 3) length)
                                   (match-beginning 3))))
                    (overlay-put overlay 'display
                                 (propertize
                                  number-string 'face 'regexp-lock-group))
                    (overlay-put overlay 'window (selected-window))
                    (overlay-put overlay 'cursor t)
                    (overlay-put overlay 'priority regexp-lock-show-priority)
                    (setq regexp-lock-overlays
                          (cons overlay regexp-lock-overlays))))
                (setq groups (cdr groups)))
               (t                       ; no open group, warn
                (let ((overlay (make-overlay (1- (match-end 3)) (match-end 3))))
                  (overlay-put overlay 'face font-lock-warning-face)
                  (overlay-put overlay 'window (selected-window))
                  (overlay-put overlay 'priority regexp-lock-show-priority)
                  (setq regexp-lock-overlays
                        (cons overlay regexp-lock-overlays))))))))
          (when groups
            ;; unclosed group, warn
            (let ((overlay (make-overlay (1- to) to)))
              (overlay-put overlay 'face font-lock-warning-face)
              (overlay-put overlay 'window (selected-window))
              (overlay-put overlay 'priority regexp-lock-show-priority)
              (setq regexp-lock-overlays
                    (cons overlay regexp-lock-overlays)))))))))

;; _____________________________________________________________________________
;;
;;;                                  Matching
;; _____________________________________________________________________________
;;
(defun regexp-lock-match-pre-command ()
  "Remove match overlays."
  (when regexp-lock-match-overlays
    (dolist (overlay regexp-lock-match-overlays)
      (delete-overlay overlay))
    (setq regexp-lock-match-overlays nil))
  ;; remove ourselves from pre-command-hook
  (remove-hook 'pre-command-hook 'regexp-lock-match-pre-command))

(defun regexp-lock-match (direction)
  "Highlight expressions matching current regexp."
  (interactive)
  (unless (and regexp-lock-match-regexp
               (memq last-command
                     '(regexp-lock-match-next regexp-lock-match-prev)))
    (if (or (and (< (point) (point-max))
                 (get-text-property (point) 'regexp-lock))
            (and (> (point) (point-min))
                 (get-text-property (1- (point)) 'regexp-lock)))
        (save-match-data
          (save-excursion
            (let* ((at (point)) (from at) (to at)
                   (parse-sexp-ignore-comments t))
              ;; search beginning and end, tedious
              (while (and (> from (point-min))
                          (get-text-property (1- from) 'regexp-lock)
                          (not (zerop (get-text-property
                                       (1- from) 'regexp-lock)))
                          (setq from (previous-single-property-change
                                      (point) 'regexp-lock nil (point-min)))
                          (goto-char from)))
              (goto-char at)
              (while (and (< to (point-max))
                          (get-text-property to 'regexp-lock)
                          (setq to (next-single-property-change
                                    (point) 'regexp-lock nil (point-max)))
                          (goto-char to)))

              (save-restriction
                (narrow-to-region from to)
                (goto-char (point-min))
                (setq regexp-lock-match-regexp
                      (condition-case var
                          (eval (read (current-buffer)))
                        ;; display signal information
                        (error (message "%s" var) nil)))))))
      (message "No regexp around point")))
  (when regexp-lock-match-regexp
    (if (and regexp-lock-match-window
             (window-live-p regexp-lock-match-window)
             (not (eq regexp-lock-match-window (selected-window))))
        ;; remember buffer
        (setq regexp-lock-match-buffer (window-buffer regexp-lock-match-window))
      ;; unless regexp-lock-match-window is a live window different from
      ;; the selected one, split the selected window and make the newly
      ;; created one the new regexp-lock-match-window
      (setq regexp-lock-match-window (split-window))
      (if (and (not (eq (window-buffer regexp-lock-match-window)
                        regexp-lock-match-buffer))
               (buffer-live-p regexp-lock-match-buffer))
	  (progn
	    ;; when regexp-lock-match-buffer is a live buffer assert
	    ;; that it is displayed in regexp-lock-match-window (make
	    ;; sure we're not affected by Stefan's `set-window-buffer'
	    ;; fix).
	    (set-window-buffer
	     regexp-lock-match-window regexp-lock-match-buffer)
	    (when (eq regexp-lock-match-window (selected-window))
	      (set-buffer regexp-lock-match-buffer)))
        ;; remember buffer
        (setq regexp-lock-match-buffer
              (window-buffer regexp-lock-match-window))))
    (save-match-data
      (save-excursion
        (with-selected-window regexp-lock-match-window
          ;; handle direction changes in an intuitive way
          (cond
           ((and (eq last-command 'regexp-lock-match-next)
                 (< direction 0)
                 (eq (marker-buffer regexp-lock-match-from)
                     regexp-lock-match-buffer))
            ;; use from marker
            (goto-char regexp-lock-match-from))
           ((and (eq last-command 'regexp-lock-match-prev)
                 (> direction 0)
                 (eq (marker-buffer regexp-lock-match-to)
                     regexp-lock-match-buffer))
            ;; use to marker
            (goto-char regexp-lock-match-to)))
          (let ((at (point))
                bound first)
            (catch 'empty
              (while (if (< direction 0)
                         (re-search-backward regexp-lock-match-regexp bound t)
                       (re-search-forward regexp-lock-match-regexp bound t))
                (if (= (match-beginning 0) (match-end 0))
                    (progn
                      (message "Empty match ...")
                      (sit-for 1)
                      (throw 'empty nil))
                  (let ((overlay (make-overlay
                                  (match-beginning 0) (match-end 0)))
                        (matches (cddr (match-data)))
                        (index 1))
                    (setq regexp-lock-match-overlays
                          (cons overlay regexp-lock-match-overlays))
                    (overlay-put overlay 'face
                                 (if first
                                     'regexp-lock-match-other
                                   'regexp-lock-match))
                    (overlay-put overlay 'window regexp-lock-match-window)
                    (unless first
                      (setq first (point))
                      (set-marker regexp-lock-match-from (match-beginning 0))
                      (set-marker regexp-lock-match-to (match-end 0))
                      (setq bound
                            (save-excursion
                              (vertical-motion
                               (if (< direction 0)
                                   (- (window-height))
                                 (window-height)))
                              (setq bound (point))))
                      ;; set pre-command-hook to remove match overlays eventually
                      (add-hook 'pre-command-hook 'regexp-lock-match-pre-command)
                      (while matches
                        (cond
                         ((eq (car matches) nil)
                          (setq index (1+ index))
                          (setq matches (cddr matches)))
                         ((integer-or-marker-p (car matches))
                          (setq overlay
                                (make-overlay (car matches) (cadr matches)))
                          (overlay-put
                           overlay 'before-string
                           (propertize (concat regexp-lock-match-before-group
                                               (number-to-string index))
                                       'face 'regexp-lock-match-group))
                          (overlay-put overlay 'priority index)
                          (overlay-put overlay 'window regexp-lock-match-window)
                          (setq regexp-lock-match-overlays
                                (cons overlay regexp-lock-match-overlays))
                          (overlay-put
                           overlay 'after-string
                           (propertize (concat (number-to-string index)
                                               regexp-lock-match-after-group)
                                       'face 'regexp-lock-match-group))
                          (overlay-put overlay 'priority index)
                          (overlay-put overlay 'window regexp-lock-match-window)
                          (setq regexp-lock-match-overlays
                                (cons overlay regexp-lock-match-overlays))
                          (setq index (1+ index))
                          (setq matches (cddr matches)))
                         (t (setq matches nil))))))))
              (let ((to (or (and first regexp-lock-match-from) at)))
                (save-excursion
                  (goto-char to)
                  (vertical-motion (- (window-height)))
                  (while (re-search-forward regexp-lock-match-regexp to t)
                    (cond
                     ((= (match-beginning 0) (match-end 0))
                      (message "Empty match ...")
                      (sit-for 1)
                      (throw 'empty nil))
                     (t
                      (let ((overlay (make-overlay
                                      (match-beginning 0) (match-end 0))))
                        (setq regexp-lock-match-overlays
                              (cons overlay regexp-lock-match-overlays))
                        (overlay-put overlay 'face 'regexp-lock-match-other)
                        (overlay-put
                         overlay 'window regexp-lock-match-window)))))
                  (goto-char (or (and first regexp-lock-match-to) to))
                  (setq to (save-excursion
                             (vertical-motion (window-height))
                             (point)))
                  (while (re-search-forward regexp-lock-match-regexp to t)
                    (cond
                     ((= (match-beginning 0) (match-end 0))
                      (message "Empty match ...")
                      (sit-for 1)
                      (throw 'empty nil))
                     (t
                      (let ((overlay (make-overlay
                                      (match-beginning 0) (match-end 0))))
                        (setq regexp-lock-match-overlays
                              (cons overlay regexp-lock-match-overlays))
                        (overlay-put overlay 'face 'regexp-lock-match-other)
                        (overlay-put
                         overlay 'window regexp-lock-match-window))))))))
            (if first
                (progn
                  (goto-char first)
                  (unless (pos-visible-in-window-p)
                    (if (< direction 0)
                        (recenter -3)
                      (recenter 3))))
              (goto-char at)
              (set-marker regexp-lock-match-from nil)
              (set-marker regexp-lock-match-to nil)
              (message "No (more) matches ...")
              (sit-for 1))))))))

(defun regexp-lock-match-next ()
  "Move to next matching expression."
  (interactive)
  (if (memq last-command '(regexp-lock-match-next regexp-lock-match-prev))
      (regexp-lock-match 1)
    (regexp-lock-match 0)))

(defun regexp-lock-match-prev ()
  "Move to previous matching expression."
  (interactive)
  (regexp-lock-match -1))

;; _____________________________________________________________________________
;;
;;;                 Increment / Decrement group numbers
;; _____________________________________________________________________________
;;
(defun regexp-lock-increment (above increment start end)
  "In-/Decrement group numbers within region.

Within region add INCREMENT to all arguments of `match-beginning',
`match-end', and `match-string' greater or equal ABOVE."
  (interactive "nIn-/Decrement group numbers >=: \nnBy: \nr")
  (save-excursion
    (goto-char start)
    (let ((count 0))
      (while (re-search-forward
	      ;; Added `replace-match' on 2009-08-04.
              "\\((match-\\(?:beginning\\|end\\|string\\(?:-no-properties\\)?\\)[ \t\n\f]+\\([0-9]+\\))\\)\
\\|\\((replace-match\\)"
              end t)
	(cond
	 ((match-beginning 1)
	  (let ((number (string-to-number (match-string 2))))
	    (when (>= number above)
	      (replace-match
	       (number-to-string (+ number increment)) nil nil nil 2)
	      (setq count (1+ count)))))
	 ((match-beginning 3)
	  ;; `replace-match' is hairy because the SUBEXP arg is optional.
	  (condition-case nil
	      (progn
		(forward-sexp 4)
		(forward-comment (buffer-size))
		(when (looking-at "[0-9]+")
		  (let ((number (string-to-number (match-string 0))))
		    (when (>= number above)
		      (replace-match
		       (number-to-string (+ number increment)))
		      (setq count (1+ count))))))
	    (error nil)))))
      (if (zerop count)
          (message "No substitutions performed")
        (message "%s substitution(s) performed" count)))))

(provide 'regexp-lock)

;;; regexp-lock.el ends here

--------------A908D8939D78C4D46252684E--




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#50766; Package emacs. Full text available.

Message received at 50766 <at> debbugs.gnu.org:


Received: (at 50766) by debbugs.gnu.org; 1 Oct 2021 15:00:17 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Oct 01 11:00:17 2021
Received: from localhost ([127.0.0.1]:57094 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mWK1J-0006jf-JF
	for submit <at> debbugs.gnu.org; Fri, 01 Oct 2021 11:00:17 -0400
Received: from mout.gmx.net ([212.227.15.19]:55917)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <rudalics@HIDDEN>) id 1mWK1F-0006jK-4b
 for 50766 <at> debbugs.gnu.org; Fri, 01 Oct 2021 11:00:15 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net;
 s=badeba3b8450; t=1633100405;
 bh=JwC9o9JOIeVBVnu8Z+Pe0ZNFcGxevD+4p4BC4d1JLu4=;
 h=X-UI-Sender-Class:Subject:To:Cc:References:From:Date:In-Reply-To;
 b=EeYYgExOA24UQb4QXzjf1N/qjQ1eC8DZvjcwMeXPtGUD4txmZHA8KG52o7HUnsXub
 ixHKPM2TwVaER7dCPlDRLnrQy2R3voRbIzbY6EpTMRL8XjtqQLwIkteQtUyOXSt4Hf
 hgPZrgOiNHyvOedTJ+ED0wvf8haaFzXnKdnWt4VQ=
X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c
Received: from [192.168.1.102] ([212.95.5.169]) by mail.gmx.net (mrgmx004
 [212.227.17.190]) with ESMTPSA (Nemesis) id 1N2mBa-1my0N70I2e-013AS9; Fri, 01
 Oct 2021 17:00:05 +0200
Subject: Re: bug#50766: Regexp paren pairs in query-replace-regexp prompt
 should be highlighted
To: Lars Ingebrigtsen <larsi@HIDDEN>
References: <1LWmgMt-iOZcz0k2N5IVTqgDu922CLEd8GATVBsqdQfVeBzIGEaVuORC9k0SXORQDkpqc8BO3zxOPFbQeMMhNHQmOvcvIOpOpoWL8CAVUq8=@protonmail.com>
 <87bl4jxacl.fsf@HIDDEN>
 <atDsN91XbGZS6ecbC5yOWe2GothSwxFFxxiDQzgAxgA667yjW5TBvcbMYRWgfxfdqJ5D5MnndE5Ac-Kcg9J4DFBlNWZq-gTyPYiMCSQqGAo=@protonmail.com>
 <877df5tqyj.fsf@HIDDEN>
 <oTLxP6KkO1yT3-D-VFh7hv5OTCQhVkuuQkMJfBrhT-0iM_ABsCci7cZzLcFgv-FDCJYP5Swz7d6e7-JtFj4nNeIR0RVdQiH1naGihdidELc=@protonmail.com>
 <87h7e5gtk0.fsf@HIDDEN> <f5746c2c-81f7-f3a0-773e-937a42dcc84b@HIDDEN>
 <87ilyhw6si.fsf@HIDDEN>
From: martin rudalics <rudalics@HIDDEN>
Message-ID: <a708f0e1-c716-1643-24bf-4ba7038100b2@HIDDEN>
Date: Fri, 1 Oct 2021 17:00:03 +0200
MIME-Version: 1.0
In-Reply-To: <87ilyhw6si.fsf@HIDDEN>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-Provags-ID: V03:K1:PGhmFxtiFsN4UlIeHctPKQGKX2ir8VffyYty0YcrVI1LTXxnAD7
 vzMtBM5Vz92wyC8swE8B4i8ym6E+LglYBwfEUAp8falPg8b7iLaeBbLrFCk/GKXmUWtt10K
 ZJcnOaUKBOZIRf7NCKqNeHdSv5zlb1K1TIsWkMAS7SZ6cLnnbO0sL4WMYSWIG9dX2tBEB7i
 3uAtIuEZ6UQ+oFE8IVcYA==
X-Spam-Flag: NO
X-UI-Out-Filterresults: notjunk:1;V03:K0:qoQvgMy2Mk4=:VYdK3QAuLDshbAIZJns6so
 Da9e6e8O1cJV/nXKqm6AX2yVchu0kcjtOXaLPk2YmhUfK4rJr5ccDUAlPIB8Tw2EvkyZttR4d
 pdpLq/MdHUkNe2qjWOkpO3l6enO9zobbA1W2Wiu9D45iBgFIISlg+/ROMxsN9I6ygIY9J8un4
 TUvKIlqfuqHtmkCsnRatplQUd/U8t4mg2SYle/BiuWfcna5oe/f7zMm7X5sLm2da0MKCypEJH
 Ki0JbEOKZk192ulN4xITlgEd+3BddKnn8AWr1R7/db4tNjTYpmbOCSCueJK5DX+U3SWGig414
 VnLPinDrTE11fbfMoVcx155AIuaXnjbWUHjdM0Unt40tKcIPURj0bpj+kgRkab9wRcO/CWiJX
 /4W7eaXZ5ACzPctimabzgsNCf4CT02t23gXt2YbovIQacM6bhucqCzC4ff77iNPkip+wGIA/9
 H6UwM+9Lf/VfWVCTJ7tdTQkUFf5MCYBm0gKFXj8RHL0UI6fXgTEZCsl/vw9vwWafPWSK6KOUh
 qmdSP3RbYGCLay//lO99xr1K5pff4uM6HZPLvFw/HCGPYOI6x/BjQ1g1bdh7/ePG6whair+Xc
 KuuWJ411KbfeffMk9GFBqAMsAZwe1MI6WQNQJ8/zReeuW2DRm3MEk7TU1Hg4m5W0MmgIV4NrG
 g1qjG+IZMmGCDUAtI/BgxFQAB/jnm5MLrcuXrpSRM4MnZR7bybR9kFItX5Qrm/mkOV+mRW5Ca
 o0vOGUo5TgL+Cx9kkXHXxw0YiOkglg82iGs3PmEE57Z52QX/BwNDETpCNnGb7/sNFxRyxNOdO
 k4qq7jCJPb8fExxPHmDj9RP/Ug01tOAr2PJ9beQVyqm07L8m+jm57kuxKExIQeWByKsvCgk7O
 TkoPd7IrTGd8dyrHNxlcVy7SpqPN0QG/+oai0c6kzpm1iNarHgTdEQDTpUedJVTOrP9fqPOno
 r8ow/JaEia7ii2zEEl1KsdP9s/KoLwlBqzzNsXDnlfgLVg6/r24I7HGIbgmoCuwRTC2EqON6Y
 tM7XwyJ4AQQl5AQkWZHQlnjoiQIjAxDaPmnw1mk/UXX5nAevw/Itm+JWrlVtkR2wKUFh6Hn2z
 Kv/6ec3rhKk4y8=
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 50766
Cc: ndame <laszlomail@HIDDEN>, 50766 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

 > I think that it would help users a lot when constructing regexps, so it
 > would be very welcome.

OK.  I'll try to cook up something useful.

 >> It would not handle 'blink-matching-open'.
 >
 > Is there any way to make that work, too?

Hardly.  'blink-matching-paren' is not timer-based.  Doing any parsing
in between would slow down typing.

 > Some people don't like
 > show-paren-mode, but use 'blink-matching-open' instead.

With 'blink-matching-paren' on do C-M-% and type [)].  People who use
'blink-matching-paren' do not type complex regexps.

martin




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#50766; Package emacs. Full text available.

Message received at 50766 <at> debbugs.gnu.org:


Received: (at 50766) by debbugs.gnu.org; 1 Oct 2021 14:29:11 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Oct 01 10:29:11 2021
Received: from localhost ([127.0.0.1]:57021 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mWJXC-0005pT-Ql
	for submit <at> debbugs.gnu.org; Fri, 01 Oct 2021 10:29:11 -0400
Received: from mail-40137.protonmail.ch ([185.70.40.137]:34517)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <laszlomail@HIDDEN>) id 1mWJWw-0005oh-82
 for 50766 <at> debbugs.gnu.org; Fri, 01 Oct 2021 10:29:09 -0400
Date: Fri, 01 Oct 2021 14:28:46 +0000
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com;
 s=protonmail; t=1633098527;
 bh=0YBmUhx186HZQL4dsaVFvMvN0GrpYrDBSXH0XUdXmgk=;
 h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From;
 b=UGzQEhUuhNrEKAg1eBxk8myumCjpbB827BCQ39N3J2JskWqpfJ9eFvgaafv/FC9Td
 6jf9EX0LyGZnUnGyhDlYDpVswmwN6J1Q9UMnl+1sROFrcjL9hamGf6iZzaRIYQcg4E
 pGrJbs3akcJ6YhvxBfKHy8tVHFEIXHSlv9HvCwYI=
To: Lars Ingebrigtsen <larsi@HIDDEN>
From: ndame <laszlomail@HIDDEN>
Subject: Re: bug#50766: Regexp paren pairs in query-replace-regexp prompt
 should be highlighted
Message-ID: <1yqlcMml0l3wVdGLY1Z2JY5i9dsiJwkc19jcWETHoeEhfraWDi2lKO8u9B3wKdVZ6wJxOF3eTe4DJd-qq-jMAJ-kiIpyMqanJNYdhmrLZ2g=@protonmail.com>
In-Reply-To: <87ilyhw6si.fsf@HIDDEN>
References: <1LWmgMt-iOZcz0k2N5IVTqgDu922CLEd8GATVBsqdQfVeBzIGEaVuORC9k0SXORQDkpqc8BO3zxOPFbQeMMhNHQmOvcvIOpOpoWL8CAVUq8=@protonmail.com>
 <87bl4jxacl.fsf@HIDDEN>
 <atDsN91XbGZS6ecbC5yOWe2GothSwxFFxxiDQzgAxgA667yjW5TBvcbMYRWgfxfdqJ5D5MnndE5Ac-Kcg9J4DFBlNWZq-gTyPYiMCSQqGAo=@protonmail.com>
 <877df5tqyj.fsf@HIDDEN>
 <oTLxP6KkO1yT3-D-VFh7hv5OTCQhVkuuQkMJfBrhT-0iM_ABsCci7cZzLcFgv-FDCJYP5Swz7d6e7-JtFj4nNeIR0RVdQiH1naGihdidELc=@protonmail.com>
 <87h7e5gtk0.fsf@HIDDEN> <f5746c2c-81f7-f3a0-773e-937a42dcc84b@HIDDEN>
 <87ilyhw6si.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Status: No, score=-1.2 required=10.0 tests=ALL_TRUSTED,DKIM_SIGNED,
 DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM shortcircuit=no
 autolearn=disabled version=3.4.4
X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on
 mailout.protonmail.ch
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 50766
Cc: martin rudalics <rudalics@HIDDEN>, 50766 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Reply-To: ndame <laszlomail@HIDDEN>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

>
> I think that it would help users a lot when constructing regexps, so it
> would be very welcome.

I wonder if it could be a generic feature which besides working in the
minibuffer for regexps would also work when typing escaped parens in
in strings, e.g. when using a string regexp in a program:

   "stuff ( \\(  ) "

Here it could indicate the mismatching parens.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#50766; Package emacs. Full text available.

Message received at 50766 <at> debbugs.gnu.org:


Received: (at 50766) by debbugs.gnu.org; 1 Oct 2021 07:20:12 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Oct 01 03:20:12 2021
Received: from localhost ([127.0.0.1]:54568 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mWCq3-0004ZC-Uh
	for submit <at> debbugs.gnu.org; Fri, 01 Oct 2021 03:20:12 -0400
Received: from quimby.gnus.org ([95.216.78.240]:50900)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <larsi@HIDDEN>) id 1mWCpz-0004Yc-GS
 for 50766 <at> debbugs.gnu.org; Fri, 01 Oct 2021 03:20:10 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org;
 s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date:
 References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:
 Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender:
 Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:
 List-Subscribe:List-Post:List-Owner:List-Archive;
 bh=lG8YU5pHEZMG7NqJ/JKjbBbqc1VjigMgutDssXeDVUU=; b=IaoY7AV6KjAkMRnKTzgnIj8MOD
 1VVvg+i/jJ1JhxO27ZbLmFpDzsROCGBG/7YvwTOG29ntC15xnUSdA32DHWYbonG+oYtNf1iC9iH4j
 wZHI9ORARGSQWK2dPfbXJ7Xvw/qsFVvfAYbXTAOzHc2s9A0o/Hm6Vdt94h9ZbvkLNBDY=;
Received: from [84.212.220.105] (helo=elva)
 by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.92) (envelope-from <larsi@HIDDEN>)
 id 1mWCpq-0006QQ-4T; Fri, 01 Oct 2021 09:20:00 +0200
From: Lars Ingebrigtsen <larsi@HIDDEN>
To: martin rudalics <rudalics@HIDDEN>
Subject: Re: bug#50766: Regexp paren pairs in query-replace-regexp prompt
 should be highlighted
References: <1LWmgMt-iOZcz0k2N5IVTqgDu922CLEd8GATVBsqdQfVeBzIGEaVuORC9k0SXORQDkpqc8BO3zxOPFbQeMMhNHQmOvcvIOpOpoWL8CAVUq8=@protonmail.com>
 <87bl4jxacl.fsf@HIDDEN>
 <atDsN91XbGZS6ecbC5yOWe2GothSwxFFxxiDQzgAxgA667yjW5TBvcbMYRWgfxfdqJ5D5MnndE5Ac-Kcg9J4DFBlNWZq-gTyPYiMCSQqGAo=@protonmail.com>
 <877df5tqyj.fsf@HIDDEN>
 <oTLxP6KkO1yT3-D-VFh7hv5OTCQhVkuuQkMJfBrhT-0iM_ABsCci7cZzLcFgv-FDCJYP5Swz7d6e7-JtFj4nNeIR0RVdQiH1naGihdidELc=@protonmail.com>
 <87h7e5gtk0.fsf@HIDDEN>
 <f5746c2c-81f7-f3a0-773e-937a42dcc84b@HIDDEN>
Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAgMAAAAqbBEUAAAAAXNSR0IArs4c6QAAAAlQTFRF
 0K6PNzEs////OZlX6wAAAAFiS0dEAmYLfGQAAAAJcEhZcwAACxIAAAsSAdLdfvwAAAAHdElNRQfl
 CgEGJjcHvwXMAAAASElEQVQoz2NgGCYgNBTBZgwNdYBzWENDA+Ac0dBQFyQtoa5YOYwgjgMuTihx
 nBAHJKNDkTmO2J3DGhoigvCCgyjCCyieG9oAACIWFVbu726BAAAAWmVYSWZNTQAqAAAACAAFARIA
 AwAAAAEAAQAAARoABQAAAAEAAABKARsABQAAAAEAAABSASgAAwAAAAEAAgAAAhMAAwAAAAEAAQAA
 AAAAAAAAAEgAAAABAAAASAAAAAEfUvc0AAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDIxLTEwLTAxVDA2
 OjM4OjU1KzAwOjAw4LNwDgAAACV0RVh0ZGF0ZTptb2RpZnkAMjAyMS0xMC0wMVQwNjozODo1NSsw
 MDowMJHuyLIAAAAXdEVYdGV4aWY6WUNiQ3JQb3NpdGlvbmluZwAxrA+AYwAAADh0RVh0aWNjOmNv
 cHlyaWdodABDb3B5cmlnaHQgKGMpIDE5OTggSGV3bGV0dC1QYWNrYXJkIENvbXBhbnn5V3k3AAAA
 IXRFWHRpY2M6ZGVzY3JpcHRpb24Ac1JHQiBJRUM2MTk2Ni0yLjFXrdpHAAAAJnRFWHRpY2M6bWFu
 dWZhY3R1cmVyAElFQyBodHRwOi8vd3d3LmllYy5jaBx/AEwAAAA3dEVYdGljYzptb2RlbABJRUMg
 NjE5NjYtMi4xIERlZmF1bHQgUkdCIGNvbG91ciBzcGFjZSAtIHNSR0JEU0ipAAAAAElFTkSuQmCC
X-Now-Playing: The Notwist's _Vertigo Dubs Vol. 1: Odd Nosdam_: "Ship (Odd
 Nosdam Remix)"
Date: Fri, 01 Oct 2021 09:19:57 +0200
In-Reply-To: <f5746c2c-81f7-f3a0-773e-937a42dcc84b@HIDDEN> (martin rudalics's
 message of "Thu, 30 Sep 2021 18:18:02 +0200")
Message-ID: <87ilyhw6si.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 @@CONTACT_ADDRESS@@ for details.
 Content preview:  martin rudalics <rudalics@HIDDEN> writes: > I have written
 such code for Elisp buffers and can convert and simplify > it to make it
 work for minibuffers. I suppose it would amount to about > 100 lines to add
 to paren.el and would do it only i [...] 
 Content analysis details:   (-2.9 points, 5.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -1.0 ALL_TRUSTED            Passed through trusted hosts only via SMTP
 -1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%
 [score: 0.0000]
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 50766
Cc: ndame <laszlomail@HIDDEN>, 50766 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

martin rudalics <rudalics@HIDDEN> writes:

> I have written such code for Elisp buffers and can convert and simplify
> it to make it work for minibuffers.  I suppose it would amount to about
> 100 lines to add to paren.el and would do it only if you are convinced
> that it's worth the effort.

I think that it would help users a lot when constructing regexps, so it
would be very welcome.

> It would not handle 'blink-matching-open'.

Is there any way to make that work, too?  Some people don't like
show-paren-mode, but use 'blink-matching-open' instead.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#50766; Package emacs. Full text available.

Message received at 50766 <at> debbugs.gnu.org:


Received: (at 50766) by debbugs.gnu.org; 30 Sep 2021 16:18:14 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Sep 30 12:18:13 2021
Received: from localhost ([127.0.0.1]:53784 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mVylB-00050A-Js
	for submit <at> debbugs.gnu.org; Thu, 30 Sep 2021 12:18:13 -0400
Received: from mout.gmx.net ([212.227.15.19]:55901)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <rudalics@HIDDEN>) id 1mVyl9-0004zt-Du
 for 50766 <at> debbugs.gnu.org; Thu, 30 Sep 2021 12:18:12 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net;
 s=badeba3b8450; t=1633018685;
 bh=hbpXJMK72JfAxMEsi2zSabE3XV9PeecT2YW55sQ50vo=;
 h=X-UI-Sender-Class:Subject:To:Cc:References:From:Date:In-Reply-To;
 b=lR0wd3qr5NkDfce37bBndJTy+sl3i1pEDHLcWoRNmdFBoH+cg5+NrLi78mb+ZnJgA
 jbXYBgxiRHN2c4hIsulL7bdmKiB7DbVH1P0DUg4DuGwHa6gEuaq5ojpGqEuXtcqC1A
 OhvjXM056F5xrFcBbBVfF0JfMX3YjKNG2pE5fPRU=
X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c
Received: from [192.168.1.101] ([46.125.249.119]) by mail.gmx.net (mrgmx004
 [212.227.17.190]) with ESMTPSA (Nemesis) id 1M7sDg-1mS90A2WJ8-004xE4; Thu, 30
 Sep 2021 18:18:04 +0200
Subject: Re: bug#50766: Regexp paren pairs in query-replace-regexp prompt
 should be highlighted
To: Lars Ingebrigtsen <larsi@HIDDEN>, ndame <laszlomail@HIDDEN>
References: <1LWmgMt-iOZcz0k2N5IVTqgDu922CLEd8GATVBsqdQfVeBzIGEaVuORC9k0SXORQDkpqc8BO3zxOPFbQeMMhNHQmOvcvIOpOpoWL8CAVUq8=@protonmail.com>
 <87bl4jxacl.fsf@HIDDEN>
 <atDsN91XbGZS6ecbC5yOWe2GothSwxFFxxiDQzgAxgA667yjW5TBvcbMYRWgfxfdqJ5D5MnndE5Ac-Kcg9J4DFBlNWZq-gTyPYiMCSQqGAo=@protonmail.com>
 <877df5tqyj.fsf@HIDDEN>
 <oTLxP6KkO1yT3-D-VFh7hv5OTCQhVkuuQkMJfBrhT-0iM_ABsCci7cZzLcFgv-FDCJYP5Swz7d6e7-JtFj4nNeIR0RVdQiH1naGihdidELc=@protonmail.com>
 <87h7e5gtk0.fsf@HIDDEN>
From: martin rudalics <rudalics@HIDDEN>
Message-ID: <f5746c2c-81f7-f3a0-773e-937a42dcc84b@HIDDEN>
Date: Thu, 30 Sep 2021 18:18:02 +0200
MIME-Version: 1.0
In-Reply-To: <87h7e5gtk0.fsf@HIDDEN>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
X-Provags-ID: V03:K1:kf3uy7oUCPlU+dU3Pp2wRqkdBzx+pkRFMCmH4nprgS2yCjAA/ZF
 p2hHXgnQiMqarERKI1AZukgVn+bgxiKM1A40RNKGzsxZLeN3w108st2yZ/4xxoFmiHEXkA7
 CnJrfdSWdXeku5h1ERjrZVCLuYcueqhEDiPcCodxDiq3d99IXxqbTL7I7OyWSPXzoHy+PLZ
 h/R/5F1ZxfepqK4wMUMjw==
X-Spam-Flag: NO
X-UI-Out-Filterresults: notjunk:1;V03:K0:HhnxrU+Atwo=:MrQEllsZevDyvYNT7gOakL
 WA3cvJ0wne1+nnAgbFoLy6JXBye+ABnr/cGHyqFR99yGYCqWNZ2E2PaUZgt40J0F1mv6SgzVh
 spqbYEcTibUrDsNfakx4v9qldsMNahqNg3nGZCsORRFoCuqoR6exLEVoV9xwF/E1HTOyeLjtm
 1s/X7T35ydM8tcJq7qSRzlN7J9kOErJF3/qSjL31mue2zKjeb7kNOaPR5q+WuIF9q94C4qZUE
 Uyjviub9+Ai0P42635TwQQmecfeCInWhrS4kp+TmP41xmaof6GaNP6vWtWIVl4YHhLeLFllQi
 kHJC+zgUwzBnuzYpgtXOJgQXJQTBYYZ+hOasbMYRDx9TMHWvPCgjYNgw3TvYO5WlN2oKOzO0x
 2hPM9BVGr0p0+3arPvGRXrAWENNRBm89dJmqYxk+XLeUlSrrtM7nHnY5LV0ljGX8bQvdR/hH2
 ryQPskkQ7+X72+o+5NOwsVn4pI/nhzngUXM2nuGAT5kFVks1kJQMEMwVfpcMdBC+JoJp6sZnt
 PjTKYBnR/w4bN7OJXne9p54occXbT0z0Pe7PbbHfCfTrb9pEcFRoNykdSCLxRDvjMrCpdfwz5
 C1KS9dgUeR44ZGX2O27jg6dylr4JvnXLg9jK7a0uszXhHxpzONGB9pp27HuwH6zpd4k9+6zeK
 r3xFQJsNaLYAXqxG6wc2dqvNWG3b5yRAiUARW2nI8aUaiB6tnIA4a5QgRmS9f0LozQ8aRh0TF
 2hXOoDHMCrT3TtIF4Kjpp4cE1WOnSZ+sJjqXWVOQyNo0otagSzxgOgL5U74Akyp2HE0LxyaTX
 50xIz86FUS6X4SCWwLA3iip4eg17si+VV+rDK9lZmKloIM95D/S/pXvReUYN0QWa8lXdAt+Y7
 rO7w/1dSop114wXuYocbIOpGILzrZmcBRZtlLdLkRABEUzqiToNSnyyk90N4S2JZ+Z+8rsKF6
 Sx6oE59EtUDPuQZI++Vs8eg+cPFa6iD7c9ExOTcrOKv8g4QPU7zAXn7AhvLeEcr19RFRND0B8
 T1l4Tj5lVJNnIgmXwynbEsRC6wFD6mPnOcZcKNvXwtYbeyRPZEoJzKmTHW/9z7V/pdzjatuN8
 gK7Jedo4YwpsmG+vQZX6ZQ+/WHeVekztDYy
X-Spam-Score: 2.9 (++)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 Content preview: > Indeed. I wondered whether we had code that did the right
 syntax > marking for regexps so that this would work, but I guess not? It's
 not entirely trivial: With "\(" you normally want to put the syntax table
 property on the "\" but inside a character alternative you want to put it
 on the "(". So you have to re-parse the minibuf [...] 
 Content analysis details:   (2.9 points, 10.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 3.6 RCVD_IN_SBL_CSS        RBL: Received via a relay in Spamhaus SBL-CSS
 [46.125.249.119 listed in zen.spamhaus.org]
 -0.0 SPF_PASS               SPF: sender matches SPF record
 0.0 FREEMAIL_FROM          Sender email is commonly abused enduser mail
 provider (rudalics[at]gmx.at)
 0.0 SPF_HELO_NONE          SPF: HELO does not publish an SPF Record
 -0.7 RCVD_IN_DNSWL_LOW      RBL: Sender listed at https://www.dnswl.org/,
 low trust [212.227.15.19 listed in list.dnswl.org]
 -0.0 RCVD_IN_MSPIKE_H2      RBL: Average reputation (+2)
 [212.227.15.19 listed in wl.mailspike.net]
X-Debbugs-Envelope-To: 50766
Cc: 50766 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 1.9 (+)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 
 Content preview:  > Indeed. I wondered whether we had code that did the right
    syntax > marking for regexps so that this would work, but I guess not? It's
    not entirely trivial: With "\(" you normally want to put the syntax table
    property on the "\" but inside a character alternative you want to put it
    on the "(". So you have to re-parse the minibuf [...] 
 
 Content analysis details:   (1.9 points, 10.0 required)
 
  pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -0.0 RCVD_IN_MSPIKE_H2      RBL: Average reputation (+2)
                             [212.227.15.19 listed in wl.mailspike.net]
  3.6 RCVD_IN_SBL_CSS        RBL: Received via a relay in Spamhaus SBL-CSS
                             [46.125.249.119 listed in zen.spamhaus.org]
 -0.7 RCVD_IN_DNSWL_LOW      RBL: Sender listed at https://www.dnswl.org/,
                             low trust
                             [212.227.15.19 listed in list.dnswl.org]
 -0.0 SPF_PASS               SPF: sender matches SPF record
  0.0 FREEMAIL_FROM          Sender email is commonly abused enduser mail
                             provider (rudalics[at]gmx.at)
  0.0 SPF_HELO_NONE          SPF: HELO does not publish an SPF Record
 -1.0 MAILING_LIST_MULTI     Multiple indicators imply a widely-seen list
                             manager

 > Indeed.  I wondered whether we had code that did the right syntax
 > marking for regexps so that this would work, but I guess not?

It's not entirely trivial: With "\(" you normally want to put the syntax
table property on the "\" but inside a character alternative you want to
put it on the "(".  So you have to re-parse the minibuffer after each
editing change.

Which means we'd have to, at the beginning of 'show-paren--default',

- check whether this is a minibuffer where we want that feature enabled,

- enable 'parse-sexp-lookup-properties' for it,

- syntactically propertize parens, brackets, braces and backslashes
   according to their positions within the regexp typed.

That's all.  What it would get us are regexps with properly highlighted
parens and proper sexp navigation.

I have written such code for Elisp buffers and can convert and simplify
it to make it work for minibuffers.  I suppose it would amount to about
100 lines to add to paren.el and would do it only if you are convinced
that it's worth the effort.  It would not handle 'blink-matching-open'.

martin




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#50766; Package emacs. Full text available.
Severity set to 'wishlist' from 'normal' Request was from Stefan Kangas <stefan@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 50766 <at> debbugs.gnu.org:


Received: (at 50766) by debbugs.gnu.org; 28 Sep 2021 05:26:07 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Sep 28 01:26:07 2021
Received: from localhost ([127.0.0.1]:43472 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mV5d0-0004a3-Te
	for submit <at> debbugs.gnu.org; Tue, 28 Sep 2021 01:26:07 -0400
Received: from quimby.gnus.org ([95.216.78.240]:41000)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <larsi@HIDDEN>) id 1mV5cy-0004Yy-Nb
 for 50766 <at> debbugs.gnu.org; Tue, 28 Sep 2021 01:26:05 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org;
 s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date:
 References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:
 Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender:
 Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:
 List-Subscribe:List-Post:List-Owner:List-Archive;
 bh=3/LxNcS+hqk4pKFxPhy6dVwa3SWZ5VfMgu0i1hRS/3U=; b=B2+z6Vcq1hdG7IQnhuYiOi39yo
 H5XRp8vAIW2nrjVRB5Sc7bC0zVSrqn7rnjmQMHUiHSu/IcmRLRtcdF7ukkZbeIh8g+Od/G6d3ghnM
 2VW2zAexWiM956g2PAfkiX8zxDBCEwp2lWUwJJ31Gj0DDxGwiABfF+zmt7nd29pf07yo=;
Received: from [84.212.220.105] (helo=elva)
 by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.92) (envelope-from <larsi@HIDDEN>)
 id 1mV5cq-0007d0-1X; Tue, 28 Sep 2021 07:25:58 +0200
From: Lars Ingebrigtsen <larsi@HIDDEN>
To: ndame <laszlomail@HIDDEN>
Subject: Re: bug#50766: Regexp paren pairs in query-replace-regexp prompt
 should be highlighted
References: <1LWmgMt-iOZcz0k2N5IVTqgDu922CLEd8GATVBsqdQfVeBzIGEaVuORC9k0SXORQDkpqc8BO3zxOPFbQeMMhNHQmOvcvIOpOpoWL8CAVUq8=@protonmail.com>
 <87bl4jxacl.fsf@HIDDEN>
 <atDsN91XbGZS6ecbC5yOWe2GothSwxFFxxiDQzgAxgA667yjW5TBvcbMYRWgfxfdqJ5D5MnndE5Ac-Kcg9J4DFBlNWZq-gTyPYiMCSQqGAo=@protonmail.com>
 <877df5tqyj.fsf@HIDDEN>
 <oTLxP6KkO1yT3-D-VFh7hv5OTCQhVkuuQkMJfBrhT-0iM_ABsCci7cZzLcFgv-FDCJYP5Swz7d6e7-JtFj4nNeIR0RVdQiH1naGihdidELc=@protonmail.com>
Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAACBj
 SFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAFVBMVEXYebPYd7KtYpCK
 TnJHKDvwyeL////KdnvEAAAAAWJLR0QGYWa4fQAAAAlwSFlzAAAAZAAAAGQAD5bF3QAAAAd0SU1F
 B+UJHAUVGyaZR9QAAAGlSURBVDjLbZNtjoQgDIYLM/wHXP8reIDNlBMMHABnw/2vsgVEUaeJIekj
 Lf14Aa7GZmYRw80PWhobXAB1GJOKaWOGgC4ESCKmmEQiExBFNPOyAbKYimUaP9p58lcgs3MsYFqH
 UKyANbMKIlvCcSN24IPdDZYSbED8uQ5AAzHND4e4hyrRMvibjEVvMRx1xCSjsM5jNk8EjqJVjY4F
 9r3SW9rgTb5x2BJ668DzDHICpSR93J8AVUCFUVtFpLY2t2t1xFz16uyWfe/VuJaBPOu73kstMHdo
 pQqpymjyz78lRxwrYKX9+oXO/xzJRZ0t/cEx2KO7dYjF4LE/t05btjPn9/wC6NEy+0EPe6h28vwq
 MOCAhkHpRT3HRA17M1gsgsqTYKqes6IdkQD8xU/rrCVYQ36QFKwHw8Symyma/AlwyYsOtEV3AlKa
 ogN91YdRE+GJW3cB3FB8rcrGndWk6KFNOBfjryaciy2zvq1P3TqKFNwXwEmy3wCzFr+GotJIm3gD
 A70H0d5AESxpwJ23veogq4Ng30TVdED6OPVqaBvtLznaRlX7B5KPsgegCyajAAAAJXRFWHRkYXRl
 OmNyZWF0ZQAyMDIxLTA5LTI4VDA1OjIxOjI3KzAwOjAwT9vIeAAAACV0RVh0ZGF0ZTptb2RpZnkA
 MjAyMS0wOS0yOFQwNToyMToyNyswMDowMD6GcMQAAAAASUVORK5CYII=
X-Now-Playing: Hexting's _Post Post Rock Rock_: "Bit Mac, No Tomato -Waiting
 for ketchup"
Date: Tue, 28 Sep 2021 07:25:51 +0200
In-Reply-To: <oTLxP6KkO1yT3-D-VFh7hv5OTCQhVkuuQkMJfBrhT-0iM_ABsCci7cZzLcFgv-FDCJYP5Swz7d6e7-JtFj4nNeIR0RVdQiH1naGihdidELc=@protonmail.com>
 (ndame's message of "Mon, 27 Sep 2021 13:16:41 +0000")
Message-ID: <87h7e5gtk0.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 @@CONTACT_ADDRESS@@ for details.
 Content preview: ndame <laszlomail@HIDDEN> writes: > So blinking
 should
 be able to handle escaped and non-escaped parens too and > pair them properly.
 Indeed. I wondered whether we had code that did the right syntax marking
 for regexps so that this would work, but I guess not? 
 Content analysis details:   (-2.9 points, 5.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -1.0 ALL_TRUSTED            Passed through trusted hosts only via SMTP
 -1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%
 [score: 0.0000]
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 50766
Cc: 50766 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

ndame <laszlomail@HIDDEN> writes:

> So blinking should be able to handle escaped and non-escaped parens too and
> pair them properly.

Indeed.  I wondered whether we had code that did the right syntax
marking for regexps so that this would work, but I guess not?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#50766; Package emacs. Full text available.

Message received at 50766 <at> debbugs.gnu.org:


Received: (at 50766) by debbugs.gnu.org; 27 Sep 2021 13:17:05 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Sep 27 09:17:05 2021
Received: from localhost ([127.0.0.1]:40061 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mUqVE-0000g2-P9
	for submit <at> debbugs.gnu.org; Mon, 27 Sep 2021 09:17:05 -0400
Received: from mail-40130.protonmail.ch ([185.70.40.130]:51402)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <laszlomail@HIDDEN>) id 1mUqUy-0000f2-TS
 for 50766 <at> debbugs.gnu.org; Mon, 27 Sep 2021 09:17:04 -0400
Date: Mon, 27 Sep 2021 13:16:41 +0000
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com;
 s=protonmail; t=1632748602;
 bh=eOy53O9qIJ9QAzgXtlpWR7UXlTi8x/toevvZ1JV9gDs=;
 h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From;
 b=nSZXM0mi/LsJtD8ZJnDZvEG9V2WBMW4tuPdf8XGi3vwiDJNa7Qut4489f2zujm1vL
 E5XF+Pleg834NhKMI4sqvZzY22c+DBJEbXv1UEEKK0/jHCTR9l3L1Xtv81prgjvHzP
 WHIiPn2uNO7ydBRWy//RrlCvzCZSlMjmqgRHw3Lo=
To: Lars Ingebrigtsen <larsi@HIDDEN>
From: ndame <laszlomail@HIDDEN>
Subject: Re: bug#50766: Regexp paren pairs in query-replace-regexp prompt
 should be highlighted
Message-ID: <oTLxP6KkO1yT3-D-VFh7hv5OTCQhVkuuQkMJfBrhT-0iM_ABsCci7cZzLcFgv-FDCJYP5Swz7d6e7-JtFj4nNeIR0RVdQiH1naGihdidELc=@protonmail.com>
In-Reply-To: <877df5tqyj.fsf@HIDDEN>
References: <1LWmgMt-iOZcz0k2N5IVTqgDu922CLEd8GATVBsqdQfVeBzIGEaVuORC9k0SXORQDkpqc8BO3zxOPFbQeMMhNHQmOvcvIOpOpoWL8CAVUq8=@protonmail.com>
 <87bl4jxacl.fsf@HIDDEN>
 <atDsN91XbGZS6ecbC5yOWe2GothSwxFFxxiDQzgAxgA667yjW5TBvcbMYRWgfxfdqJ5D5MnndE5Ac-Kcg9J4DFBlNWZq-gTyPYiMCSQqGAo=@protonmail.com>
 <877df5tqyj.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Status: No, score=-1.2 required=10.0 tests=ALL_TRUSTED,DKIM_SIGNED,
 DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM shortcircuit=no
 autolearn=disabled version=3.4.4
X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on
 mailout.protonmail.ch
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 50766
Cc: 50766 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Reply-To: ndame <laszlomail@HIDDEN>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

>
> But doesn't it already have escape syntax? That's why (...) blinks and
> \(...\) doesn't blink, I'd have thought. (But I haven't tested it.)

Optimally, both should blink, but only for their fitting pairs.

So, \( does not match ), no blink, but it matches \), there should be a bli=
nk.
And vica versa for (.


> The problem is, though, that we do want \ to escape some things (like
> \[, which is the literal [ character), but the logic is the opposite

Even the literal character can have a matching \] part for which it should
blink, because it helps the user to see which literal \[ he closed.

So blinking should be able to handle escaped and non-escaped parens too and
pair them properly.





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#50766; Package emacs. Full text available.

Message received at 50766 <at> debbugs.gnu.org:


Received: (at 50766) by debbugs.gnu.org; 25 Sep 2021 00:55:01 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Sep 24 20:55:01 2021
Received: from localhost ([127.0.0.1]:59622 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mTvxw-0000Zr-H0
	for submit <at> debbugs.gnu.org; Fri, 24 Sep 2021 20:55:00 -0400
Received: from quimby.gnus.org ([95.216.78.240]:33284)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <larsi@HIDDEN>) id 1mTvxi-0000ZJ-4W
 for 50766 <at> debbugs.gnu.org; Fri, 24 Sep 2021 20:54:55 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org;
 s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date:
 References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:
 Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender:
 Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:
 List-Subscribe:List-Post:List-Owner:List-Archive;
 bh=X0g7RQiWFRBfJQYysa5r+/wI1uiF9dd9FYNkhI8S09A=; b=Y+CUOmmraapKVgMGPLpuO7c/GX
 t6Asjio/KmgZGpF53xXLZMvQtJ7nGKmpwQvkaJk4rJH/u5MfJoA4wsOQSjPt6VFNlvw76o9VX758Q
 NjzLkxI9YXSMlTAQ9gJ2nFfHWbmNIvVMc7k4BaHDQN3wPmLIgYjUbi+6UzPEIDXnFKyg=;
Received: from [84.212.220.105] (helo=elva)
 by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.92) (envelope-from <larsi@HIDDEN>)
 id 1mTvxZ-0007ak-Iv; Sat, 25 Sep 2021 02:54:36 +0200
From: Lars Ingebrigtsen <larsi@HIDDEN>
To: ndame <laszlomail@HIDDEN>
Subject: Re: bug#50766: Regexp paren pairs in query-replace-regexp prompt
 should be highlighted
References: <1LWmgMt-iOZcz0k2N5IVTqgDu922CLEd8GATVBsqdQfVeBzIGEaVuORC9k0SXORQDkpqc8BO3zxOPFbQeMMhNHQmOvcvIOpOpoWL8CAVUq8=@protonmail.com>
 <87bl4jxacl.fsf@HIDDEN>
 <atDsN91XbGZS6ecbC5yOWe2GothSwxFFxxiDQzgAxgA667yjW5TBvcbMYRWgfxfdqJ5D5MnndE5Ac-Kcg9J4DFBlNWZq-gTyPYiMCSQqGAo=@protonmail.com>
Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAAAAAByaaZbAAAAAXNSR0IArs4c6QAAAAJiS0dE
 AP+Hj8y/AAAACXBIWXMAAAsSAAALEgHS3X78AAAAB3RJTUUH5QkZACQX2Gc+lAAAAJhJREFUSMft
 k9ENgCAMRIGwkqPclF3KUfzBQC3aw/ihwX4R0tdryxHXMBZpMH9OIAeUk3BAXOqZQlqgIXBaQQF7
 BjolyKFhLrRCCGKSRPNDa0WnJSgBsV2lXpWrgZyWrETml4R+Sx7Gb6lgiTEQGo3jw7nxwh9344tS
 UU3MKTSmJxXqQzw/tGgBFzDOcRUwChxjSvP9wEeBDeQcFNLrTcmuAAAAJXRFWHRkYXRlOmNyZWF0
 ZQAyMDIxLTA5LTI1VDAwOjM2OjIzKzAwOjAwjKPZmAAAACV0RVh0ZGF0ZTptb2RpZnkAMjAyMS0w
 OS0yNVQwMDozNjoyMyswMDowMP3+YSQAAAA4dEVYdGljYzpjb3B5cmlnaHQAQ29weXJpZ2h0IChj
 KSAxOTk4IEhld2xldHQtUGFja2FyZCBDb21wYW55+Vd5NwAAACF0RVh0aWNjOmRlc2NyaXB0aW9u
 AHNSR0IgSUVDNjE5NjYtMi4xV63aRwAAACZ0RVh0aWNjOm1hbnVmYWN0dXJlcgBJRUMgaHR0cDov
 L3d3dy5pZWMuY2gcfwBMAAAAN3RFWHRpY2M6bW9kZWwASUVDIDYxOTY2LTIuMSBEZWZhdWx0IFJH
 QiBjb2xvdXIgc3BhY2UgLSBzUkdCRFNIqQAAAABJRU5ErkJggg==
X-Now-Playing: Lost Girls's _Menneskekollektivet_: "Love, Lovers"
Date: Sat, 25 Sep 2021 02:54:28 +0200
In-Reply-To: <atDsN91XbGZS6ecbC5yOWe2GothSwxFFxxiDQzgAxgA667yjW5TBvcbMYRWgfxfdqJ5D5MnndE5Ac-Kcg9J4DFBlNWZq-gTyPYiMCSQqGAo=@protonmail.com>
 (ndame's message of "Fri, 24 Sep 2021 08:27:22 +0000")
Message-ID: <877df5tqyj.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 @@CONTACT_ADDRESS@@ for details.
 Content preview: ndame <laszlomail@HIDDEN> writes: > Looks like
 setting
 the syntax in the minibuffer fixes this: > > (modify-syntax-entry ?\\ "\\"
 (syntax-table)) > > So the syntax of \ in the minibuffer should be changed
 temporarily to > escape-synta [...] 
 Content analysis details:   (-2.9 points, 5.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -1.0 ALL_TRUSTED            Passed through trusted hosts only via SMTP
 -1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%
 [score: 0.0000]
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 50766
Cc: 50766 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

ndame <laszlomail@HIDDEN> writes:

> Looks like setting the syntax in the minibuffer fixes this:
>
> (modify-syntax-entry ?\\ "\\" (syntax-table))
>
> So the syntax of \  in the minibuffer should be changed temporarily to
> escape-syntax during  read-regexp.

But doesn't it already have escape syntax?  That's why (...) blinks and
\(...\) doesn't blink, I'd have thought.  (But I haven't tested it.)

The problem is, though, that we do want \ to escape some things (like
\[, which is the literal [ character), but the logic is the opposite
with ( and ).

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#50766; Package emacs. Full text available.

Message received at 50766 <at> debbugs.gnu.org:


Received: (at 50766) by debbugs.gnu.org; 24 Sep 2021 08:27:31 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Sep 24 04:27:31 2021
Received: from localhost ([127.0.0.1]:56677 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mTgYM-0006LU-VF
	for submit <at> debbugs.gnu.org; Fri, 24 Sep 2021 04:27:31 -0400
Received: from mail-4324.protonmail.ch ([185.70.43.24]:30895)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <laszlomail@HIDDEN>) id 1mTgYL-0006LD-DQ
 for 50766 <at> debbugs.gnu.org; Fri, 24 Sep 2021 04:27:30 -0400
Date: Fri, 24 Sep 2021 08:27:22 +0000
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com;
 s=protonmail; t=1632472042;
 bh=jx6pqd9uVxr3qaJWFwbhpicAzB+ljXDMeW28wPcuSfs=;
 h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From;
 b=EqIOwzofQy4U9LRd70xX/pu4rmk+zWoU4+BgRdFZAf0OK2DmF/aLicIVgX1XzsTtA
 PrKm6ssiemxrhm3dCF7r/Hx5lw6wdAUUtXGGjvzdBjj34eT3eJo4VMeW/YYemy+83T
 x4G8nHj0w9MRg3+9kWgVELqX9fUOeKwy/4Q03kd4=
To: Lars Ingebrigtsen <larsi@HIDDEN>
From: ndame <laszlomail@HIDDEN>
Subject: Re: bug#50766: Regexp paren pairs in query-replace-regexp prompt
 should be highlighted
Message-ID: <atDsN91XbGZS6ecbC5yOWe2GothSwxFFxxiDQzgAxgA667yjW5TBvcbMYRWgfxfdqJ5D5MnndE5Ac-Kcg9J4DFBlNWZq-gTyPYiMCSQqGAo=@protonmail.com>
In-Reply-To: <87bl4jxacl.fsf@HIDDEN>
References: <1LWmgMt-iOZcz0k2N5IVTqgDu922CLEd8GATVBsqdQfVeBzIGEaVuORC9k0SXORQDkpqc8BO3zxOPFbQeMMhNHQmOvcvIOpOpoWL8CAVUq8=@protonmail.com>
 <87bl4jxacl.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Status: No, score=-1.2 required=10.0 tests=ALL_TRUSTED,DKIM_SIGNED,
 DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM shortcircuit=no
 autolearn=disabled version=3.4.4
X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on
 mailout.protonmail.ch
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 50766
Cc: 50766 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Reply-To: ndame <laszlomail@HIDDEN>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Looks like setting the syntax in the minibuffer fixes this:

(modify-syntax-entry ?\\ "\\" (syntax-table))

So the syntax of \  in the minibuffer should be changed temporarily to
escape-syntax during  read-regexp.






Information forwarded to bug-gnu-emacs@HIDDEN:
bug#50766; Package emacs. Full text available.

Message received at 50766 <at> debbugs.gnu.org:


Received: (at 50766) by debbugs.gnu.org; 23 Sep 2021 21:15:19 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Sep 23 17:15:18 2021
Received: from localhost ([127.0.0.1]:56019 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mTW3q-0004Je-My
	for submit <at> debbugs.gnu.org; Thu, 23 Sep 2021 17:15:18 -0400
Received: from quimby.gnus.org ([95.216.78.240]:47942)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <larsi@HIDDEN>) id 1mTW3o-0004JO-VA
 for 50766 <at> debbugs.gnu.org; Thu, 23 Sep 2021 17:15:17 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org;
 s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date:
 References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:
 Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender:
 Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:
 List-Subscribe:List-Post:List-Owner:List-Archive;
 bh=7M3VsFmkt/c4F4J3ehNk7agcDFoXbp4fs+qAzBUPLio=; b=M5hHJtFBcFtVOfpeTeyAUH5nmq
 +zZgCOFzlChgSPgRNPhprMOghS7MqZBgfueSMNUrxl4RV1G1Q5KV35fclfEwjBFVNyVhiRJYVgOT+
 TotjTQ19RnAMgHnypalNAxJdL9FOB7i2+awfvfN13w2376gyaql0pl+jQDPKhuBg0b4s=;
Received: from [84.212.220.105] (helo=elva)
 by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.92) (envelope-from <larsi@HIDDEN>)
 id 1mTW3f-0006xi-Be; Thu, 23 Sep 2021 23:15:10 +0200
From: Lars Ingebrigtsen <larsi@HIDDEN>
To: ndame <laszlomail@HIDDEN>
Subject: Re: bug#50766: Regexp paren pairs in query-replace-regexp prompt
 should be highlighted
References: <1LWmgMt-iOZcz0k2N5IVTqgDu922CLEd8GATVBsqdQfVeBzIGEaVuORC9k0SXORQDkpqc8BO3zxOPFbQeMMhNHQmOvcvIOpOpoWL8CAVUq8=@protonmail.com>
X-Now-Playing: Magnus Granberg & Skogen's _Let Pass My Weary Guiltless
 Ghost_: "Let Pass My Weary Guiltless Ghost"
Date: Thu, 23 Sep 2021 23:15:06 +0200
In-Reply-To: <1LWmgMt-iOZcz0k2N5IVTqgDu922CLEd8GATVBsqdQfVeBzIGEaVuORC9k0SXORQDkpqc8BO3zxOPFbQeMMhNHQmOvcvIOpOpoWL8CAVUq8=@protonmail.com>
 (ndame's message of "Thu, 23 Sep 2021 16:59:47 +0000")
Message-ID: <87bl4jxacl.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 @@CONTACT_ADDRESS@@ for details.
 Content preview: ndame <laszlomail@HIDDEN> writes: > Emacs highlights
 parents by default, e.g. when point is after the closing > paren the opening
 parent is highlighted. > > If I type capturing parens in the query replace
 regexp prompt then the > pare [...] 
 Content analysis details:   (-2.9 points, 5.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -1.0 ALL_TRUSTED            Passed through trusted hosts only via SMTP
 -1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%
 [score: 0.0000]
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 50766
Cc: 50766 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

ndame <laszlomail@HIDDEN> writes:

> Emacs highlights parents by default, e.g. when point is after the closing
> paren  the opening parent is highlighted.
>
> If I type capturing parens in the query replace regexp prompt then the
> paren pairs are not highlighted:
>
>    Query replace regexp: \(something\)
>
> They should be, so when typing a complex regexp with multiple capturing
> parens then it's easier to see the pairs.

Let's see...  this basically ends up calling `read-regexp', which then
calls `read-from-minibuffer'.

The blinking is done from `blink-matching-open', which does a
`(forward-sexp -1)' to find the position.

So we'd have to set up some syntax stuff to get this right.  Does
anybody know if we have something ready-made for regexps somewhere?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#50766; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 23 Sep 2021 17:00:04 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Sep 23 13:00:04 2021
Received: from localhost ([127.0.0.1]:55719 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mTS4q-0007Ut-1r
	for submit <at> debbugs.gnu.org; Thu, 23 Sep 2021 13:00:04 -0400
Received: from lists.gnu.org ([209.51.188.17]:47014)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <laszlomail@HIDDEN>) id 1mTS4o-0007Uc-8A
 for submit <at> debbugs.gnu.org; Thu, 23 Sep 2021 13:00:02 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:40188)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <laszlomail@HIDDEN>)
 id 1mTS4n-0005OX-Sc
 for bug-gnu-emacs@HIDDEN; Thu, 23 Sep 2021 13:00:01 -0400
Received: from mail-40132.protonmail.ch ([185.70.40.132]:29259)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <laszlomail@HIDDEN>)
 id 1mTS4l-00053O-Oo
 for bug-gnu-emacs@HIDDEN; Thu, 23 Sep 2021 13:00:01 -0400
Date: Thu, 23 Sep 2021 16:59:47 +0000
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com;
 s=protonmail; t=1632416389;
 bh=bvH42fI+3FDqYCOzpav256OLHpWn9e1rXY+RgLfxaOQ=;
 h=Date:To:From:Reply-To:Subject:From;
 b=j54yoGJBXNWFrtsRSQe+8++21bTQ9mxsdFTPLVowW6ZPTcSGmBT96suQZjBFRfOt9
 SGPZ7upwgr0zOQnz/NSfarZbFiQE1xaGDVr3eNzURdsX6qrkePVz8DqLqenErnPJoE
 KZ5gN7BKToMpJsStdf7TiDyd+JsodVFsRGCKYqZI=
To: "Bug reports for GNU Emacs,
 the Swiss army knife of text editors" <bug-gnu-emacs@HIDDEN>
From: ndame <laszlomail@HIDDEN>
Subject: Regexp paren pairs in query-replace-regexp prompt should be
 highlighted
Message-ID: <1LWmgMt-iOZcz0k2N5IVTqgDu922CLEd8GATVBsqdQfVeBzIGEaVuORC9k0SXORQDkpqc8BO3zxOPFbQeMMhNHQmOvcvIOpOpoWL8CAVUq8=@protonmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Status: No, score=-1.2 required=10.0 tests=ALL_TRUSTED,DKIM_SIGNED,
 DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM shortcircuit=no
 autolearn=disabled version=3.4.4
X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on
 mailout.protonmail.ch
Received-SPF: pass client-ip=185.70.40.132;
 envelope-from=laszlomail@HIDDEN; helo=mail-40132.protonmail.ch
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_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Reply-To: ndame <laszlomail@HIDDEN>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)

Emacs highlights parents by default, e.g. when point is after the closing
paren  the opening parent is highlighted.

If I type capturing parens in the query replace regexp prompt then the
paren pairs are not highlighted:

   Query replace regexp: \(something\)

They should be, so when typing a complex regexp with multiple capturing
parens then it's easier to see the pairs.




Acknowledgement sent to ndame <laszlomail@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#50766; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Sat, 2 Oct 2021 09:15:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.