2022-11-08

Published: Nov 08, 2022Last modified: Apr 05, 2023
Word count: 330

another great blog

org insert link completion

Adding external links to the same 5 github repos all over my org notes grows tiresome, typing out the full-url over and over. Here's a way to add suggestions/completions to your org-insert-link flow.

(setq russ/suggested-links
      '("https://github.com/russmatney"
        "https://github.com/russmatney/org-blog"
        "https://github.com/russmatney/org-crud"
        "https://github.com/russmatney/clawe"
        "https://github.com/russmatney/dino"
        "https://russmatney.itch.io"
        "https://russmatney.itch.io/dino"
        "https://russmatney.itch.io/runner"
        "https://russmatney.itch.io/dungeon-crawler"
        "https://patreon.com/russmatney"
        "https://danger.russmatney.com"))

;; NOTE the doom context implied by this `after!` - could go in your own use-package usage
(after! org
  (org-link-set-parameters
   "https"
   :complete
   (lambda ()
     (completing-read "link: "
                      (cl-remove
                       "https:"
                       (delete-dups
                        (cl-concatenate 'list
                                        org-link--insert-history
                                        russ/suggested-links)))))))

This uses the org-link--insert-history - that much may be all you care for. I'm not sure the lifecycle of that variable though, and I don't care to enter the full protocol and url every time, so I included some suggested links to always-include via russ/suggested-links.