* disable region after running a command on it
@ 2022-12-13 11:18 Luca Ferrari
2022-12-13 13:13 ` Eli Zaretskii
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Luca Ferrari @ 2022-12-13 11:18 UTC (permalink / raw)
To: help-gnu-emacs
Hi all,
is there a way to disable a region every time a command has been run
on it? For example, I mark a region, M-x eval-region and I would like
that the region selection disappear.
Thanks,
Luca
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: disable region after running a command on it
2022-12-13 11:18 disable region after running a command on it Luca Ferrari
@ 2022-12-13 13:13 ` Eli Zaretskii
2022-12-13 13:26 ` Gregory Heytings
2022-12-13 16:20 ` Stefan Monnier via Users list for the GNU Emacs text editor
2 siblings, 0 replies; 6+ messages in thread
From: Eli Zaretskii @ 2022-12-13 13:13 UTC (permalink / raw)
To: help-gnu-emacs
> From: Luca Ferrari <fluca1978@gmail.com>
> Date: Tue, 13 Dec 2022 12:18:40 +0100
>
> is there a way to disable a region every time a command has been run
> on it? For example, I mark a region, M-x eval-region and I would like
> that the region selection disappear.
Add deactivate-mark to your post-command-hook?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: disable region after running a command on it
2022-12-13 11:18 disable region after running a command on it Luca Ferrari
2022-12-13 13:13 ` Eli Zaretskii
@ 2022-12-13 13:26 ` Gregory Heytings
2022-12-13 16:20 ` Stefan Monnier via Users list for the GNU Emacs text editor
2 siblings, 0 replies; 6+ messages in thread
From: Gregory Heytings @ 2022-12-13 13:26 UTC (permalink / raw)
To: Luca Ferrari; +Cc: help-gnu-emacs
>
> is there a way to disable a region every time a command has been run on
> it? For example, I mark a region, M-x eval-region and I would like that
> the region selection disappear.
>
(defun maybe-deactivate-mark ()
(if (memq this-command
'(eval-region
;; other commands after which you want to deactivate mark
))
(deactivate-mark)))
(add-hook 'post-command-hook #'maybe-deactivate-mark)
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: disable region after running a command on it
2022-12-13 11:18 disable region after running a command on it Luca Ferrari
2022-12-13 13:13 ` Eli Zaretskii
2022-12-13 13:26 ` Gregory Heytings
@ 2022-12-13 16:20 ` Stefan Monnier via Users list for the GNU Emacs text editor
2022-12-13 16:36 ` [External] : " Drew Adams
2022-12-14 17:56 ` Emanuel Berg
2 siblings, 2 replies; 6+ messages in thread
From: Stefan Monnier via Users list for the GNU Emacs text editor @ 2022-12-13 16:20 UTC (permalink / raw)
To: help-gnu-emacs
> is there a way to disable a region every time a command has been run
> on it? For example, I mark a region, M-x eval-region and I would like
> that the region selection disappear.
What' you're asking is the normal behavior, usually. I see indeed that
`eval-region` doesn't follow this principle, but I can't see any good
reason for that, so maybe a bug report is the best way to fix
the problem.
Stefan
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [External] : Re: disable region after running a command on it
2022-12-13 16:20 ` Stefan Monnier via Users list for the GNU Emacs text editor
@ 2022-12-13 16:36 ` Drew Adams
2022-12-14 17:56 ` Emanuel Berg
1 sibling, 0 replies; 6+ messages in thread
From: Drew Adams @ 2022-12-13 16:36 UTC (permalink / raw)
To: Stefan Monnier; +Cc: 'Help-Gnu-Emacs (help-gnu-emacs@gnu.org)'
[-- Attachment #1: Type: text/plain, Size: 511 bytes --]
> > is there a way to disable a region every time a command has been run
> > on it? For example, I mark a region, M-x eval-region and I would like
> > that the region selection disappear.
>
> What' you're asking is the normal behavior, usually.
That was going to be my answer: this is the normal
behavior of the command loop. Generally, if you
_don't_ want the region deactivated after each
command you need to do something, such as call
`deactivate-mark' or reset var `deactivate-mark'
to nil.
[-- Attachment #2: winmail.dat --]
[-- Type: application/ms-tnef, Size: 13446 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: disable region after running a command on it
2022-12-13 16:20 ` Stefan Monnier via Users list for the GNU Emacs text editor
2022-12-13 16:36 ` [External] : " Drew Adams
@ 2022-12-14 17:56 ` Emanuel Berg
1 sibling, 0 replies; 6+ messages in thread
From: Emanuel Berg @ 2022-12-14 17:56 UTC (permalink / raw)
To: help-gnu-emacs
Stefan Monnier via Users list for the GNU Emacs text editor wrote:
>> is there a way to disable a region every time a command has
>> been run on it? For example, I mark a region, M-x
>> eval-region and I would like that the region
>> selection disappear.
>
> What' you're asking is the normal behavior, usually. I see
> indeed that `eval-region` doesn't follow this principle, but
> I can't see any good reason for that, so maybe a bug report
> is the best way to fix the problem.
See?
Way to go, Luca \o/
--
underground experts united
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-12-14 17:56 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-13 11:18 disable region after running a command on it Luca Ferrari
2022-12-13 13:13 ` Eli Zaretskii
2022-12-13 13:26 ` Gregory Heytings
2022-12-13 16:20 ` Stefan Monnier via Users list for the GNU Emacs text editor
2022-12-13 16:36 ` [External] : " Drew Adams
2022-12-14 17:56 ` Emanuel Berg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).