From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.devel Subject: PATCH: isearch-yank-until-match Date: Wed, 14 Aug 2019 14:08:50 -0700 (PDT) Message-ID: <6c21d7af-e071-4c9e-9325-38c6f19794b3@default> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="__1565816931781161062abhmp0017.oracle.com" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="193477"; mail-complaints-to="usenet@blaine.gmane.org" To: Karl Fogel , Emacs developers Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Aug 14 23:10:38 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hy0XV-000oEF-Lj for ged-emacs-devel@m.gmane.org; Wed, 14 Aug 2019 23:10:37 +0200 Original-Received: from localhost ([::1]:36168 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hy0XU-0002Cm-Jt for ged-emacs-devel@m.gmane.org; Wed, 14 Aug 2019 17:10:36 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40704) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hy0Vw-0001H8-NY for emacs-devel@gnu.org; Wed, 14 Aug 2019 17:09:02 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hy0Vv-0006BT-1z for emacs-devel@gnu.org; Wed, 14 Aug 2019 17:09:00 -0400 Original-Received: from userp2130.oracle.com ([156.151.31.86]:40382) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hy0Vt-0006AI-UA for emacs-devel@gnu.org; Wed, 14 Aug 2019 17:08:58 -0400 Original-Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7EL41aK059386; Wed, 14 Aug 2019 21:08:54 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=mime-version : message-id : date : from : sender : to : subject : content-type; s=corp-2019-08-05; bh=ocxI2pun7FdEfHBjbUkDeIM6yGq9kVWvRTMDy4D9x5w=; b=SICoOe0HMhzRNrJKS5iC6eM1Doe2jIrFJqwnmfwGWZV7pZCioGm9NzOuXZzwuF9t4XRA adItKGCWXQ9r83DX8K4V2hMclAASvuuavKkFhZ/GiPMbVqZLGzU6l3gmCxv3A//NBbB0 fs4k6xR8gkuB3ZDSVD1Rcx+3NutezLol//o5HMZEU1PJZNep4J0nCyceK8q9VZKHKf2B AqotZW6PDctHW4eGmjPrGmOocTj/QONcSLy7AbT3j7QOPXDPRkUQW7F2IXB2qY1fDlxW ZoeN9q87MVldnmj0j/r6HUxZTjif7wCwwfPpJ3ApehT4i8s1CG/3G4L6hwltWuluFWyZ CQ== Original-Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 2u9nbtqbkj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Aug 2019 21:08:53 +0000 Original-Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7EL7qxB189349; Wed, 14 Aug 2019 21:08:53 GMT Original-Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3020.oracle.com with ESMTP id 2ucgf086c4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Aug 2019 21:08:53 +0000 Original-Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x7EL8pCE024494; Wed, 14 Aug 2019 21:08:52 GMT X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9.1 (1003210) [OL 16.0.4873.0 (x86)] X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9349 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908140192 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9349 signatures=668684 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908140191 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.86 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:239369 Archived-At: --__1565816931781161062abhmp0017.oracle.com Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable This is similar to what Karl submitted today. Not a replacement for that; something different. --- During Isearch, hit `C-M-m' (aka `M-RET'). You're prompted for another search pattern. The text matching the pattern from point, in the search direction, is yanked to the search string. Works for forward and backward searches, and for regexp and literal searches. If searching backward, the matched text is prepended to the search string; else it is appended. If you use a prefix arg with `C-M-m' then the pattern is matched as a regexp, not literally. --- I think Karl's `isearch-yank-until-char' should also be made to support backward search. With the attached patch the following definition does that. (The attached patch does not include this command. The diff is against the isearch.el in master today.) (defun isearch-yank-until-char (char) "Yank buffer text, up to next instance of CHAR, to search string. You are prompted for CHAR." (interactive "cYank until character: ") (isearch-yank-internal (lambda () (let ((inhibit-field-text-motion t)) (funcall (if isearch-forward =09=09 #'search-forward =09=09 #'search-backward) =09=09(char-to-string char)) (if isearch-forward (backward-char) (forward-char)) (point))))) --- The attached patch also improves these two functions: `isearch-process-search-string': Prepend STRING if searching backward and search string is not just a single char. (Otherwise, append, as now.) Add a doc string. `isearch-yank-internal': 1. Doc string now talks about arg as being a function, not a "lambda expression". Arg name is JUMPFUN, not JUMPFORM. 2. Use fixed version of `isearch-process-search-string', so no need to move to other end when searching backward. --- I don't think the patch breaks anything (e.g. uses of `isearch-yank-internal' or `isearch-process-search-string'), but I've done limited testing. Maybe someone knowledgeable about the isearch.el code (e.g. Juri) could take a look to be sure. --__1565816931781161062abhmp0017.oracle.com Content-Type: application/octet-stream; name="isearch-2019-08-14a.patch" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="isearch-2019-08-14a.patch" ZGlmZiAtdSBpc2VhcmNoLmVsIGlzZWFyY2gtMjAxOS0wOC0xNGEtUEFUQ0guZWwKLS0tIGlzZWFy Y2guZWwJMjAxOS0wOC0xNCAxMzoxNjoxNS4yMDA4NTM4MDAgLTA3MDAKKysrIGlzZWFyY2gtMjAx OS0wOC0xNGEtUEFUQ0guZWwJMjAxOS0wOC0xNCAxMzoyNTozOC4zMzI4OTQzMDAgLTA3MDAKQEAg LTcwNSw2ICs3MDUsNyBAQAogICAgIChkZWZpbmUta2V5IG1hcCAiXE0tXEMtZCIgJ2lzZWFyY2gt ZGVsLWNoYXIpCiAgICAgKGRlZmluZS1rZXkgbWFwICJcTS1cQy15IiAnaXNlYXJjaC15YW5rLWNo YXIpCiAgICAgKGRlZmluZS1rZXkgbWFwICAgICJcQy15IiAnaXNlYXJjaC15YW5rLWtpbGwpCisg ICAgKGRlZmluZS1rZXkgbWFwI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YXJlIHByb21wdGVkIGZvciB0 aGUgcGF0dGVybi4KK1dpdGggYSBwcmVmaXggYXJnIHRoZSBwYXR0ZXJuIGlzIG1hdGNoZWQgYXMg YSByZWdleHAuIgorICAoaW50ZXJhY3RpdmUgIlAiKQorICAobGV0IChwYXR0ZXJuKQorICAgICh3 aXRoLWlzZWFyY2gtc3VzcGVuZGVkCisgICAgIChzZXRxIHBhdHRlcm4gIChpZiBhcmcKKyAgICAg ICAgICAgICAgICAgICAgICAgIChyZWFkLXJlZ2V4cCAiTWF0Y2ggcmVnZXhwOiAiKQorICAgICAg ICAgICAgICAgICAgICAgIChyZWFkLXN0cmluZyAiTWF0Y2g6ICIpKSkpCisgICAgKGlzZWFyY2gt eWFuay1pbnRlcm5hbAorICAgICAobGFtYmRhICgpCisgICAgICAgKGxldCAoKGluaGliaXQtZmll bGQtdGV4dC1tb3Rpb24gIHQpKQorICAgICAgICAgKGZ1bmNhbGwgKGlmIGFyZworICAgICAgICAg ICAgICAgICAgICAgIChpZiBpc2VhcmNoLWZvcndhcmQKKyAgICAgICAgICAgICAgICAgICAgICAg ICAgIydzZWFyY2gtZm9yd2FyZC1yZWdleHAKKyAgICAgICAgICAgICAgICAgICAgICAgICMnc2Vh cmNoLWJhY2t3YXJkLXJlZ2V4cCkKKyAgICAgICAgICAgICAgICAgICAgKGlmIGlzZWFyY2gtZm9y d2FyZAorICAgICAgICAgICAgICAgICAgICAgICAgIydzZWFyY2gtZm9yd2FyZAorICAgICAgICAg ICAgICAgICAgICAgICMnc2VhcmNoLWJhY2t3YXJkKSkKKyAgICAgICAgICAgICAgICAgIHBhdHRl cm4pCisgICAgICAgICAocG9pbnQpKSkpKSkKKwogKGRlZnVuIGlzZWFyY2gtc2VhcmNoLWFuZC11 cGRhdGUgKCkKICAgOzsgRG8gdGhlIHNlYXJjaCBhbmQgdXBkYXRlIHRoZSBkaXNwbGF5LgogICAo d2hlbiAob3IgaXNlYXJjaC1zdWNjZXNzCkBAIC0zMDE1LDEw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aCBSaW5nCiAK --__1565816931781161062abhmp0017.oracle.com--