From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Emanuel Berg via Users list for the GNU Emacs text editor Newsgroups: gmane.emacs.help Subject: Re: alt to copy-region-as-kill for kill ring Date: Sun, 07 Mar 2021 10:43:10 +0100 Message-ID: <87mtvfuwnl.fsf@zoho.eu> References: <8735x7qr2z.fsf@gmail.com> Reply-To: Emanuel Berg Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26966"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) To: help-gnu-emacs@gnu.org Cancel-Lock: sha1:kB8KOjAkEsznxc1Y/XVICZrmvDw= Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sun Mar 07 10:43:41 2021 Return-path: Envelope-to: geh-help-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 1lIpwp-0006w3-NV for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 07 Mar 2021 10:43:39 +0100 Original-Received: from localhost ([::1]:59476 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lIpwo-0000JJ-Pg for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 07 Mar 2021 04:43:38 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48616) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lIpwX-0000JD-HC for help-gnu-emacs@gnu.org; Sun, 07 Mar 2021 04:43:21 -0500 Original-Received: from ciao.gmane.io ([116.202.254.214]:48102) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lIpwV-0006oU-5h for help-gnu-emacs@gnu.org; Sun, 07 Mar 2021 04:43:21 -0500 Original-Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1lIpwS-0006W4-9s for help-gnu-emacs@gnu.org; Sun, 07 Mar 2021 10:43:16 +0100 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: help-gnu-emacs@gnu.org Mail-Copies-To: never Received-SPF: pass client-ip=116.202.254.214; envelope-from=geh-help-gnu-emacs@m.gmane-mx.org; helo=ciao.gmane.io X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=0.25, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 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-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:128357 Archived-At: Jeremie Juste wrote: > The following function to copies a word in the visible > buffer and comes back to point to yank it. It builds on > avy package. OK, it should be required, then (require 'avy) - hm... Ah, it is in both ELPA (0.5.0) and MELPA (20201226.1734), actually! And then tons of extra avy-material at that. > (defun boomrang (query-char) > "kill word and come back to point" geh.el:281: First sentence should end with punctuation geh.el:281: First line should be capitalized geh.el:281: Argument ‘query-char’ should appear (as QUERY-CHAR) in the doc string Please use this: [check-package-style, lines 50-62) https://dataswamp.org/~incal/emacs-init/ide/elisp.el > (interactive (list (read-char "Query Char:"))) Should be equivalent? (interactive "cchar: ") > (save-excursion If mark moves as well, one can consider `save-mark-and-excursion'. I actually don't know if it does, do you? And I don't know a good way to find out, either. But OTOH, why not just reset as much of the initial state as possible? Because the state is disorganized bureaucracy? Because it is the PO-LICE department? ... well, no! I think one can just reset it while at it. > (progn not needed, right? > (copy-region-as-kill (point) > (progn (re-search-forward "[[:alnum:]_-]*") (point)) This will signal an error if there is no hit. One can instead do (when (re-search-forward RE (point-max) t) (point)). And speaking of the RE, isn't "[[:alnum:]_-]*" always found, instantly? You want (re-search-forward "[[:alnum:]_-]+") or something else? > There are a few limitations to it: - if the word is in > a different buffer it yank it but the cursor does `save-window-excursion'? > - If we bind the function to a key (say C-'), it is rather > difficult to control the copy-region-as-kill as when used > with this function it behaves like C-M-w (see function > kill-ring-save). ? You can bind it to whatever, it doesn't change it or anything else. > when only instance is wanted. A temporary solution might be > to enter a key between after M-d to deactivate appending. > But this solution is costly. ? -- underground experts united http://user.it.uu.se/~embe8573 https://dataswamp.org/~incal