Subject: Re: bug#22434: 25.0.50; recentf pastes X clipboard upon opening

From: Benjamin Riefenstahl <[email-masked]>
Date: Wed, 25 May 2016 19:16:40 +0200

Hi Eli,

Eli Zaretskii writes:
> Thanks, but we'd prefer to have a solution for this bug that doesn't
> require the #23288 patch, so we could fix recentf on the release
> branch.  Could you perhaps come up with such a patch?

Does the attached fit the bill?  It works for me.  I hope I got the
formalities right.

IMO on master we really should either fix
mouse--down-1-maybe-follows-link like in #23288 or re-think this
strategy of generating an event for some random unknown consumer.

so long, benny

>From f1e368b62f9cb817c23bf1933f6820815ec20609 Mon Sep 17 00:00:00 2001
From: Benjamin Riefenstahl <[email-masked]>
Date: Wed, 25 May 2016 19:03:36 +0200
Subject: [PATCH] Fix bug#22434, recentf pastes X clipboard

A quick hack to avoid bug#22434.  Introduces a special symbol for this
purpose.
* lisp/mouse.el (mouse--down-1-maybe-follows-link): React to
'do-not-follow-link.
* lisp/recentf.el (recentf-open-files-item): Set :follow-link to
'do-not-follow-link.
---
 lisp/mouse.el   | 9 ++++++++-
 lisp/recentf.el | 6 ++++++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/lisp/mouse.el b/lisp/mouse.el
index fa355ff..4c31d65 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -98,7 +98,14 @@ mouse--down-1-maybe-follows-link
              (eq (if (eq mouse-1-click-follows-link 'double)
                      'double-down-mouse-1 'down-mouse-1)
                  (car-safe last-input-event))
-             (mouse-on-link-p (event-start last-input-event))
+             ;; Hack: Conspire with recentf-open-files-item to not do
+             ;; this in the recentf-open-files dialog.  The documented
+             ;; way would be to set :follow-link to a string or vector
+             ;; with a do-nothing event, but that does not work at
+             ;; this point, because this function does not implement
+             ;; that aspect.
+             (let ((action (mouse-on-link-p (event-start last-input-event))))
+               (and action (not (eq action 'do-not-follow-link))))
              (or mouse-1-click-in-non-selected-windows
                  (eq (selected-window)
                      (posn-window (event-start last-input-event)))))
diff --git a/lisp/recentf.el b/lisp/recentf.el
index df7f3e2..15114e3 100644
--- a/lisp/recentf.el
+++ b/lisp/recentf.el
@@ -1187,6 +1187,12 @@ recentf-open-files-item
            :format "%[%t\n%]"
            :help-echo ,(concat "Open " (cdr menu-element))
            :action recentf-open-files-action
+           ;; Hack: Conspire with mouse--down-1-maybe-follows-link to
+           ;; not add a spurious mouse-2 event.  The documented way
+           ;; would be to set :follow-link to a string or vector with
+           ;; a do-nothing event, but that does not work at this
+           ;; point.
+           :follow-link do-not-follow-link
            ,(cdr menu-element))))
 
 (defun recentf-open-files-items (files)
-- 
2.1.4