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

Clicking a link in recentf in the startup screen causes contents from the kill-ring from the previous session to be pasted in the opened buffer. #5059

Closed
3rd3 opened this issue Feb 14, 2016 · 18 comments
Labels
- Bug tracker - Emacs 25.1 stale marked as a stale issue/pr (usually by a bot)

Comments

@3rd3
Copy link

3rd3 commented Feb 14, 2016

I don't make use of custom settings for persistence like desktop, so I suspect this to be an issue regarding a certain persistence package that is configured by Spacemacs. I've also tried removing the .cache folder, but it still occurs. Which packages could cause this behavior?

@StreakyCobra
Copy link
Contributor

Can you please update your issue to follow this template?

@3rd3 3rd3 changed the title Whenever I open a file, Spacemacs yanks some contents from the kill-ring from the previous session. Whenever I open a file by clicking one of the Recent Files in the startup screen, Spacemacs yanks some contents from the kill-ring from the previous session. Mar 13, 2016
@3rd3
Copy link
Author

3rd3 commented Mar 13, 2016

Description

Clicking a recently opened file in Recent Files in the startup screen inserts some text. This does not occur then opening a file via find-file.

System Info

  • OS: OS X
  • Emacs: 25.1.50.1
  • Spacemacs: 0.105.14
  • Spacemacs branch: master
  • Distribution: Spacemacs
  • Editing style: VIM
  • Completion: Helm

@3rd3
Copy link
Author

3rd3 commented Mar 13, 2016

Interestingly, this also does not happen when clicking the recent file link by pressing space bar. I tried searching any bindings to mouse-1 in my configuration, but I could not find anything suspicious.

@StreakyCobra
Copy link
Contributor

Have you some precise reproduction steps? Because clicking on a link in the recentf list doesn't yank anything on my side.

@3rd3
Copy link
Author

3rd3 commented Mar 13, 2016

I just click a link in the recentf after starting Emacs and it pastes something into the file buffer it switches to. This also occurs, if the file is already loaded in some buffer.

@3rd3
Copy link
Author

3rd3 commented Mar 13, 2016

These are my activated layers:

 auto-completion
 spell-checking
 syntax-checking
 (ibuffer :variables
          ibuffer-group-buffers-by nil
          )
 (ranger :variables
         ranger-ignored-extensions '(
                                     "mkv" "iso" "mp4" "avi" "mp4" "mkv"
                                     "zip" "rar" "exe" "ps" "webm" "png"
                                     "jpg" "jpeg" "tif" "tiff" "ics" "dmg"
                                     "swf" "gz" "m4a")
         ranger-max-preview-size 4  ;; Megabyte
         ranger-cleanup-eagerly t
         )
 (latex :variables
        latex-enable-auto-fill t)
 org
 git
 github
 version-control
 finance
 extra-langs
 markdown
 emacs-lisp
 haskell
 html
 javascript
 ipython-notebook
 shell-scripts
 java
 (haskell :variables
          haskell-enable-ghc-mod-support nil
          haskell-enable-ghci-ng-support t
          haskell-enable-hindent-style "gibiansky"
          haskell-enable-shm-support nil
          )
 (c-c++ :variables
        c-c++-enable-clang-support t
        )
 gtags
 (python :variables
         python-test-runner 'pytest
         )
 (clojure :variables
          clojure-enable-fancify-symbols t
          )
 (shell :variables
        shell-default-height 20
        shell-default-position 'bottom
        shell-enable-smart-eshell t
        shell-default-shell 'eshell)
 evil-commentary
 )

@3rd3 3rd3 changed the title Whenever I open a file by clicking one of the Recent Files in the startup screen, Spacemacs yanks some contents from the kill-ring from the previous session. Clicking a link in recentf in the startup screen causes contents from the kill-ring from the previous session to be pasted in the opened buffer. Mar 13, 2016
@3rd3
Copy link
Author

3rd3 commented Mar 13, 2016

@StreakyCobra I could reproduce it with a blank Spacemacs install:

  1. Open a .tex file, copy and delete some text sections, save file.
  2. Close and re-open Emacs.
  3. Click (mouse-1) .tex file in recentf.
  4. Switch back to *spacemacs* buffer.
  5. Click .tex file in recentf again.
  6. Observe text having been inserted (dirty flag of file is set).

@StreakyCobra
Copy link
Contributor

I can't reproduce this, even with a fresh install 😳

@denki
Copy link

denki commented Nov 8, 2016

I have the same problem. The text that is pasted into the emacs buffer seems to come from the selection buffer of X.

System Info 💻

  • OS: gnu/linux
  • Emacs: 25.1.1
  • Spacemacs: 0.200.5
  • Spacemacs branch: master (rev. 664ba6a)
  • Graphic display: t
  • Distribution: spacemacs
  • Editing style: vim
  • Completion: helm
  • Layers:
(auto-completion emacs-lisp haskell spell-checking syntax-checking themes-megapack)
  • System configuration features: XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GCONF GSETTINGS NOTIFY ACL GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11

@bmag
Copy link
Contributor

bmag commented Nov 9, 2016

Copying my comment from the duplicate issue #6765:

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

@edwintorok
Copy link
Contributor

edwintorok commented Dec 13, 2016

Same problem here with Emacs 25.1.1

Description :octocat:

Left clicking on a file in the Recent files list in the spacemacs buffer causes text from the clipboard to be inserted into the file.
This is quite annoying when I just want to open a source file for reading.

Reproduces every time with Emacs 25 on Gentoo, doesn't reproduce with Emacs 24.5.1 on Ubuntu Yakkety.

Workaround from #6765 (comment) makes the problem go away.

Reproduction guide 🪲

  • Install minimal Spacemacs
$ mkdir spacemacsbug && cd spacemacsbug && export HOME=~/spacemacsbug
$ git clone https://github.com/syl20bnr/spacemacs .emacs.d
$ emacs
Choose `evil`, `minimal`, and `none` (for completion).
  • Start Emacs
  • Edit a file, write some text into it and save it (e.g. :e ~/testing<CR>ifoo<ESC>:w)
  • Restart Emacs (SPC q q, and start)
  • Select something with the mouse such that middle click would paste it (e.g. from the browser or terminal)
  • Left-click on ~/testing in the Recent Files section

Observed behaviour: 👀 💔
Text from mouse selection gets pasted, e.g. my buffer looks like this after left click:

foodrwxr-xr-x   3 edwin edwin  4096 Dec 13 13:08 .

Expected behaviour: ❤️ 😄
The buffer is unaltered, and random stuff from the clipboard doesn't get pasted into my source files.

System Info 💻

  • OS: gnu/linux
  • Emacs: 25.1.1
  • Spacemacs: 0.200.5
  • Spacemacs branch: master (rev. 664ba6a)
  • Graphic display: t
  • Distribution: spacemacs-base
  • Editing style: vim
  • Completion: helm
  • Layers:
(emacs-lisp)
  • System configuration features: XPM JPEG TIFF GIF PNG RSVG SOUND GPM DBUS NOTIFY ACL GNUTLS FREETYPE XFT ZLIB GTK3 X11

Desktop: Xfce 4.12, Distribution: Gentoo

Trace 🐾

view-lossage shows that mouse-yank-primary gets executed. (Note: I only clicked the left button)

 <return> [Buffer-menu-this-window]
 <down-mouse-1> <mouse-1> <mouse-1> [widget-button-click]
 <mouse-2> [mouse-yank-primary]
 M-x [execute-extended-command]
 v [self-insert-command]
 i [self-insert-command]
 e [self-insert-command]
 w [self-insert-command]
 - [self-insert-command]
 l [self-insert-command]
 o [self-insert-command]
 s [self-insert-command]
 s [self-insert-command]
 a [self-insert-command]
 g [self-insert-command]
 e [self-insert-command]
 <return> [minibuffer-complete-and-exit]

[back]

In xev clicking the left mouse looks like this:

ButtonPress event, serial 37, synthetic NO, window 0x4a00001,
    root 0x49f, subw 0x0, time 8476039, (47,109), root:(918,564),
    state 0x10, button 1, same_screen YES

ButtonRelease event, serial 37, synthetic NO, window 0x4a00001,
    root 0x49f, subw 0x0, time 8476150, (47,109), root:(918,564),
    state 0x110, button 1, same_screen YES

@sebhofer
Copy link

I observe the exact same behaviour under Linux, emacs version 25.0.93, spacemacs 0.200.9. Is there any progress on this?

@amrhassan
Copy link

Same for me on Arch Linux.

@hliebert
Copy link

hliebert commented Feb 7, 2018

Also experiencing this on Arch Linux, Emacs 25.3.1, latest develop branch.

@jaminsore
Copy link

jaminsore commented Mar 2, 2018

Same on Kubuntu 17.10, emacs 25.2.2, spacemacs 0.200.13. I'm happy to find out it's a known issue, and not me being careless with my keystrokes, though.

@4goodapp
Copy link

4goodapp commented Mar 20, 2018

Same on Debian Buster testing , Emacs 25.2.2, Spacemacs 0.200.10.

I'm happy to find out it's a known issue, and not me being careless with my keystrokes, though.

Same here.

The solution mentioned on :#10380 (comment) seems to fix the issue for me:
add in the dotspacemacs/user-config section of your .spacemacs file.

(add-hook 'spacemacs-buffer-mode-hook (lambda ()
(set (make-local-variable 'mouse-1-click-follows-link) nil)))

@neverfox
Copy link

neverfox commented Apr 2, 2018

Can confirm, OS X, 0.200.1@25.3.1, and that @4goodapp's solution works.

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Please let us know if this issue is still valid!

@github-actions github-actions bot added the stale marked as a stale issue/pr (usually by a bot) label Feb 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- Bug tracker - Emacs 25.1 stale marked as a stale issue/pr (usually by a bot)
Projects
None yet
Development

No branches or pull requests