all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org>
To: help-gnu-emacs@gnu.org
Subject: Re: alt to copy-region-as-kill for kill ring
Date: Sun, 07 Mar 2021 10:43:10 +0100	[thread overview]
Message-ID: <87mtvfuwnl.fsf@zoho.eu> (raw)
In-Reply-To: 8735x7qr2z.fsf@gmail.com

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	other threads:[~2021-03-07  9:43 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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=87mtvfuwnl.fsf@zoho.eu \
    --to=help-gnu-emacs@gnu.org \
    --cc=moasenwood@zoho.eu \
    /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.