From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Ergus Newsgroups: gmane.emacs.devel Subject: Re: isearch region or thing at point. Date: Mon, 29 Apr 2019 03:30:11 +0200 Message-ID: <20190429013011.4k4zfs5igxf7w6m5@Ergus> References: <20190427001453.isjx247kc3lu5fe4@Ergus> <87a7gcp51i.fsf@tcd.ie> <20190429004135.rn5tp2gnmbjovrxj@Ergus> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="67588"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: NeoMutt/20180716 Cc: emacs-devel@gnu.org To: "Basil L. Contovounesios" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Apr 29 03:42:26 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.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hKvJG-000HK4-D2 for ged-emacs-devel@m.gmane.org; Mon, 29 Apr 2019 03:42:22 +0200 Original-Received: from localhost ([127.0.0.1]:50550 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hKvJF-0004Zp-Az for ged-emacs-devel@m.gmane.org; Sun, 28 Apr 2019 21:42:21 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:41177) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hKvI0-00045J-T7 for emacs-devel@gnu.org; Sun, 28 Apr 2019 21:41:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hKv7e-0000XF-RS for emacs-devel@gnu.org; Sun, 28 Apr 2019 21:30:24 -0400 Original-Received: from sonic303-21.consmr.mail.ir2.yahoo.com ([77.238.178.202]:41389) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hKv7e-0000WU-Ja for emacs-devel@gnu.org; Sun, 28 Apr 2019 21:30:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aol.com; s=a2048; t=1556501420; bh=I0FL4ROTqCuCwLuLIO5qI7aCcBsUS6BRXbiMjrsJo/4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From:Subject; b=tf8eik+n75p5cB5kCDcrJkoDhzfPbbDhVvkM2al2cdWl5y8P25Va7+lOB7ezUbGg91/1h9beQ1E+eSvZ0kHx+SSBFWvJ37TqbuO/jNYFh+/eEvkwIkOYknSaXAgZDGS7tGL/MmX+RZmAwkIm74JF8IPy77LuCNvvWjeCsLyHs1Elqt88foNjGi/SGIqGk5yX0xdIjv8bzl98smhVS7P3ZFah1ppBkwEsad8ASgkABeGL1ui2QtoDWhfNvTAMu1s0u/8eTNCtSVjakEY45aoKL8S8WasGdEGqg/9/Zj5Hpbz6upEv/00LhbSQvpozAxB60MArXkkb/BliND0+TFPPxw== X-YMail-OSG: WIFrJfgVM1kWzcTvV4Cuv_DabeOfOjdXaJyTS2MrJvX6K_HIuDgcUZc._gVS7Zt jD7iNtmjkdDTiAQk4EoGSV4EtG_sFbK4ApRwf.e3IuH_yINl3Hld.UIwLqXlxxD90c.vKeX7Dk8B dNGaJ56q_NXaYx.yNwFqZ8mf_Uk1_nFa8QlEpSbOrRCFpmPpHcU8DUNqxp_q5pOxfvlmR81ShVmY oQ_vmEQydcN2QcI504mjl8HdZTqnO9GvtzQhN2zoaf7sPm2YdHjlwKO3eqN1kddB3Ki9ENQfTpME 3a9D.ynBvutaPcqbLA1oBGj.8kzMq4xWGu24LSsdIsLXS5urwscFpxmCzliSxSW.fRkxCHcFbVVQ KXBnHH.NrpGgAZDfyUV89dpX8PTMVzku8F_IKaX9v4epLKj3rts20Gv9Q0kuJMEefcXIdmzKt9g. tCe.XNqW1L5pOw530arvMtO8d4amCCMPwOwDVKSCMJtYzs4xcxoXFCFxekG1iKW1mFAhHqMFiiTO Q2hyLRnj5Go1i3HLOniqU4k9DMP9mKVc4F6FxAV_WoMxuWwUgzO7n8kQYNblfttWgKXOFND8Ctmh 0OdgQKRhCYoqAwy3vDIkiGVgCvsEvBY5YKahW5UO34x.mFalvCbAymgSpL.APjgMwa.dkPqq.kIB L.k7VkpgAjF5iiH6QRmQRvR2NfuhDLD7etharKR4zSCCaeJCnXjrvQ61tc_EGw1PDB7Vz_62Mxgu S.T_sdjEkXZIum_n7qmip3rri0FL3Qq0Dfi2vnFri7m0.cjI3TMvxeEI1zd.YoB2GCMWcfGavjPe XF78rg3u12nk0xSUhI7mzB5BDYKoCd7Yrx9aqYLoh2 Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic303.consmr.mail.ir2.yahoo.com with HTTP; Mon, 29 Apr 2019 01:30:20 +0000 Original-Received: from 2.152.205.184.dyn.user.ono.com (EHLO Ergus) ([2.152.205.184]) by smtp429.mail.ir2.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID c02d12e85f9201080af885e6e14d69ee; Mon, 29 Apr 2019 01:30:16 +0000 (UTC) Content-Disposition: inline In-Reply-To: <20190429004135.rn5tp2gnmbjovrxj@Ergus> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 77.238.178.202 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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:236019 Archived-At: Patch update: Sorry, the last one was a wrong one. On Mon, Apr 29, 2019 at 02:41:35AM +0200, Ergus wrote: >On Sat, Apr 27, 2019 at 03:15:21AM +0100, Basil L. Contovounesios wrote: >>Ergus writes: >> >>>I am looking in the manual for two isearch functionalities that maybe >>>are already implemented, but I don't find them. Else maybe it is not >>>so complex to do in elisp (at least for my config) And you could suggest >>>a right way to implement it. >>> >>>1) isearch-yank-thing-at-point, this should be similar to >>>isearch-yank-word, but if the cursor is in the middle of a word >>>it may insert the whole word not just the rest of the current word. >>> >>>(swiper provides this with M-n) >> >>The closest to this that I'm aware of is >>isearch-forward-symbol-at-point, bound to 'M-s .' by default. >> >>>2) In "transient-mark-mode" if the region is active before C-s, the >>>initial input could be the text in the region. Is it there a way to >>>enable that behavior? >>> >>>An alternative for this is a command that yanks the region's text in the >>>minibuffer when isearch is active so we could bind it in the isearch-map >>>(for example to M-f). >>> >>>Are some of these already implemented? >> >>I'm not familiar with any built-in versions of the rest of the >>functionality you describe, but I'm no expert. If it is indeed not >>currently present, I for one would welcome such additions. >> >>Thanks, >> >>-- >>Basil >> >Hi Basil: > >I just made a small change in isearch.el to enable region text auto >insertion in transient-mark-mode. (patch attached) > >I did it as simple as I could. So please if you (or any anyone) could >give a look and correct/improve/expose corner cases, or suggest a better >implementation will be very nice. > >I don't have corner cases right now, but I just started testing it. > >So any correction/suggestion/recommendation is very appreciated. > >Thanks in advance, > >Ergus > >diff --git a/lisp/isearch.el b/lisp/isearch.el >index 6280afebdc..3de0493c8a 100644 >--- a/lisp/isearch.el >+++ b/lisp/isearch.el >@@ -413,6 +413,17 @@ and doesn't remove full-buffer highlighting after a search." > :group 'lazy-count > :version "27.1") > >+(defcustom isearch-autoinsert-region nil >+ "If non-nil, the text in the region will be auto-inserted for searching. >+This works only if the variable `transient-mark-mode' is enabled >+and the region is active." >+ :type 'boolean >+ :group 'isearch >+ :version "27.1") >+ >+(defvar isearch-deactivated-mark nil >+ "If for some reason isearch removed the mark on start.") >+ > > ;; Define isearch help map. > >@@ -1205,7 +1216,8 @@ used to set the value of `isearch-regexp-function'." > ;; Save the original value of `minibuffer-message-timeout', and > ;; set it to nil so that isearch's messages don't get timed out. > isearch-original-minibuffer-message-timeout minibuffer-message-timeout >- minibuffer-message-timeout nil) >+ minibuffer-message-timeout nil >+ isearch-deactivated-mark nil) > > (if (local-variable-p 'tool-bar-map) > (setq isearch-tool-bar-old-map tool-bar-map)) >@@ -1244,6 +1256,15 @@ used to set the value of `isearch-regexp-function'." > ;; `isearch-push-state' to save mode-specific initial state. (Bug#4994) > (isearch-push-state) > >+ (when (and isearch-autoinsert-region ;; Check option >+ (use-region-p) >+ (not (region-noncontiguous-p)) >+ (= (count-lines (region-beginning) (region-end)) 1)) >+ (isearch-yank-string >+ (buffer-substring-no-properties (region-beginning) (region-end))) >+ (setq mark-active nil >+ isearch-deactivated-mark t)) >+ > (isearch-update) > > (add-hook 'pre-command-hook 'isearch-pre-command-hook) >@@ -1782,6 +1803,9 @@ The following additional command keys are active while editing. > (isearch--set-state (car isearch-cmds))) > (goto-char isearch-opoint)) > (isearch-done t) ; Exit isearch.. >+ (when isearch-deactivated-mark >+ (setq isearch-deactivated-mark nil >+ activate-mark t) > (isearch-clean-overlays) > (signal 'quit nil)) ; ..and pass on quit signal. >