* `yank-and-mark` command? @ 2015-07-04 21:43 Raffaele Ricciardi 2015-07-05 17:48 ` Michael Heerdegen [not found] ` <mailman.6386.1436118550.904.help-gnu-emacs@gnu.org> 0 siblings, 2 replies; 11+ messages in thread From: Raffaele Ricciardi @ 2015-07-04 21:43 UTC (permalink / raw) To: help-gnu-emacs I am trying to write a command that yanks and marks the yanked text -- the equivalent of C-y C-x C-x -- with Transient Mark Mode. The obvious implementation does not work: (defun yank-and-mark/rr (&optional $arg) (interactive "*P") (yank $arg) (exchange-point-and-mark)) I have tried cleverer implementations, but I will spare them for another day ;) Thank you. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: `yank-and-mark` command? 2015-07-04 21:43 `yank-and-mark` command? Raffaele Ricciardi @ 2015-07-05 17:48 ` Michael Heerdegen [not found] ` <mailman.6386.1436118550.904.help-gnu-emacs@gnu.org> 1 sibling, 0 replies; 11+ messages in thread From: Michael Heerdegen @ 2015-07-05 17:48 UTC (permalink / raw) To: help-gnu-emacs Raffaele Ricciardi <rfflrccrd@gmail.com> writes: > implementation does not work: > > (defun yank-and-mark/rr (&optional $arg) > (interactive "*P") > (yank $arg) > (exchange-point-and-mark)) In which way does the above not work like you want? Do you have `transient-mark-mode' enabled in your config? Michael. ^ permalink raw reply [flat|nested] 11+ messages in thread
[parent not found: <mailman.6386.1436118550.904.help-gnu-emacs@gnu.org>]
* Re: `yank-and-mark` command? [not found] ` <mailman.6386.1436118550.904.help-gnu-emacs@gnu.org> @ 2015-07-05 18:02 ` Raffaele Ricciardi 2015-07-05 18:35 ` Stefan Monnier 0 siblings, 1 reply; 11+ messages in thread From: Raffaele Ricciardi @ 2015-07-05 18:02 UTC (permalink / raw) To: help-gnu-emacs On 05/07/15 19:48, Michael Heerdegen wrote: > Raffaele Ricciardi <rfflrccrd@gmail.com> writes: > >> implementation does not work: >> >> (defun yank-and-mark/rr (&optional $arg) >> (interactive "*P") >> (yank $arg) >> (exchange-point-and-mark)) > > In which way does the above not work like you want? Do you have > `transient-mark-mode' enabled in your config? I am trying to mimic C-y C-x C-x. I have considered using a keyboard macro, but I would prefer a Lisp alternative. Transient Mark Mode is enabled by default in my Emacs. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: `yank-and-mark` command? 2015-07-05 18:02 ` Raffaele Ricciardi @ 2015-07-05 18:35 ` Stefan Monnier 2015-07-06 8:37 ` Raffaele Ricciardi 0 siblings, 1 reply; 11+ messages in thread From: Stefan Monnier @ 2015-07-05 18:35 UTC (permalink / raw) To: help-gnu-emacs > I am trying to mimic C-y C-x C-x. I have considered using > a keyboard macro, but I would prefer a Lisp alternative. That doesn't say in which way your code doesn't work like you want. But my guess is that the yank sets deactivate-mark and exchange-point-and-mark doesn't reset it, so after running the command the mark is deactivated by the default code that deactivates the mark after buffer modifications. So you'll want to add (setq deactivate-mark nil) either before or after exchange-point-and-mark. Stefan ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: `yank-and-mark` command? 2015-07-05 18:35 ` Stefan Monnier @ 2015-07-06 8:37 ` Raffaele Ricciardi 2015-07-06 13:50 ` Stefan Monnier [not found] ` <mailman.6444.1436190783.904.help-gnu-emacs@gnu.org> 0 siblings, 2 replies; 11+ messages in thread From: Raffaele Ricciardi @ 2015-07-06 8:37 UTC (permalink / raw) To: help-gnu-emacs On 05/07/15 20:35, Stefan Monnier wrote: >> I am trying to mimic C-y C-x C-x. I have considered using >> a keyboard macro, but I would prefer a Lisp alternative. > > So you'll want to add (setq deactivate-mark nil) either before or after > exchange-point-and-mark. This works. Thank you. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: `yank-and-mark` command? 2015-07-06 8:37 ` Raffaele Ricciardi @ 2015-07-06 13:50 ` Stefan Monnier [not found] ` <mailman.6444.1436190783.904.help-gnu-emacs@gnu.org> 1 sibling, 0 replies; 11+ messages in thread From: Stefan Monnier @ 2015-07-06 13:50 UTC (permalink / raw) To: help-gnu-emacs >> So you'll want to add (setq deactivate-mark nil) either before or after >> exchange-point-and-mark. > This works. Thank you. Note that the call to exchange-point-and-mark is redundant. Stefan ^ permalink raw reply [flat|nested] 11+ messages in thread
[parent not found: <mailman.6444.1436190783.904.help-gnu-emacs@gnu.org>]
* Re: `yank-and-mark` command? [not found] ` <mailman.6444.1436190783.904.help-gnu-emacs@gnu.org> @ 2015-07-06 14:45 ` Raffaele Ricciardi 2015-07-06 16:06 ` Stefan Monnier 0 siblings, 1 reply; 11+ messages in thread From: Raffaele Ricciardi @ 2015-07-06 14:45 UTC (permalink / raw) To: help-gnu-emacs On 06/07/15 15:50, Stefan Monnier wrote: > Note that the call to exchange-point-and-mark is redundant. Yet if I remove `exchange-point-and-mark', the command does not work any longer. Please compare the effects of the following command: (defun yank-and-mark/rr (&optional $arg) (interactive "*P") (yank $arg) (exchange-point-and-mark) (setq deactivate-mark nil)) with the same command, but without `exchange-point-and-mark'. Tested in the "*scratch*" buffer, after "emacs -Q". In Fundamental Mode, too. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: `yank-and-mark` command? 2015-07-06 14:45 ` Raffaele Ricciardi @ 2015-07-06 16:06 ` Stefan Monnier 2015-07-07 11:29 ` Nicolas Richard [not found] ` <mailman.6480.1436268552.904.help-gnu-emacs@gnu.org> 0 siblings, 2 replies; 11+ messages in thread From: Stefan Monnier @ 2015-07-06 16:06 UTC (permalink / raw) To: help-gnu-emacs > Yet if I remove `exchange-point-and-mark', the command does not > work any longer. Oh, I thought you called it with the region activated. If not, then indeed you still need to explicitly activate the region (which is better done with `activate-region' than with `exchange-point-and-mark' when called from Lisp). Stefan ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: `yank-and-mark` command? 2015-07-06 16:06 ` Stefan Monnier @ 2015-07-07 11:29 ` Nicolas Richard [not found] ` <mailman.6480.1436268552.904.help-gnu-emacs@gnu.org> 1 sibling, 0 replies; 11+ messages in thread From: Nicolas Richard @ 2015-07-07 11:29 UTC (permalink / raw) To: Stefan Monnier; +Cc: help-gnu-emacs Stefan Monnier <monnier@iro.umontreal.ca> writes: >> Yet if I remove `exchange-point-and-mark', the command does not >> work any longer. > > Oh, I thought you called it with the region activated. If not, then > indeed you still need to explicitly activate the region (which is > better done with `activate-region' than with `exchange-point-and-mark' > when called from Lisp). By the way, is there a reason `activate-mark' isn't interactive ? Sometimes I want to see where the mark is, and hitting C-x C-x C-x C-x is a bit too much... -- Nico ^ permalink raw reply [flat|nested] 11+ messages in thread
[parent not found: <mailman.6480.1436268552.904.help-gnu-emacs@gnu.org>]
* Re: `yank-and-mark` command? [not found] ` <mailman.6480.1436268552.904.help-gnu-emacs@gnu.org> @ 2015-07-07 11:50 ` Damien Wyart 2015-07-07 14:49 ` Stefan Monnier 1 sibling, 0 replies; 11+ messages in thread From: Damien Wyart @ 2015-07-07 11:50 UTC (permalink / raw) To: help-gnu-emacs * Nicolas Richard <youngfrog@members.fsf.org> in gnu.emacs.help: > Sometimes I want to see where the mark is, and hitting C-x C-x C-x C-x > is a bit too much... This package is quite useful for this: https://gitlab.com/iankelling/visible-mark/blob/master/visible-mark.el -- DW ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: `yank-and-mark` command? [not found] ` <mailman.6480.1436268552.904.help-gnu-emacs@gnu.org> 2015-07-07 11:50 ` Damien Wyart @ 2015-07-07 14:49 ` Stefan Monnier 1 sibling, 0 replies; 11+ messages in thread From: Stefan Monnier @ 2015-07-07 14:49 UTC (permalink / raw) To: help-gnu-emacs > By the way, is there a reason `activate-mark' isn't interactive ? No deep reason, no. Stefan ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2015-07-07 14:49 UTC | newest] Thread overview: 11+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2015-07-04 21:43 `yank-and-mark` command? Raffaele Ricciardi 2015-07-05 17:48 ` Michael Heerdegen [not found] ` <mailman.6386.1436118550.904.help-gnu-emacs@gnu.org> 2015-07-05 18:02 ` Raffaele Ricciardi 2015-07-05 18:35 ` Stefan Monnier 2015-07-06 8:37 ` Raffaele Ricciardi 2015-07-06 13:50 ` Stefan Monnier [not found] ` <mailman.6444.1436190783.904.help-gnu-emacs@gnu.org> 2015-07-06 14:45 ` Raffaele Ricciardi 2015-07-06 16:06 ` Stefan Monnier 2015-07-07 11:29 ` Nicolas Richard [not found] ` <mailman.6480.1436268552.904.help-gnu-emacs@gnu.org> 2015-07-07 11:50 ` Damien Wyart 2015-07-07 14:49 ` Stefan Monnier
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.