clipboard-kill-region to copy contents from Emacs to other programs. But sometimes, it copies the same content twice into the clipboard.
It looks like,
when I copy the filename
Is there a way I can empty the clipboard contents before calling
My complete function is shown here; it is a utility function to copy the absolute path of currently opened file in Emacs buffer:
(defun sk-copy-file-name () "Put the current file name on the clipboard" (interactive) (let ((filename (if (equal major-mode 'dired-mode) default-directory (buffer-file-name)))) (when filename (with-temp-buffer (insert filename) (clipboard-kill-region (point-min) (point-max))) (message filename))))