Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Content of clipboard is pasted into selected Recent Files automatically #6765

Closed
kc1212 opened this issue Aug 5, 2016 · 4 comments
Closed

Comments

@kc1212
Copy link

kc1212 commented Aug 5, 2016

Hello,

After starting spacemacs, I often go to the bottom of the *spacemacs* buffer to open one of my recently used files. At this point, if I have something in my clipboard, the content of the clipboard gets automatically pasted into the new buffer. This only happens when I left click the file name using my mouse. If move my cursor to the file name using the vim keys and hit enter then it's fine.

It happens for both Rust code and the .spacemacs file so I suspect it's not specific to a single language layer. I was able to reproduce the issue in both master and develop.

I'm using Fedora 24 with GNOME 3.20 (if that matters).

System Info 💻

  • OS: gnu/linux
  • Emacs: 25.1.1
  • Spacemacs: 0.105.21
  • Spacemacs branch: develop (rev. 7280a46)
  • Graphic display: t
  • Distribution: spacemacs
  • Editing style: vim
  • Completion: helm
  • Layers:
(auto-completion better-defaults emacs-lisp git markdown org
                 (shell :variables shell-default-shell 'eshell shell-default-height 30 shell-default-position 'bottom)
                 syntax-checking version-control c-c++ rust go haskell shell-scripts latex)
@bmag
Copy link
Collaborator

bmag commented Aug 5, 2016

Reproduced on with Emacs 25.0.95.1 (last pretest before RC1) on Ubuntu 16.04, using latest develop and spacemacs-base distribution freshly installed. As a temporary work-around you can add this to user-config:

(define-key spacemacs-buffer-mode-map [down-mouse-1] nil)

Note that you can open recent files without the mouse:

  • r jumps to recent files list
  • o opens a link, and can be used for opening recent files (the link is chosen with avy)

I'll post more details later.

@bmag
Copy link
Collaborator

bmag commented Aug 6, 2016

Spacemacs binds [down-mouse-1] to widget-button-click in the home buffer (source), shadowing Evil's evil-mouse-drag-region. It works fine on Ubuntu 16.04 with Emacs 24.5, but on Emacs 25 it shows the reported bug.

I have tried to debug why the clipboard text is inserted to the buffer, but I couldn't find where that happens. Stepping through widget-button-click with Edebug revealed that the text is inserted after widget-button-click returns, so it isn't really widget-button-click that inserts the text. This is very weird, and I suspect a bug in Evil or Emacs 25, or that we are using the wrong function. It didn't seem that widget-button-click had any advices defined either.

Removing the widget-button-click bindings prevents the text-insertion bug, but causes another inconvenience. Clicking the recent-file link opens the file and doesn't insert extra text, but it also activates the region in the home buffer.

I have managed to reproduce the bug outside of the home buffer (but still inside Spacemacs) by evaluating the following code, and then in the scratch buffer calling M-x create-debug-button and M-x set-debug-click. This created a button that has the same behavior, bug included.

(defun create-debug-button ()
  (interactive)
  (widget-create 'push-button
                 :action (lambda (&rest ignore)
                           (find-file-existing "~/tmp-file"))
                 :mouse-face 'highlight
                 :follow-link "\C-m"
                 :button-prefix ""
                 :button-suffix ""
                 :format "%[%t%]"
                 (abbreviate-file-name  "~/tmp-file")))
(defun set-debug-click ()
  (interactive)
  (local-set-key [down-mouse-1] 'widget-button-click))

I don't know if I'll have time to debug this further, but the next steps should be:

  • try to reproduce the bug in emacs -Q with or without evil-mode
  • check if there is a better command to use than widget-click-button

@kc1212
Copy link
Author

kc1212 commented Aug 8, 2016

Thanks for the tip @bmag, I didn't know you could use r to jump straight to recent files.

@TheBB
Copy link
Collaborator

TheBB commented Nov 8, 2016

Duplicate #5059

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants