Treemacs: Spacemacs: loosing copied content while moving to another file.

Created on 3 Feb 2019  ·  10Comments  ·  Source: Alexander-Miller/treemacs

HOW TO REPRODUCE:
Copy a text block y in the opened buffer.
Move to another file via treemaps and open it in place of the previous buffer.
Messages buffer writes somewhat:

Saving file /home/andrey/.emacs.d/.cache/treemacs-persist...
Wrote /home/andrey/.emacs.d/.cache/treemacs-persist

Try to paste copied text block p:
You paste Project name.

Not sure if it can be reproduced 100% times, but appears really often and annoys hard

Most helpful comment

I'm using l (Lowercase L) to open subfolders and navigate into,

You should've said so from the start. With this info I've found the culprit.

Lesson of the day: Don't use kill-whole-line if you don't want to pollute the kill-ring. Use something like (delete-region (point-at-bol) (1+ (line-end-position))) instead.

I'll be dropping a patch tomorrow.

All 10 comments

Cannot reproduce. Some really weird is going on here.

Saving file /home/andrey/.emacs.d/.cache/treemacs-persist...

That only happens if something changes with your projects, when one is added, removed or a position is changed.

You paste Project name.

And that only happens when you call treemacs-copy-project-root which is bound to yr.

So yeah, what version of spacemacs and treemacs are you on, what keys do you press and what does your config look like.

https://github.com/Antiarchitect/.dotfiles/blob/master/.spacemacs
Spacemacs is latest develop branch treemacs layer updates with it.
It's enough to open file from one project, select and copy block with y, SPC-0 back to Treemacs, go to another project, open file with o-o in place of the old, and try to paste with p. I'm pretty sure I don't press r during this procedure.

Let's get a tie breaker, and ask other spacemacs+treemacs users: @duianto, @TimoFreiberg - can you guys do me the favor and see if you can reproduce this?

TLDR:

It seems to be working as expected.

Long version:

With two projects defined Treemacs (both cloned from their github repositories):

  • helm
  • spacemacs-theme

Steps to reproduce

  • Restart Spacemacs develop (rev. bd77a5df6) without resuming files/layouts SPC q R
  • Open Treemacs SPC f t
  • Open helm-adaptive.el
  • Copy yy the first line:
;;; helm-adaptive.el --- Adaptive Sorting of Candidates. -*- lexical-binding: t -*-
  • Select the Treemacs window SPC 0
  • Select the next project (spacemacs-theme) C-j
  • Center the selection in the Treemacs window C-l (Ctrl and lowercase L)
  • Open spacemacs-common.el o o
  • Paste p

Observed and Expected

The copied line from the first file is inserted after the second files first line

;;; spacemacs-common.el --- Color theme with a dark and light versions.
;;; helm-adaptive.el --- Adaptive Sorting of Candidates. -*- lexical-binding: t -*-

System Info :computer:

  • OS: windows-nt
  • Emacs: 26.1
  • Spacemacs: 0.300.0
  • Spacemacs branch: develop (rev. bd77a5df6)
  • Graphic display: t
  • Distribution: spacemacs
  • Editing style: vim
  • Completion: helm
  • Layers:
(autohotkey colors emacs-lisp git helm html ibuffer markdown multiple-cursors org spell-checking treemacs version-control)
  • System configuration features: XPM JPEG TIFF GIF PNG RSVG SOUND NOTIFY ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS THREADS LCMS2

Can't reproduce either.
I used the same commands as you guys.
Emacs 26.1, Archlinux, Spacemacs develop

I'm using l (Lowercase L) to open subfolders and navigate into, h - to move to parent - seems habit from Neotree. Use j to move down, and k for up. Don't use C-j C-l

Confirmed.

One doesn't have to copy anything, the kill-ring gets entries just by navigating with h or l (lowercase L).

With a project called project that has a subdir dir1.

  • Clear the kill-ring from the Eval: prompt (S-M-;)
(setq kill-ring nil)

kill-ring is a variable defined in ‘simple.el’.
Its value is nil

  • With project as root, select the subdir dir1
  • Change root to dir1 with l
    Pasting in a buffer inserts:

The kill-ring now contains:

Value:
(#(" project
" 0 1
(img-unselected #2=(image :type png :file "c:/Users/username/.emacs.d/elpa/26.1/develop/treemacs-20190204.1821/icons/root.png" :scale 1 :ascent center :background "#292b2e")
img-selected
(image :type png :file "c:/Users/username/.emacs.d/elpa/26.1/develop/treemacs-20190204.1821/icons/root.png" :scale 1 :ascent center :background "#212026")
display #2#)
2 9
(button
(t)
category default-button face treemacs-root-face :project #s(treemacs-project "project" #1="c:/project")
:symlink nil :state root-node-closed :path #1# :depth 0))
#("kill-ring is a variable defined in ‘simple.el’.
Its value is nil
" 0 36
(yank-handler #1=(evil-yank-line-handler nil t))
36 45
(help-args
(kill-ring "c:/Users/username/Applications/emacs-26.1-x86_64/share/emacs/26.1/lisp/simple.el")
category help-variable-def-button button
(t)
yank-handler #1#)
45 65
(yank-handler #1#)))

  • Clearing the kill-ring again and changing back the root to project with h
    Pasting in a buffer inserts:

The kill-ring contains:

Value:
(#(" dir1" 0 1
(img-unselected
(image :type png :file "c:/Users/username/.emacs.d/elpa/26.1/develop/treemacs-20190204.1821/icons/root.png" :scale 1 :ascent center :background "#292b2e")
img-selected #2=(image :type png :file "c:/Users/username/.emacs.d/elpa/26.1/develop/treemacs-20190204.1821/icons/root.png" :scale 1 :ascent center :background "#212026")
display #2#)
2 6
(button
(t)
category default-button face treemacs-root-face :project #s(treemacs-project "dir1" #1="c:/project/dir1")
:symlink nil :state root-node-closed :path #1# :depth 0)))

I'm using l (Lowercase L) to open subfolders and navigate into,

You should've said so from the start. With this info I've found the culprit.

Lesson of the day: Don't use kill-whole-line if you don't want to pollute the kill-ring. Use something like (delete-region (point-at-bol) (1+ (line-end-position))) instead.

I'll be dropping a patch tomorrow.

Guys, I'm very new to emacs/spacemacs (but I'm in love though) so didn't understand a single word. But patch sounds great to me!

@Antiarchitect Welcome. Don't worry you'll learn the more you use it. 😺

@Alexander-Miller The fix seems to be working, the kill-ring isn't modified after changing the root up or down. Thanks 👍

Was this page helpful?
0 / 5 - 0 ratings