Q: How can I get a custom
org link function to insert a description automatically?
I'd like to store
org links to files in a
dired buffer, but would prefer that the link description be the file name sans path rather than report the full path, ie:
file:~/the/full/path/myfile.ext ; default, but no thanks myfile.ext ; what I want
org-store-link hardcodes links from
dired to provide the default. Instead, I've written a custom function (cribbing from the hard-coded function) and added it to
(defun dired-store-link () (when (derived-mode-p 'dired-mode) (let ((file (dired-get-filename nil t))) (setf file (if file (abbreviate-file-name (expand-file-name file)) default-directory)) (org-store-link-props :type "dired" :link file :description (file-name-nondirectory file)) file))) (add-to-list 'org-store-link-functions #'dired-store-link)
So far so good, and it works as expected, but for one thing:
- When calling
org-insert-linkwith the built-in, default behavior, it simply inserts the link without asking me for a description.
- When calling
org-insert-linkwith my custom function, it prompts me to enter a description (which it correctly populates with the file name stored in the
I'd rather not be prompted for the description each time, and want
org-insert-link to use the value of
:description that the custom function sets.
How can I convince
org-insert-link to use the
:description automatically without prompting me for it?