* [PATCH] emacs: do not put quoted reply in primary selection
@ 2013-11-17 12:04 Mark Walters
2013-11-17 19:37 ` Jameson Graef Rollins
2013-11-20 0:59 ` David Bremner
0 siblings, 2 replies; 5+ messages in thread
From: Mark Walters @ 2013-11-17 12:04 UTC (permalink / raw)
To: notmuch
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@servo.finestructure.net. I couldn't
persuade the fixes mentioned in id:87hadh934c.fsf@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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] emacs: do not put quoted reply in primary selection
2013-11-17 12:04 [PATCH] emacs: do not put quoted reply in primary selection Mark Walters
@ 2013-11-17 19:37 ` Jameson Graef Rollins
2013-11-17 19:42 ` Tomi Ollila
2013-11-20 0:59 ` David Bremner
1 sibling, 1 reply; 5+ messages in thread
From: Jameson Graef Rollins @ 2013-11-17 19:37 UTC (permalink / raw)
To: Mark Walters, notmuch
[-- Attachment #1: Type: text/plain, Size: 1175 bytes --]
On Sun, Nov 17 2013, Mark Walters <markwalters1009@gmail.com> wrote:
> 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.
I'm very happy to report that I reply to this message with an unpolluted
paste buffer! Kudos Mark!
> Anyway, this is the best I can manage!
Too modest for such an achievement.
+10
jamie.
[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] emacs: do not put quoted reply in primary selection
2013-11-17 19:37 ` Jameson Graef Rollins
@ 2013-11-17 19:42 ` Tomi Ollila
2013-11-17 20:41 ` Mark Walters
0 siblings, 1 reply; 5+ messages in thread
From: Tomi Ollila @ 2013-11-17 19:42 UTC (permalink / raw)
To: Jameson Graef Rollins, Mark Walters, notmuch
On Sun, Nov 17 2013, Jameson Graef Rollins <jrollins@finestructure.net> wrote:
> On Sun, Nov 17 2013, Mark Walters <markwalters1009@gmail.com> wrote:
>> 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.
>
> I'm very happy to report that I reply to this message with an unpolluted
> paste buffer! Kudos Mark!
>
>> Anyway, this is the best I can manage!
>
> Too modest for such an achievement.
>
> +10
This works for me too (and tests pass).
I don't see how this could break thinks, So I think this is important
enough th be included in 0.17
> jamie.
Tomi
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] emacs: do not put quoted reply in primary selection
2013-11-17 19:42 ` Tomi Ollila
@ 2013-11-17 20:41 ` Mark Walters
0 siblings, 0 replies; 5+ messages in thread
From: Mark Walters @ 2013-11-17 20:41 UTC (permalink / raw)
To: Tomi Ollila, Jameson Graef Rollins, notmuch
On Sun, 17 Nov 2013, Tomi Ollila <tomi.ollila@iki.fi> wrote:
> On Sun, Nov 17 2013, Jameson Graef Rollins <jrollins@finestructure.net> wrote:
>
>> On Sun, Nov 17 2013, Mark Walters <markwalters1009@gmail.com> wrote:
>>> 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.
>>
>> I'm very happy to report that I reply to this message with an unpolluted
>> paste buffer! Kudos Mark!
>>
>>> Anyway, this is the best I can manage!
>>
>> Too modest for such an achievement.
>>
>> +10
>
> This works for me too (and tests pass).
That's great.
> I don't see how this could break thinks, So I think this is important
> enough th be included in 0.17
I think the only thing that could break is the ability to cut the quoted
message with kill-region/ctrl-w. That is probably minor enough that we
do not need to worry too much.
Best wishes
Mark
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] emacs: do not put quoted reply in primary selection
2013-11-17 12:04 [PATCH] emacs: do not put quoted reply in primary selection Mark Walters
2013-11-17 19:37 ` Jameson Graef Rollins
@ 2013-11-20 0:59 ` David Bremner
1 sibling, 0 replies; 5+ messages in thread
From: David Bremner @ 2013-11-20 0:59 UTC (permalink / raw)
To: Mark Walters, notmuch
Mark Walters <markwalters1009@gmail.com> writes:
>
> Anyway, this is the best I can manage!
>
pushed,
d
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-11-20 0:59 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-17 12:04 [PATCH] emacs: do not put quoted reply in primary selection Mark Walters
2013-11-17 19:37 ` Jameson Graef Rollins
2013-11-17 19:42 ` Tomi Ollila
2013-11-17 20:41 ` Mark Walters
2013-11-20 0:59 ` David Bremner
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
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).