Make it possible to insert the current filename at point

This commit is contained in:
Gergely Polonkai 2019-02-19 14:32:47 +01:00
parent 74922ec587
commit 03f3c4ec78
1 changed files with 23 additions and 1 deletions

View File

@ -403,6 +403,27 @@ DELIMITED, START, and END are passed down verbatim to `perform-replace'."
t t delimited nil nil start end))
#+END_SRC
*** Insert the current files name at point
:PROPERTIES:
:SOURCE: http://mbork.pl/2019-02-17_Inserting_the_current_file_name_at_point
:END:
#+BEGIN_SRC emacs-lisp
(defun insert-current-file-name-at-point (&optional full-path)
"Insert the current filename at point.
With prefix argument, use full path."
(interactive "P")
(let* ((buffer
(if (minibufferp)
(window-buffer
(minibuffer-selected-window))
(current-buffer)))
(filename (buffer-file-name buffer)))
(if filename
(insert (if full-path filename (file-name-nondirectory filename)))
(error (format "Buffer %s is not visiting a file" (buffer-name buffer))))))
#+END_SRC
** Navigation
*** Move to different beginnings of the current line
@ -3359,7 +3380,8 @@ With the new Transient package it will be easier. I just dont know how to us
("c i" . org-clock-in)
("c I" . org-clock-in-last)
("c o" . org-clock-out)
("c g" . org-clock-goto))
("c g" . org-clock-goto)
("M-o" . insert-current-file-name-at-point))
#+END_SRC
** TODO These fail to work using ~bind-keys~, but why?