[Date Prev][Date Next][Thread Prev][][Date Index][Thread Index]

Re: Copying URLs to X-clipboard [PATCH]]

Katsumi Yamaoka <yamaoka@xxxxxxx> writes:
> I feel it is not a matter only emacs-w3m should support anyway.

I'd probably agree w3m needn't do anything special, though for interest
I actually use the very rough couple of lines below on a key when I want
to put a link onto the selection ready for pasting (out of emacs lucid).

(I found the emacs selection settings confusing overall but got it to
leave the selection alone most of the time, only transient mark by mouse
and this specific link copy. :-)

(defun my-copy-link ()
  "Copy a URL or filename at point.
Can be a w3m link or image, or a dired filename.
The copy is to the Emacs kill ring and the X primary selection."
  (let ((str (or (and (fboundp 'w3m-anchor) ;; is a macro
                 (and (fboundp 'w3m-image)
                 (and (equal major-mode 'dired-mode)
                 (error "No link or image"))))

    (cond ((eq window-system 'w32)
           (require 'simpleclip)
           (simpleclip-set-contents str))
           (let ((x-select-enable-primary t))
             (kill-new str))))
    (message "%s" str)))