From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.help Subject: RE: How to yank a regexp in isearch-mode? Date: Sun, 11 Nov 2018 09:13:59 -0800 (PST) Message-ID: <3aa3f0c4-363e-4f4b-b368-0c81690db1d6@default> References: <4DFE9F27-7B86-4C33-B1BE-8193B56AD261@outlook.com> <225f0813-8140-4ab5-a97c-bfdee0451be6@default> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1541956350 14957 195.159.176.226 (11 Nov 2018 17:12:30 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 11 Nov 2018 17:12:30 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Zhang Haijun Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Nov 11 18:12:26 2018 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gLtHe-0003o1-0w for geh-help-gnu-emacs@m.gmane.org; Sun, 11 Nov 2018 18:12:26 +0100 Original-Received: from localhost ([::1]:43103 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gLtJk-0003nT-7m for geh-help-gnu-emacs@m.gmane.org; Sun, 11 Nov 2018 12:14:36 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38222) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gLtJH-0003nL-VP for help-gnu-emacs@gnu.org; Sun, 11 Nov 2018 12:14:08 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gLtJD-0008FZ-Ut for help-gnu-emacs@gnu.org; Sun, 11 Nov 2018 12:14:07 -0500 Original-Received: from aserp2120.oracle.com ([141.146.126.78]:40400) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gLtJD-0008F2-Lg for help-gnu-emacs@gnu.org; Sun, 11 Nov 2018 12:14:03 -0500 Original-Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id wABH9jHe072702; Sun, 11 Nov 2018 17:14:02 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=mime-version : message-id : date : from : sender : to : cc : subject : references : in-reply-to : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=JKKwAUTF68ZJUakTuvJj85A1LePIVomDPFrMJq+TvRk=; b=cWx8qw7toMGNqBvwPEJ1jOFaJ1EQDZZAerFJKRybEqaqUM4iftumWgsRNBli+YYkey3J JakdSvURnkpQlqIy9uRQ/zGQ5nGPU+FPGP6qlva28U9wm9hzNpVfRT9rByWYFd2kEmdK sDEUmjlV0CrK5TQzEUr+kt1lmFeKllAVxOKtD8dsISCxIOOyPdNW99JWEc037wIkszyU GsWIAYAFL21Tqy4f4SfhyDc1XvApCGu/Rfd++DDGJxioQaGneHMxyT3Emq265LMXCycv fs5mwCAAB5BDL7deBGIFGxCl5nMEwyTKXQ02XO9wivsp4zdxtYc5vZUK00oHww/TOpUn dA== Original-Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp2120.oracle.com with ESMTP id 2nnw6eab4w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 11 Nov 2018 17:14:02 +0000 Original-Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id wABHE1TO001303 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 11 Nov 2018 17:14:01 GMT Original-Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id wABHE0gs023891; Sun, 11 Nov 2018 17:14:00 GMT In-Reply-To: X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9.1 (1003210) [OL 16.0.4756.0 (x86)] X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9074 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=678 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1811110164 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 141.146.126.78 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:118646 Archived-At: > > `isearch-yank-string' can yank a regexp string as well. >=20 > But it escape the string if isearch-regexp is not nil. Yes. That's why Isearch+ adds `isearchp-regexp-quote-yank-flag' (and a key to toggle that during Isearch): to give you a choice (control). > > If you use Isearch+ then you have option > > `isearchp-regexp-quote-yank-flag':... > > > > With this escaping turned off, you can yank text such > > as `^\*.*' without it being transformed to `\^\\\*\.\*'. > > > > Isearch+: > > > > https://www.emacswiki.org/emacs/IsearchPlus >=20 > I see it. It is a big package. It is too big for my use case. I just > want to yank a regexp. It's not very big, if you remove the Commentary. But yes, it's purpose is not just to let you yank regexp. If you don't want to use Isearch+ then just advise or redefine `isearch-yank-string', like Isearch+ does. It's trivial to do. E.g., change this: (if isearch-regexp (setq string (regexp-quote string))) to this: (when (and isearch-regexp your-variable) (setq string (regexp-quote string))) Or define a separate command that yanks without doing `regexp-quote' - same defun but without that line (if regexp-quote...). And bind that command to a different key. IOW, either use a variable with two values (and maybe a toggle command) or two different keys. Pretty simple.