all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* alt to copy-region-as-kill for kill ring
@ 2021-03-07  8:57 Jeremie Juste
  2021-03-07  9:43 ` Emanuel Berg via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 6+ messages in thread
From: Jeremie Juste @ 2021-03-07  8:57 UTC (permalink / raw)
  To: help-gnu-emacs

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



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-03-07 18:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-07  8:57 alt to copy-region-as-kill for kill ring Jeremie Juste
2021-03-07  9:43 ` 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

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.