-
Notifications
You must be signed in to change notification settings - Fork 16
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
doest not work one Emacs 25.1 when use emacs-nox #6
Comments
I can confirm this trouble. The failure extends even to @redguardtoo : Do be aware that |
I have the same problem. It indicates success upon copy, but nothing copied. Using it on fedora in urxvt. |
Well, it has been nine+ months since the initial report, so I thought I would share my work-around, that doesn't require the simpleclip package at all. However, it does require the linux command line program ; x-clip support for emacs-nox / emacs-nw
(defun my-copy-to-xclipboard(arg)
(interactive "P")
(cond
((not (use-region-p))
(message "Nothing to yank to X-clipboard"))
((and (not (display-graphic-p))
(/= 0 (shell-command-on-region
(region-beginning) (region-end) "xsel -i -b")))
(error "Is program `xsel' installed?"))
(t
(when (display-graphic-p)
(call-interactively 'clipboard-kill-ring-save))
(message "Yanked region to X-clipboard")
(when arg
(kill-region (region-beginning) (region-end)))
(deactivate-mark))))
(defun my-cut-to-xclipboard()
(interactive)
(my-copy-to-xclipboard t))
(defun my-paste-from-xclipboard()
"Uses shell command `xsel -o' to paste from x-clipboard. With
one prefix arg, pastes from X-PRIMARY, and with two prefix args,
pastes from X-SECONDARY."
(interactive)
(if (display-graphic-p)
(clipboard-yank)
(let*
((opt (prefix-numeric-value current-prefix-arg))
(opt (cond
((= 1 opt) "b")
((= 4 opt) "p")
((= 16 opt) "s"))))
(insert (shell-command-to-string (concat "xsel -o -" opt))))))
(global-set-key (kbd "C-c C-w") 'my-cut-to-xclipboard)
(global-set-key (kbd "C-c M-w") 'my-copy-to-xclipboard)
(global-set-key (kbd "C-c C-y") 'my-paste-from-xclipboard) |
@Boruch-Baum - this is excellent. Thanks a lot for sharing. |
I actually made a small change and decided to use OSC 52 which will yank the text into the terminal. The advantage of this is that it works with tmux on a remote host without the need to forward X display. here is the code based on the one from @Boruch-Baum (defun my-copy-to-xclipboard(arg)
(interactive "P")
(if (use-region-p)
(if (not (display-graphic-p))
(letrec ((s (buffer-substring-no-properties (region-beginning) (region-end)))
(s-length (+ (* (length s) 3) 2)))
(if (<= s-length 16384) ; magic number set to the same as ESC_BUF_SIZ of suckless termial (st.c)
(progn
(send-string-to-terminal (concat "\e]52;c;"
(base64-encode-string (encode-coding-string s 'utf-8) t)
"\07"))
(message "Yanked region to terminal clipboard")
(when arg
(kill-region (region-beginning) (region-end)))
(deactivate-mark))
(message "Selection too long (%d) to send to terminal." s-length))))
(message "Nothing to yank to terminal clipboard"))) |
@fikovnik : Cool. I have a bunch of questions / comments / feedback:
|
You just add the name of the language used next to the fenced block (cf. the code section in examples in https://guides.github.com/features/mastering-markdown/)
Good point! Thanks!
Yes, I run emacs-nox in a tmux in an ssh session on a remote host. I did not want to keep forwarding X display and plus on some servers I cannot install xsel or xclip. I have not find any other way how to copy selected text.
This is a good idea. It would be actually interesting to see what is the limit for other terminal.
I guess there should be some limit. I don't think the terminal wants to allocate infinite memory. What this limit should I have no idea. This magic number is the one I actually set in my instance of st. The default was 128 ~ 380 characters.
Another good point.
Sure, this was just an alternative that fits my use case. For local use, yours is better since OSC is not supported in many terminal emulators. Anyway, thanks a lot for sharing your original code which helped me a lot to figure out the basics! |
It would be great if somebody (with more elisp knowledge) can put these things into working package :-) |
I just tried your code, using stterm as packaged by debian, and haven't got it to work. Any tricks, gotchas, or code patches necessary? Debian claims that the version of stterm is 5+..., but I agree about the idea of producing a working package with you, with the caveat that it not be specific to only stterm. |
I think the version is too old, i.e. without OSC 52 support. You can try my fork https://github.com/fikovnik/st The OSC 52, while being terminal agnostic, is not supported widely. I know only of xterm, urxvt and st that handle it. |
Same here: this mode advertises itself as seamless, but did not work. I'm running emacs -nw (I think still the gtk version, not nox) in a tmux terminal on my desktop. @Boruch-Baum version at least let's me copy to the X clipboard. |
Yes, arguably the TTY functionality is not "simple", and doesn't belong in this library. |
(x-get-selection 'CLIPBOARD)
returnnil
same issue happened on Debian Linux and Cygwin
The text was updated successfully, but these errors were encountered: