John Kitchin <jkitc...@andrew.cmu.edu> writes: > What do you think of this approach: > > (defcustom org-link-parameters > - '(("file" :complete 'org-file-complete-link) > - ("file+emacs" :follow (lambda (path) (org-open-file path '(4)))) > - ("file+sys" :follow (lambda (path) (org-open-file path 'system))) > + '(("file" :complete #'org-file-complete-link) > + ("file+emacs" :follow (lambda (path) (org-open-file-link path '(4)))) > + ("file+sys" :follow (lambda (path) (org-open-file-link path 'system)))
It could work, but I suggest to rename it `org--open-file-link' or some such, i.e., make it an internal function, because it could be confusing with `org-open-link-from-string'. > ("http") ("https") ("ftp") ("mailto") > ("news") ("shell") ("elisp") > ("doi") ("message") ("help")) > @@ -10732,6 +10732,30 @@ they must return nil.") > > (defvar org-link-search-inhibit-query nil) ;; dynamically scoped > (defvar clean-buffer-list-kill-buffer-names) ; Defined in midnight.el > + > +(defun org-open-file-link (path app) > + "Open PATH using APP. > + > +PATH is from a file link, and can have the following missing "syntax"? > + [[file:~/code/main.c::255]] > + [[file:~/xx.org::My Target]] > + [[file:~/xx.org::*My Target]] > + [[file:~/xx.org::#my-custom-id]] > + [[file:~/xx.org::/regexp/]] > + > +APP is '(4) to open the PATH in Emacs, or 'system to use a system > application." > + (let* ((fields (split-string path "::")) > + (option (when (cdr fields) > + (mapconcat 'identity (cdr fields) "")))) (and (cdr field) (mapconcat #'identity (cdr fields) "")) > + (apply #'org-open-file > + (car fields) > + app > + (cond ((not option) nil) > + ((org-string-match-p "\\`[0-9]+\\'" option) org-string-match-p -> string-match-p Regards,