[PATCH] emacs: do not put quoted reply in primary selection
Mark Walters
markwalters1009 at gmail.com
Sun Nov 17 04:04:09 PST 2013
In current emacs (24.3) select-active-regions is set to t by
default. The reply insertion code sets the region to the quoted
message to make it easy to delete (kill-region or C-w). These two
things combine to put the quoted message in the primary selection.
This is not what the user wanted and is a privacy risk (accidental
pasting of the quoted message). We can avoid some of the problems
by let-binding select-active-regions to nil. This fixes if the
primary selection was previously in a non-emacs window but not if
it was in an emacs window. To avoid the problem in the latter case
we deactivate mark.
One key test (which fails under many simpler "fixes") is: open emacs
24.3 with notmuch, open 2 windows (viewing different notmuch buffers),
highlight some text in one, and then reply to a message in the
other. In many of my earlier attempts to fix this big this test fails.
---
This problem was first discussed in the thread starting with jrollins
bug report in id:87vc1y6fbr.fsf at servo.finestructure.net. I couldn't
persuade the fixes mentioned in id:87hadh934c.fsf at qmul.ac.uk to work
in all cases.
The most difficult case to fix was when emacs already had a
highlighted section. The simpler fixes mentioned did fix the case when
the primary selection was in some non-emacs window (eg an xterm).
Unfortunately there are lots of cases that need checking: differnent
versions of emacs (at least 23 and 24), the various settings of
select-active-regions (nil, t, 'only), does cutting the quoted message
work, and possibly the various setting affecting whether cut text goes
in the primary-selction or the clipboard.
I have tested on emacs 23.4 and 24.3 on debian stable (ish) with all
three possibilities for select-active-regions (note 'only was
introduced in emacs 24 so is not relevant for emacs 23)
Anyway, this is the best I can manage!
Finally, note that I normally use emacs23 and this bug is not present
there (unless the user has customised select-active-regions to t) so I
have not given this patch a lot of testing.
Best wishes
Mark
emacs/notmuch-mua.el | 19 +++++++++++++++++--
1 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el
index 53802d2..00cd980 100644
--- a/emacs/notmuch-mua.el
+++ b/emacs/notmuch-mua.el
@@ -346,10 +346,25 @@ the From: address first."
If PROMPT-FOR-SENDER is non-nil, the user will be prompted for
the From: address first. If REPLY-ALL is non-nil, the message
will be addressed to all recipients of the source message."
+
+;; In current emacs (24.3) select-active-regions is set to t by
+;; default. The reply insertion code sets the region to the quoted
+;; message to make it easy to delete (kill-region or C-w). These two
+;; things combine to put the quoted message in the primary selection.
+;;
+;; This is not what the user wanted and is a privacy risk (accidental
+;; pasting of the quoted message). We can avoid some of the problems
+;; by let-binding select-active-regions to nil. This fixes if the
+;; primary selection was previously in a non-emacs window but not if
+;; it was in an emacs window. To avoid the problem in the latter case
+;; we deactivate mark.
+
(let ((sender
(when prompt-for-sender
- (notmuch-mua-prompt-for-sender))))
- (notmuch-mua-reply query-string sender reply-all)))
+ (notmuch-mua-prompt-for-sender)))
+ (select-active-regions nil))
+ (notmuch-mua-reply query-string sender reply-all)
+ (deactivate-mark)))
(defun notmuch-mua-send-and-exit (&optional arg)
(interactive "P")
--
1.7.9.1
More information about the notmuch
mailing list