help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: [emacs-lisp newbie] print-something() -> clipboard?


From: Andreas Röhler
Subject: Re: [emacs-lisp newbie] print-something() -> clipboard?
Date: Sat, 19 May 2012 09:19:36 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:12.0) Gecko/20120421 Thunderbird/12.0

Am 18.05.2012 21:46, schrieb Tom Roche:

From my init.el I load a file that contains function definitions which
all have the form

(defun print-path-and-filename ()
   "Print the current buffer's file's path at point."
   (interactive "*") ; abort if buffer is read-only
   (if buffer-file-name (insert buffer-file-name) nil))
(global-set-key "\C-pp" 'print-path-and-filename)
...
(defun print-buffer-name ()
   "Print (at point) the current buffer's name."
   (interactive "*") ; abort if buffer is read-only
   (insert (buffer-name (window-buffer (minibuffer-selected-window)))))
(global-set-key "\C-pb" 'print-buffer-name)

(provide 'tlr-print)

Most of the functions are buffer-independent (printing, e.g., current
time, emacs version) but some (like the above) are not. For the
latter, I'd like to have the option to "print" the datum to the
clipboard. How can I (easily :-) do that?

Examples esp appreciated. Feel free to point to doc.

TIA, Tom Roche<Tom_Roche@pobox.com>



Hi,

the answer might not be a one-liner, as the X-clipboard does not come with 
Emacs.

This example works at my machine:

(defun yank-date-clipboard ()
  "Insert into the kill-ring, at X also into the clipboard."
  (interactive)
  (kill-new (format-time-string "%Y%m%d")))

HTH,

Andreas




reply via email to

[Prev in Thread] Current Thread [Next in Thread]