From: Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org>
To: help-gnu-emacs@gnu.org
Subject: Re: NonGNU ELPA
Date: Sun, 23 Jan 2022 17:39:50 +0100 [thread overview]
Message-ID: <87v8yaz9rd.fsf@zoho.eu> (raw)
In-Reply-To: jwvfspe775q.fsf-monnier+emacs@gnu.org
Stefan Monnier via Users list for the GNU Emacs text editor wrote:
> The question w.r.t `xsel.el` is whether the functionality it
> offers via `xsel` is different from that offered by
> `xclip.el` (eithef via `xsel` or via other means), and if so
> whether the two shoud be combined/merged or kept separate
> (like `gpastel.el` is currently kept separate).
xsel.el is only 85 lines (including the bulk of standard
documentation) so please find out ...
It is a getter, a setter, two Emacs-specific applications and
a shorthand.
Very basic one would think?
;;; xsel.el --- use the X clipboard -*- lexical-binding: t -*-
;;;
;;; Commentary:
;;;
;;; Author: Emanuel Berg (incal) <moasenwood@zoho.eu>
;;; Created: 2021-05-04
;;; Keywords: unix
;;; License: GPL3+
;;; URL: https://dataswamp.org/~incal/emacs-init/xsel.el
;;; Version: 2.3.7
;;;
;;; This gives you access to the X clipboard from a Linux
;;; VT/console/tty Emacs instance (or any Emacs, possibly).
;;; Set and/or Insert the X clipboard at point.
;;;
;;; DWIM: If there is a region, replace it with the
;;; X clipboard.
;;;
;;; Feature: Set the X clipboard programmatically in Elisp or
;;; set it interactively to the contents of the region (if
;;; there is one), otherwise set it to the most recent
;;; Emacs kill.
;;;
;;; Use $DISPLAY or ":0" with xsel(1x).
;;;
;;; Code:
(let ((xsel-x-display (or (getenv "DISPLAY") ":0")))
(defun insert-x-clipboard ()
"Insert the X clipboard at point using xsel(1x).
If there is a region it is overwritten."
(interactive)
(when (use-region-p)
(delete-region (region-beginning) (region-end)) )
(shell-command
(format "xsel --display \"%s\" --clipboard -o" xsel-x-display)
1) ; insert in current buffer
(goto-char (mark)) )
(declare-function insert-x-clipboard nil)
(defun set-x-clipboard (str)
"Set the X clipboard to STR. When used interactively, STR
is either what is in the region, if available, if not the most
recent Emacs kill is used."
(interactive
(list (if (use-region-p)
(buffer-substring-no-properties (region-beginning) (region-end))
(encode-coding-string (current-kill 0 t) 'utf-8-unix) )))
(shell-command
(format "echo -n %s | xsel --display %s -b -i"
(shell-quote-argument str)
xsel-x-display) ))
(declare-function set-x-clipboard nil) )
(defun x-copy (&optional beg end)
"Copy the buffer text from BEG to END to the X clipboard.
Unless optional arguments are provided the whole buffer text is used."
(interactive (when (use-region-p)
(list (region-beginning) (region-end)) ))
(let ((b (or beg (point-min)))
(e (or end (point-max))) )
(set-x-clipboard (buffer-substring b e) )))
(defun x-copy-symbol (sym)
"Copy the value of SYM to the X clipboard."
(interactive "S Symbol: ")
(let*((val (symbol-value sym))
(str (format "%s" val)) )
(set-x-clipboard str) ))
;; (progn (x-copy-symbol 'fill-column) (insert-x-clipboard))
;; (progn (call-interactively #'x-copy-symbol) (insert-x-clipboard))
(defun x-clipboard-dwim ()
"If the region is active, set the X clipboard, if not, insert it."
(interactive)
(call-interactively
(if (use-region-p)
#'set-x-clipboard
#'insert-x-clipboard) ))
(defalias 'x #'x-clipboard-dwim)
(defalias 'xo #'insert-x-clipboard)
(provide 'xsel)
;;; xsel.el ends here
--
underground experts united
https://dataswamp.org/~incal
next prev parent reply other threads:[~2022-01-23 16:39 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CAG9ihEv+vex+5=PLcn2Pvs1RLQQgGVjjD7_sGxcZOYscr2mj=g@mail.gmail.com>
2022-01-13 1:22 ` Fwd: How do I go about debugging my Elisp code? Davin Pearson
2022-01-13 1:34 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-01-13 12:58 ` Michael Heerdegen
2022-01-14 6:55 ` Marcin Borkowski
2022-01-14 8:24 ` Jean Louis
2022-01-14 23:22 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-01-14 13:46 ` Jean Louis
2022-01-14 14:56 ` Tassilo Horn
2022-01-14 15:20 ` Jean Louis
2022-01-14 16:23 ` Tassilo Horn
2022-01-14 16:53 ` Jean Louis
2022-01-14 17:24 ` Tassilo Horn
2022-01-14 17:57 ` Jean Louis
2022-01-14 18:58 ` Tassilo Horn
2022-01-15 7:34 ` Jean Louis
2022-01-14 18:56 ` Marcin Borkowski
2022-01-14 19:02 ` Jean Louis
2022-01-14 19:51 ` Tassilo Horn
2022-01-15 7:35 ` Jean Louis
2022-01-15 10:15 ` Tassilo Horn
2022-01-15 11:33 ` Jean Louis
2022-01-18 0:03 ` Davin Pearson
2022-01-14 23:28 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-01-14 23:26 ` NonGNU ELPA (was: Re: Fwd: How do I go about debugging my Elisp code?) Emanuel Berg via Users list for the GNU Emacs text editor
2022-01-15 7:39 ` Jean Louis
2022-01-17 3:47 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-01-17 18:15 ` Jean Louis
2022-01-18 0:01 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-01-18 5:02 ` Jean Louis
2022-01-18 6:06 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-01-18 3:02 ` NonGNU ELPA Stefan Monnier via Users list for the GNU Emacs text editor
2022-01-18 3:20 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-01-18 3:49 ` Stefan Monnier via Users list for the GNU Emacs text editor
2022-01-21 21:32 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-01-22 4:00 ` Stefan Monnier via Users list for the GNU Emacs text editor
2022-01-22 4:53 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-01-22 5:23 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-01-22 5:24 ` Po Lu
2022-01-22 5:38 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-01-22 6:32 ` Po Lu
2022-01-22 6:42 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-01-22 7:10 ` Po Lu
2022-01-22 12:24 ` Jean Louis
2022-01-22 12:38 ` Po Lu
2022-01-22 11:13 ` Jean Louis
2022-01-22 13:43 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-01-23 9:24 ` Jean Louis
2022-01-23 16:26 ` Stefan Monnier via Users list for the GNU Emacs text editor
2022-01-23 16:39 ` Emanuel Berg via Users list for the GNU Emacs text editor [this message]
2022-01-22 4:58 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-01-22 5:05 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-01-18 3:23 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-01-14 17:40 ` Fwd: How do I go about debugging my Elisp code? Yuri Khan
2022-01-14 17:51 ` Jean Louis
2022-01-14 23:31 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-01-14 23:24 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-01-15 2:13 ` Emanuel Berg via Users list for the GNU Emacs text editor
2022-01-15 8:24 ` Jean Louis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87v8yaz9rd.fsf@zoho.eu \
--to=help-gnu-emacs@gnu.org \
--cc=moasenwood@zoho.eu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).