help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: alt to copy-region-as-kill for kill ring


From: Emanuel Berg
Subject: Re: alt to copy-region-as-kill for kill ring
Date: Sun, 07 Mar 2021 10:43:10 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]