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: Tue, 30 Apr 2019 18:25:01 +0200 Message-ID: <20190430162501.xmqh5r5h57sjjlq5@Ergus> References: <20190427001453.isjx247kc3lu5fe4@Ergus> <87a7gcp51i.fsf@tcd.ie> <20190429004135.rn5tp2gnmbjovrxj@Ergus> <87h8agy4yf.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="52074"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: NeoMutt/20180716 Cc: "Basil L. Contovounesios" , emacs-devel@gnu.org To: Juri Linkov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Apr 30 18:31:41 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 1hLVfQ-000DPV-Bd for ged-emacs-devel@m.gmane.org; Tue, 30 Apr 2019 18:31:40 +0200 Original-Received: from localhost ([127.0.0.1]:49908 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLVfP-0005lo-5o for ged-emacs-devel@m.gmane.org; Tue, 30 Apr 2019 12:31:39 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:32903) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hLVZ8-0000gd-UB for emacs-devel@gnu.org; Tue, 30 Apr 2019 12:25:12 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hLVZ7-0002KZ-Mu for emacs-devel@gnu.org; Tue, 30 Apr 2019 12:25:10 -0400 Original-Received: from sonic309-25.consmr.mail.ir2.yahoo.com ([77.238.179.83]:34272) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hLVZ7-0002Hx-Dr for emacs-devel@gnu.org; Tue, 30 Apr 2019 12:25:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aol.com; s=a2048; t=1556641505; bh=MtsdIYGirtqGo7gYmdMyL0knRht0+NdPqCWBpjlcROM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From:Subject; b=dBXfJe4G1XyhNWWgkKR6zuHe6baNW0vOeOgHjBQ3dXt5eVBXWt3+5AKf2ieIU3naRGampC27HAkoz5cJvexe3KAb2XDKEN9Bx/fGyCcBDE0F5nZ9Jn8X+eBJaTPNmQFlq88LDG+XPueLfARnm/XGCETSCrHnnMCfCthJldvuVa2AvGYcCWZv7V+wI0kTSb6GCjh97VLv2RChqwwMckt2OC28UkA7GD9jH3gbFqcrSgk6Cq3jepkpd1hnaBUKXHHx4Km85iv0C5HoPq9VA5fCOGEWWjnAdnI414CHn4wR8JJaEZhas3ZqfImZcD4xEOrwdnyZLmhPJfxp3l3mJgJg1Q== X-YMail-OSG: M47nemkVM1kpizxGVI1GoXxz6LSzFbmXzXASKAa8XGsEjzYemdYl3J6C5fUDpUs HEF2eaGqJYaceYwpIHYkVb8YHF_gao3uTOtcM8AysYNOD28dm0YEcfYs2MadXcFo12rZ94g8Qp9c 5ZUT750Z7b2FSEWhngSynO4gxuRUkG6ZV.ooqGcg38Dd14jSzCqLtvhCFJyQMj4P_fgQTN5ZuJdP F7QfKvVa6URdfEk0v_3fzEjLEJNpQ92Gd_mNasoiDRcmZ2UcC5YC2neQdJHKY3fpbMJsv_hOCfeQ WVteGdLMW2Y0P_khvWzLoyVO.1MK2J2qW_k46dC5mW6YPtIxZLOyaFNm_LInsewULV0JDVPF5y_z eNkMfo_PtkD3Icw4XZ.s3NFg.E_DolJvA66ep65Iri5Zu1aGOaL7N8S6su7qRxFX1uFwBpxLa__0 xPShJhcrYkzXy51FWeTZ3D30azBZdpIjY_hGRHJcUimpWepnAy_PQb_oYC3B6yvzSLTOGMtM1.We Arl7Wz_hQV6Q1D_XmFKUP4PZmXo4BYLnREgsuqTafZQ5QduEY4YXZxDFkR9QAlFOy3Lr2gzmDV0Z ulN03HUlK9a8JHXQoOD4psJGq36_54puWi2fXHqC33csffIubvuDbyrGbZ8k3reNTZKmttcl6jD4 L75IhpYLBn4ZYYXjqw5K9Mk1f38jz2tKwjRntCrtR5Umjvso9CD4VtdsSvY5TJIUhjIwNrFUqfdZ wAG3sutghcF4ycM1hhBUyNvta3a3aZJhzYRa38tTUQHi_R3PJ8dFwJ08VQkBCjrlIc5V2KMTePFo CLdXVJ0L.v528ZmKXHHrzzxyej306mm1jWXGC.RSoy Original-Received: from sonic.gate.mail.ne1.yahoo.com by sonic309.consmr.mail.ir2.yahoo.com with HTTP; Tue, 30 Apr 2019 16:25:05 +0000 Original-Received: from 84.88.50.33 (EHLO Ergus) ([84.88.50.33]) by smtp411.mail.ir2.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID c30851fc977816471e18b28c960ae493; Tue, 30 Apr 2019 16:25:04 +0000 (UTC) Content-Disposition: inline In-Reply-To: <87h8agy4yf.fsf@mail.linkov.net> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 77.238.179.83 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:236056 Archived-At: Hi: I wrote this code today to do a search auto-insert text from region like behavior. =============================================== (defun isearch-forward-region (&optional arg) "Do incremental search forward for text in active region. Like ordinary incremental search except that the text in the active region is added to the search string initially if variable `transient-mark-mode' is non nil. See the command `isearch-forward-symbol' for more information. With a prefix argument, search for ARGth symbol forward if ARG is positive, or search for ARGth symbol backward if ARG is negative." (interactive "P") (isearch-forward nil 1) (if-let* ((bounds (and (use-region-p) ;; Region and transient non-nil (string-empty-p isearch-string) (region-bounds))) (contiguous (= (length bounds) 1)) ;; Region is contiguous (region-beg (car (car bounds))) (region-end (cdr (car bounds))) (region-string (and (= (count-lines region-beg region-end) 1) (buffer-substring-no-properties region-beg region-end))) (noempty (not (string-blank-p region-string)))) (progn (goto-char region-beg) (setq mark-active nil isearch--deactivated-mark t) (isearch-yank-string region-string) (when-let (count (and arg (prefix-numeric-value arg))) (isearch-repeat-forward count))) (setq isearch-error "Invalid region for isearch") (isearch-push-state) (isearch-update))) ================================================ The problem is that when I C-x C-e, it works fine, but when I compile it I get an error with message: ``` funcall-interactively: Symbol???s value as variable is void: bounds ``` I am pretty new using lisp, but I don't understand this behavior, Any help, please. The backtrace only says: ================================================== Debugger entered--Lisp error: (void-variable bounds) isearch-forward-region(nil) funcall-interactively(isearch-forward-region nil) call-interactively(isearch-forward-region nil nil) command-execute(isearch-forward-region) ================================================== Do I am using wrong the if-let* statement? Thanks in advance, Ergus. On Mon, Apr 29, 2019 at 10:41:28PM +0300, Juri Linkov wrote: >>>The closest to this that I'm aware of is >>>isearch-forward-symbol-at-point, bound to 'M-s .' by default. >>> >> 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, such addition is welcome. Currently searching the >active region requires invocation of several commands: M-w C-s M-y >with a bad side-effect of leaving the region in the kill-ring. > >However, adding a new option is not a satisfactory solution >because often isearch is used to extend the boundaries of the >active region, e.g. by setting the region's beginning with C-SPC, >then searching the region's end and exiting isearch there. > >Fortunately, like Basil mentioned the command isearch-forward-symbol-at-point >bound to 'M-s .' you could create a similar command bound to e.g. 'M-s r' >that would start isearch with the text from the active region. >