From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jeremie Juste Newsgroups: gmane.emacs.help Subject: alt to copy-region-as-kill for kill ring Date: Sun, 07 Mar 2021 09:57:08 +0100 Organization: Emacs is it Message-ID: <8735x7qr2z.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="39624"; 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 Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sun Mar 07 09:58:08 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 1lIpEm-000ADe-7a for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 07 Mar 2021 09:58:08 +0100 Original-Received: from localhost ([::1]:50180 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lIpEl-0002RF-6o for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 07 Mar 2021 03:58:07 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:43744) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lIpDt-0002R6-IQ for help-gnu-emacs@gnu.org; Sun, 07 Mar 2021 03:57:13 -0500 Original-Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]:37521) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lIpDs-0001oc-2b for help-gnu-emacs@gnu.org; Sun, 07 Mar 2021 03:57:13 -0500 Original-Received: by mail-wr1-x431.google.com with SMTP id v15so8020058wrx.4 for ; Sun, 07 Mar 2021 00:57:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:organization:date:message-id:user-agent :mime-version; bh=7VBRGjeBXyPxWwWLm+twgqSB2zJQZ5khngXhFUgrA80=; b=Csod6xRFtsHjfzrcb28soUVMUKqmIPfTxT6zY/VQluY+dKqHVAuxz7iRkiUk5SSsiZ AIBdPaFtjabRSH8EomP/bQqCVMjAg+CEaovGk4AaCPXbEm9WhGzIQR/S3T21iOpGkLzk 7VFa6dbE7JNpYutp4KZ93NM7BkS+E4QfWnzEIgoTDTm4iFtoiQF0z9XJclO89XCZUily tgI8BYIWQyK/iZP5aTWxxmSfUYOp3CYoxvDOjBc9sMQ/1aIQ8x+DSZCxk2DxrnowNIXW +ah/D4feyT/aI+zpe9qnkmBpAikipkksZBj3HbIAagD5YGdNPqEj7qdzB8RUPZ2khcGv vNpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:organization:date:message-id :user-agent:mime-version; bh=7VBRGjeBXyPxWwWLm+twgqSB2zJQZ5khngXhFUgrA80=; b=YjzrAaqTq06fMDCitLmJgCiKwpVWS1OlhXemqhXEw3tvzJVWhxU9DG5vYmyAx40gy2 aA8F3wk0Fk5VEOE6Z4B9EqmHnQGhF4osAO/8tT7Uc6OjoduO0dfGE3IDzQvyTazgeDkn h2O+A/A2069D/du4Imz5j1AK8QenST/FhzlzWuPortxhnIy56GoQr21dbuEKa9f0NOwx 7PzA87wTbocz1ec6NjSkzhfEmQs8e5U97RImVmqCGck5kOQqeNhN5zUBtT1pHa4zjM40 7XzPRk+wNygBnBinBzFQgAzsWso4jAczdKEAoHLbuz9tAVzZAwhEE65ToBjBm0kWcoGa 7EZg== X-Gm-Message-State: AOAM5332ZEeBCZtzpx48+Z5yvu8cqvPBJVByIiFsVj0j9HXYLqg6nbUw 3iLGprH8fAlaLdbmhyWMa4yZypsyyqE= X-Google-Smtp-Source: ABdhPJwXiIWOr7K4g+TvjrQazHwzVIIU0ZVWeMcJn+vRYRR5/ctb8jkcZw13DeTFrsXdPj0i8aMg4g== X-Received: by 2002:a5d:4b83:: with SMTP id b3mr17656534wrt.76.1615107429779; Sun, 07 Mar 2021 00:57:09 -0800 (PST) Original-Received: from freegnu (82-64-129-7.subs.proxad.net. [82.64.129.7]) by smtp.gmail.com with ESMTPSA id m2sm12070048wml.34.2021.03.07.00.57.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Mar 2021 00:57:09 -0800 (PST) Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=jeremiejuste@gmail.com; helo=mail-wr1-x431.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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:128355 Archived-At: Hello, The following function to copies a word in the visible buffer and comes back to point to yank it. It builds on avy package. (defun boomrang (query-char) "kill word and come back to point" (interactive (list (read-char "Query Char:"))) (save-excursion (progn (avy-goto-word-1 query-char) (copy-region-as-kill (point) (progn (re-search-forward "[[:alnum:]_-]*") (point))))) (yank)) There are a few limitations to it: - if the word is in a different buffer it yank it but the cursor does not come back - 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). for instance (cursor position is represented as a |) |dfd ## M-d C-' (Query-char i) ==> dfdinstance 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. Do you have an better solution? Best regards, -- Jeremie Juste