I want to access any current file quickly. Therefore I want to build a function that put a file the register.
I've started with this function:
(defun tmp-register () """ put the current buffer in the temporary register """ (interactive) (set-register , ?q (file . buffer-file-name)) )
but it fails as expected as I need a string instead of
buffer-file-name. Do you see a way around this?
I have tweaked some code from Sacha Chua here. I've come up with this. I don't understand it entirely yet and it can probably be improved. Do you have something else in mind?
(defun tmp-register () """ put the current buffer in the temporary register """ (interactive) (my/defshortcut ?q buffer-file-name) ) (defvar my/refile-map (make-sparse-keymap)) (defmacro my/defshortcut (key file) `(progn (set-register ,key (cons 'file ,file)) (define-key my/refile-map (char-to-string ,key) (lambda (prefix) (interactive "p") (let ((org-refile-targets '(((,file) :maxlevel . 6))) (current-prefix-arg (or current-prefix-arg '(4)))) (call-interactively 'org-refile)))))) (global-set-key (kbd "<f12>") 'tmp-register)