0

I know that on emacs I can install the xclip package in order to be able to copy text to the system clipboard... With the xclip package installed and adding the following to my .emacs file, I can copy the text inside emacs and paste it into another program.

(xclip-mode 1)

So far everything is fine. However, on spacemacs I'm struggling to make it work... I know I need to edit the .spacemacs file in order to make it work. But if I install the xclip package and change my user-config function to the following:

(defun dotspacemacs/user-config ()
  "Configuration for user code:
This function is called at the very end of Spacemacs startup, after layer
configuration.
Put your configuration code here, except for variables that should be set
before packages are loaded."
  (xclip-mode 1)
)

It doesn't work, if I try to copy text with yy (vim keybindings) it won't get to the system clipboard. What am I missing? What do I need to do in order to use xclip correctly on spacemacs?

4
  • 1
    Which OS are you using? Because , as far as I know, Spacemacs should copy to clipboard by default (e.g. when using yy). Commented Oct 19, 2022 at 5:29
  • @dalanicolai I'm using Ubuntu 20.04...
    – raylight
    Commented Oct 19, 2022 at 5:31
  • I am on Fedora and copy to clipboard works out of the box on X11 as well as on Wayland, I guess this should be the default behavior on Ubuntu also. Maybe you could ask in the Spacemacs gitter channel. Commented Oct 19, 2022 at 8:16
  • 1
    My experience is the same as @dalanicolai. Copying worked out of the box with yy. I don't even have xclip on my system right now.
    – g-gundam
    Commented Oct 19, 2022 at 15:06

1 Answer 1

0

I ended up finding a solution in a different question... If I add xclip to the dotspacemacs-additional-packages on the .spacemacs file as the following:

dotspacemacs-additional-packages '(xclip)

And then I leave the user-config function as it was in my original question it works fine and anything I copy inside spacemacs will get to the system clipboard:

(defun dotspacemacs/user-config ()
  "Configuration for user code:
This function is called at the very end of Spacemacs startup, after layer
configuration.
Put your configuration code here, except for variables that should be set
before packages are loaded."
  (xclip-mode 1)
)
5
  • As mentioned in the comments, copying to the clipboard should probably work by default. If it does not work out of the box, then there is probably something wrong with your setup so that you need this workaround. Have you tried starting Emacs from the terminal with the --debug-init flag (or similarly restart from within Spacemacs using SPC q d)? Commented Oct 20, 2022 at 6:29
  • @dalanicolai I'm new to the emacs world in general... I really didn't do much with config files besides installing emacs and spacemacs. I've even tried erasing my spacemacs folder and getting it from the original git repository again, could it be that the last github version has a bug? The clipboard wasn't working on a fresh install...
    – raylight
    Commented Oct 20, 2022 at 6:44
  • Okay, that sounds like you probably did things right then. So maybe can you check if you are using the develop branch? Otherwise, I have no idea what is going on there. I am not aware of any known issues that seem related to this behavior. Commented Oct 20, 2022 at 7:00
  • @dalanicolai I'm using the master branch currently... I've tried switching to the develop branch but the problem remains if I take out the xclip from my .spacemacs file the way I did on my answer...
    – raylight
    Commented Oct 20, 2022 at 7:34
  • 1
    Okay, that is strange, but so then nice to have the workaround. Also, somewhat confusingly, you really should be using the develop branch, which, for 'dubious' historic reasons, is the well maintained and recommended branch. There are plans to get rid of that old master branch, and make the current develop branch the new master branch. But for now... reallly use the develop branch (and also better ask Spacemacs questions in its gitter channel first). Commented Oct 20, 2022 at 7:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.