I might have talked about this before, but a simple emacs customization I've implemented is that I can highlight a path-like piece of text and immediately jump to either the file referenced or go to the link specified

the code for this is not that complicated

(defun self/lookup-open-link-like-object (lookup-fn &rest args)
  "Advice for LOOKUP-FN. Opens a link-like object: a file, URL, etc."
  (let ((identifier (nth 0 args))
        (url-pattern (rx line-start (seq "http" (? "s") "://")))
        (file-path-pattern (rx line-start (group (one-or-more any)) "/" (group (one-or-more (not "/"))) line-end)))
    (cond
     ((string-match-p url-pattern identifier) (browse-url identifier))
     ((and
       (string-match-p file-path-pattern identifier)
       (string-match-p ":" identifier))
      (self/open-path-with-line-and-col identifier))
     ((file-directory-p identifier) (dired identifier))
     ((file-exists-p identifier) (switch-to-buffer (find-file-noselect identifier)))
     (t (apply lookup-fn args)))))

(this code is added as an advising function to the doom emacs function +lookup/documentation, which is what the last line refers to)


You must log in to comment.