[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Copying URLs to X-clipboard [PATCH]
- From: Boruch Baum <boruch_baum@xxxxxxx>
- Date: Sun, 19 Nov 2017 18:50:16 -0500
- X-ml-name: emacs-w3m
- X-mail-count: 12813
I don't know whether this is or has been a problem using the X-enabled
version of emacs, but I can say that when using emacs-nox in a GUI
environment it is desirable for me to be able to copy urls to the
X-clipboard, and emacs-w3m hasn't been doing it.
Attach: /home/optimum/w3m.patch Copy urls to X-clipboard
The attached patch isn't a perfect universal solution for all platforms,
but it should work for pretty much all linux distributions. To do its
magic, the patch uses a linux command line program 'xsel', which is
commonly installed.
In the past, it had been possible to use the emacs package 'simpleclip'
for this, but that package "broke" with emacs version 25, and the author
has been unresponsive for close to a year.
For your consideration.
--
hkp://keys.gnupg.net
CA45 09B5 5351 7C11 A9D1 7286 0036 9E45 1595 8BC0
Index: w3m.el
===================================================================
RCS file: /storage/cvsroot/emacs-w3m/w3m.el,v
retrieving revision 1.1692
diff -u -r1.1692 w3m.el
--- w3m.el 20 Oct 2017 00:34:47 -0000 1.1692
+++ w3m.el 19 Nov 2017 23:44:02 -0000
@@ -7484,17 +7484,23 @@
(w3m-message "No image at point")))))
(defun w3m-print-current-url ()
- "Display the current url in the echo area and put it into `kill-ring'."
+ "Display the current url in the echo area, and put it into `kill-ring'.
+
+If the external program 'xsel' is installed on the host machine, that program is used to also copy the URL to the X-clipboard."
(interactive)
(when w3m-current-url
(let ((deactivate-mark nil))
(kill-new (w3m-url-encode-string-2 w3m-current-url))
+ (call-process-shell-command
+ (concat "xsel -i -b <<<'" (w3m-url-encode-string-2 w3m-current-url) "'" ) nil 0)
(w3m-message "%s" (w3m-url-readable-string w3m-current-url)))))
(defvar message-truncate-lines)
(defun w3m-print-this-url (&optional interactive-p)
- "Display the url under point in the echo area and put it into `kill-ring'."
+ "Display the url under point in the echo area, and put it into `kill-ring'.
+
+If the external program 'xsel' is installed on the host machine, that program is used to also copy the URL to the X-clipboard."
(interactive (list t))
(let ((deactivate-mark nil)
(url (if interactive-p
@@ -7516,7 +7522,10 @@
(w3m-anchor-title)
(w3m-anchor-title (point)))))
(when (or url interactive-p)
- (and url interactive-p (kill-new (w3m-url-encode-string-2 url)))
+ (and url interactive-p
+ (kill-new (w3m-url-encode-string-2 url))
+ (call-process-shell-command
+ (concat "xsel -i -b <<<'" (w3m-url-encode-string-2 url) "'" ) nil 0))
(setq url (or (w3m-url-readable-string url)
(and (w3m-action) "There is a form")
"There is no url under point"))
@@ -7539,7 +7548,9 @@
url))))))
(defun w3m-print-this-image-url (&optional interactive-p)
- "Display image url under point in echo area and put it into `kill-ring'."
+ "Display image url under point in echo area, and put it into `kill-ring'.
+
+If the external program 'xsel' is installed on the host machine, that program is used to also copy the URL to the X-clipboard."
(interactive (list t))
(let ((deactivate-mark nil)
(url (if interactive-p
@@ -7549,7 +7560,10 @@
(w3m-image-alt)
(w3m-image-alt (point)))))
(when (or url interactive-p)
- (and url interactive-p (kill-new (w3m-url-encode-string-2 url)))
+ (and url interactive-p
+ (kill-new (w3m-url-encode-string-2 url))
+ (call-process-shell-command
+ (concat "xsel -i -b <<<'" (w3m-url-encode-string-2 url) "'" ) nil 0))
(w3m-message "%s%s"
(if (zerop (length alt))
""
Index: ChangeLog
===================================================================
RCS file: /storage/cvsroot/emacs-w3m/ChangeLog,v
retrieving revision 1.3628
diff -u -r1.3628 ChangeLog
--- ChangeLog 13 Oct 2017 08:27:49 -0000 1.3628
+++ ChangeLog 19 Nov 2017 23:44:02 -0000
@@ -1,3 +1,9 @@
+2017-11-19 Boruch Baum <boruch_baum@xxxxxxx>
+
+ * w3m.el (w3m-print-current-url, w3m-print-this-url)
+ (w3m-print-this-image-url): Add functionality to copy data to
+ X-clipboard, using linux shell command 'xsel'.
+
2017-10-13 Katsumi Yamaoka <yamaoka@xxxxxxx>
* w3m.el (w3m-copy-buffer): Make the copied buffer the next of the