I have a header-line that displays currently opened file name on top of the buffer window. I can't find a way to copy the text/file name from that header-line if emacs runs under X/gui (selecting with a mouse and coping it works fine under terminal). Does anyone have any suggestions? (Perhaps there is a way to trigger an event by clicking on header-line so that could store file name so I could paste it into the terminal via mouse click as I usually do in -nw?)
Asked
Active
Viewed 79 times
1
-
It may also be possible to define a key for mouse-3 press on [header-line mouse-3] event https://emacs.stackexchange.com/questions/47211/local-map-in-header-line – pawciobiel Jul 07 '22 at 21:38
-
https://emacs.stackexchange.com/tags/elisp/info – Drew Jul 11 '22 at 14:24
1 Answers
1
To get this
and this
do this
(add-hook
'find-file-hook
(defun my-find-file-hook ()
(add-to-list
'header-line-format
'(:eval
(let ((text (buffer-file-name)))
(when text
(buttonize
text
(lambda (text)
(message "Copied `%s' to kill ring" text)
(kill-new text))
text
"Click me, to copy me")))))))
-
Thanks, It worked - although I've used it (`buttonize`) in `buffer-list-update-hook`. – pawciobiel Jul 07 '22 at 21:12