(defun jk-clipboard-to-buffer (name) "Paste the X clipboard to new buffer NAME from chosen target (format). \\Use \\[minibuffer-complete] at the \"target (format): \" prompt to complete a partially typed target." (interactive "Bput clipboard in buffer named: ") (let ((target (intern-soft (completing-read "target (format): " (mapcar (lambda (target) (list (symbol-name target))) (x-get-selection 'CLIPBOARD 'TARGETS)))))) (let ((cbuf (generate-new-buffer name))) (set-buffer cbuf) (insert (x-get-selection 'CLIPBOARD target)) (switch-to-buffer cbuf)))) (defun jk-clipboard-all-targets () "Ask for all clipboard targets and return as list." (let ((targets (x-get-selection 'CLIPBOARD 'TARGETS))) (mapcar (lambda (target) (list target (condition-case err (x-get-selection 'CLIPBOARD target) (error 'failed)))) targets)))