* `insert' inside `with-current-buffer' deactivating the mark?
@ 2013-03-04 14:19 Michael Heerdegen
2013-03-04 14:48 ` Christopher Schmidt
0 siblings, 1 reply; 4+ messages in thread
From: Michael Heerdegen @ 2013-03-04 14:19 UTC (permalink / raw)
To: emacs-devel
Hi,
if I eval the following in emacs -Q:
--8<---------------cut here---------------start------------->8---
(defun insert-in-some-other-buffer ()
(with-current-buffer (get-buffer-create "*Test*")
(insert ".")))
(add-hook 'post-command-hook 'insert-in-some-other-buffer)
--8<---------------cut here---------------end--------------->8---
the mark in any buffer is deactivated immediately after each command.
Looks like a bug to me - the use of `with-current-buffer' should prevent
influencing any other buffer than *Test*. What am I missing?
Thanks,
Michael.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: `insert' inside `with-current-buffer' deactivating the mark?
2013-03-04 14:19 `insert' inside `with-current-buffer' deactivating the mark? Michael Heerdegen
@ 2013-03-04 14:48 ` Christopher Schmidt
2013-03-04 14:59 ` Michael Heerdegen
0 siblings, 1 reply; 4+ messages in thread
From: Christopher Schmidt @ 2013-03-04 14:48 UTC (permalink / raw)
To: emacs-devel
Michael Heerdegen <michael_heerdegen@web.de> writes:
> if I eval the following in emacs -Q:
> (defun insert-in-some-other-buffer ()
> (with-current-buffer (get-buffer-create "*Test*")
> (insert ".")))
>
> (add-hook 'post-command-hook 'insert-in-some-other-buffer)
>
> the mark in any buffer is deactivated immediately after each command.
> Looks like a bug to me - the use of `with-current-buffer' should
> prevent influencing any other buffer than *Test*. What am I missing?
deactivate-mark
Christopher
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: `insert' inside `with-current-buffer' deactivating the mark?
2013-03-04 14:48 ` Christopher Schmidt
@ 2013-03-04 14:59 ` Michael Heerdegen
2013-03-04 18:21 ` Stefan Monnier
0 siblings, 1 reply; 4+ messages in thread
From: Michael Heerdegen @ 2013-03-04 14:59 UTC (permalink / raw)
To: emacs-devel
Christopher Schmidt <christopher@ch.ristopher.com> writes:
> Michael Heerdegen <michael_heerdegen@web.de> writes:
> > if I eval the following in emacs -Q:
> > (defun insert-in-some-other-buffer ()
> > (with-current-buffer (get-buffer-create "*Test*")
> > (insert ".")))
> >
> > (add-hook 'post-command-hook 'insert-in-some-other-buffer)
> >
> > the mark in any buffer is deactivated immediately after each command.
> > Looks like a bug to me - the use of `with-current-buffer' should
> > prevent influencing any other buffer than *Test*. What am I missing?
>
> deactivate-mark
Thanks. Yes, I know `deactivate-mark' - but why is it necessary here?
Why does changing another buffer deactivate the mark in the current
buffer?
Even if you activate the mark in one buffer, manually switch to another
buffer, edit it, and come back to the first buffer, the mark is still
active there.
Michael.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: `insert' inside `with-current-buffer' deactivating the mark?
2013-03-04 14:59 ` Michael Heerdegen
@ 2013-03-04 18:21 ` Stefan Monnier
0 siblings, 0 replies; 4+ messages in thread
From: Stefan Monnier @ 2013-03-04 18:21 UTC (permalink / raw)
To: emacs-devel
> Thanks. Yes, I know `deactivate-mark' - but why is it necessary here?
> Why does changing another buffer deactivate the mark in the current
> buffer?
Because deactivate-mark is a global variable. Note also that the mark is
not deactivated in some cases where it "should":
M-: (progn (insert "a") (set-buffer (other-buffer))) RET
IOW the auto-deactivation is just a coarse heuristic, which only covers
most cases, but not all.
Stefan
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-03-04 18:21 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-04 14:19 `insert' inside `with-current-buffer' deactivating the mark? Michael Heerdegen
2013-03-04 14:48 ` Christopher Schmidt
2013-03-04 14:59 ` Michael Heerdegen
2013-03-04 18:21 ` 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.