all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Jeremie Juste <jeremiejuste@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: alt to copy-region-as-kill for kill ring
Date: Sun, 07 Mar 2021 09:57:08 +0100	[thread overview]
Message-ID: <8735x7qr2z.fsf@gmail.com> (raw)

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



             reply	other threads:[~2021-03-07  8:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-07  8:57 Jeremie Juste [this message]
2021-03-07  9:43 ` alt to copy-region-as-kill for kill ring Emanuel Berg via Users list for the GNU Emacs text editor
2021-03-07 10:35   ` Jeremie Juste
2021-03-07 14:42     ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-03-07 17:11       ` Jeremie Juste
2021-03-07 18:40         ` Emanuel Berg via Users list for the GNU Emacs text editor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8735x7qr2z.fsf@gmail.com \
    --to=jeremiejuste@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.