From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: ndame via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#52558: Option for easier typing of regexps Date: Sat, 18 Dec 2021 16:47:47 +0000 Message-ID: References: <2af49892e35fa76d89fece4b2abc8a11@webmail.orcon.net.nz> Reply-To: ndame Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2618"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 52558@debbugs.gnu.org To: Phil Sainty Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Dec 18 17:48:12 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mycsW-0000Uy-0v for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 18 Dec 2021 17:48:12 +0100 Original-Received: from localhost ([::1]:35980 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mycsU-0000wS-L3 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 18 Dec 2021 11:48:10 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:34006) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mycsN-0000wJ-BS for bug-gnu-emacs@gnu.org; Sat, 18 Dec 2021 11:48:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:60355) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mycsM-0005Ki-2R for bug-gnu-emacs@gnu.org; Sat, 18 Dec 2021 11:48:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mycsL-0004at-UK for bug-gnu-emacs@gnu.org; Sat, 18 Dec 2021 11:48:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: ndame Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 18 Dec 2021 16:48:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52558 X-GNU-PR-Package: emacs Original-Received: via spool by 52558-submit@debbugs.gnu.org id=B52558.163984608017650 (code B ref 52558); Sat, 18 Dec 2021 16:48:01 +0000 Original-Received: (at 52558) by debbugs.gnu.org; 18 Dec 2021 16:48:00 +0000 Original-Received: from localhost ([127.0.0.1]:43668 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mycsJ-0004ab-VY for submit@debbugs.gnu.org; Sat, 18 Dec 2021 11:48:00 -0500 Original-Received: from mail-4318.protonmail.ch ([185.70.43.18]:47741) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mycsE-0004ZT-Pe for 52558@debbugs.gnu.org; Sat, 18 Dec 2021 11:47:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail2; t=1639846067; bh=k9H9ZOhkYwSaPvkLn8sJZbGVyJYJwq43aZu7M7G7MO4=; h=Date:To:From:Cc:Reply-To:Subject:Message-ID:In-Reply-To: References:From:To:Cc; b=M2NIfwAcwD08cSksU/e9UGL+Wi3kcFO2yShyf2bxNeNIRgxzZMNgdDKYFOxc4OD62 QitIbGRhKmwHLodniofd4R2fzgh4YCVyGUZ/EocbnTYwbPVPWA0eqtCi0EiClq4j1r 2QSAmBwdJjZyJHljk/yX2FexAVlAz4mACBcz81avOU+yA3PlfXn9sK6FsrK4bM7QQE 3dUIZrY14npXRK6V0MgIZj0pYNBFSvfZd7VQ/u9ZBhd2FcPsx0e5jXeXMo+dJ2+aYq GTtsksppLX5/PJcoaDcsLHveun9aC+YVdELphpIhYY/YcfmJ13uIgp9sp+zXnxFr7k 1xnT+9YIH6J7A== In-Reply-To: <2af49892e35fa76d89fece4b2abc8a11@webmail.orcon.net.nz> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" X-ACL-Warn: , ndame Xref: news.gmane.io gmane.emacs.bugs:222612 Archived-At: > You can probably implement what you want by overriding > `read-regexp'. In principle I'd expect anything prompting > for a regexp to be using this. That's what I thought too at first, but turns out it's not the right way, because then history contains the normalized regexp, so if the user goes back in history then he doesn't see the easy version, though the goal is that the user works with the easy variant. So read-regexp is not the right place, because the result of that goes into history. The translation has to be done only before the regexp is used. In case of query-replace-regexp it can be done before perform-replace. Here's a solution with advice: (defun my-perform-replace (origfun &rest args) (apply origfun (if (fourth args) ;; do conversion only for regexp replace (cons (let ((s (car args)) (chars '("|" "(" ")")) (placeholder (format "@placeholder%s@" (int-to-string (buffer-modified-tick))))) (dolist (char chars) (setq s (replace-regexp-in-string placeholder char (replace-regexp-in-string char (concat "\\\\" char) (replace-regexp-in-string (concat "\\\\" char) placeholder s))))) s) (cdr args)) args))) (advice-add 'perform-replace :around 'my-perform-replace)