How to choose the link description everytime?
Ypot opened this issue · 5 comments
For some links I prefer to not use description, because my :ID:
is self explanatory.
I know org-super-links allows to customize the function that creates the description, but I am too inexpert to configure it. Could you teach how to configure org-super-links to wait for the description, instead of using just the heading?
With backlinks description I am ok ;-)
Maybe something like this would work?
(setq sl-default-description-formatter 'prompt-for-desc)
(defun prompt-for-desc (link desc)
(read-string "Link description: " desc))
I haven't tested that though, but something close anyway.
Almost, but better:
The link, with empty description, has this form:
[[id:20200808T004410.971170][]]
With "self-explanatory" ID (no description needed) the form should be this one:
[[id:20200808T004410.971170]]
again I haven't tested but try this maybe
(defun prompt-for-desc (link desc)
(let ((new-desc (read-string "Description: " desc)))
(if (string= new-desc "")
nil
new-desc)))
again I haven't tested but try this maybe
(defun prompt-for-desc (link desc) (let ((new-desc (read-string "Description: " desc))) (if (string= new-desc "") nil new-desc)))
Not yet:
- [[id:20200810T085402.649519][nil]]
But don't let me hold you back from your development progress, probably it is more valuable you to keep building.
Thanks
Not sure why, but it's working now.
This is my full setting, just for the record:
;; QUELPA+SUPERLINKS
(use-package quelpa
:ensure t
:config
(setq quelpa-upgrade-interval 7);; upgrade all packages once a week according to https://github.com/quelpa/quelpa
(add-hook #'after-init-hook #'quelpa-upgrade-all-maybe)
)
(use-package quelpa-use-package
:ensure t
)
(use-package org-super-links
:quelpa (org-super-links :repo "toshism/org-super-links" :fetcher github :commit "develop")
:bind (("C-c s l" . sl-store-link)
("C-c s C-l" . sl-insert-link)
)
)
(setq sl-default-description-formatter 'prompt-for-desc)
(defun prompt-for-desc (link desc)
(let ((new-desc (read-string "Description: " desc)))
(if (string= new-desc "")
nil
new-desc)))
;; (setq sl-search-function 'helm-org-rifle)
(setq sl-backlink-prefix "- ")
(setq sl-link-prefix "- ")