[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] links-9.0 v3
From: |
John Kitchin |
Subject: |
Re: [O] links-9.0 v3 |
Date: |
Sat, 09 Jul 2016 09:27:29 -0400 |
User-agent: |
mu4e 0.9.16; emacs 25.1.50.1 |
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)))
("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
+ [[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) ""))))
+ (apply #'org-open-file
+ (car fields)
+ app
+ (cond ((not option) nil)
+ ((org-string-match-p "\\`[0-9]+\\'" option)
+ (list (string-to-number option)))
+ (t (list nil
+ (org-link-unescape option)))))))
+
(defun org-open-at-point (&optional arg reference-buffer)
"Open link, timestamp, footnote or tags at point.
Nicolas Goaziou writes:
> John Kitchin <address@hidden> writes:
>
>> Here are the new revisions that implement the previous solution you
>> suggested and that incorporate the commit merges as far as I can see.
>
> Thank you.
>
>> +(defcustom org-link-parameters
>> + '(("file" :complete 'org-file-complete-link)
>
> #'org-file-complete-link
>
>> + ("file+emacs" :follow (lambda (path) (org-open-file path '(4))))
>> + ("file+sys" :follow (lambda (path) (org-open-file path 'system)))
>
> This will ignore so-called "option" part, e.g.
>
> [[file:test.org::3]]
>
> :follow functions need to extract it somehow.
>
> Once this issue is resolved, I think the whole change-set can be pushed
> to master, AFAIC.
--
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu
- Re: [O] links-9.0 v3, (continued)
- Re: [O] links-9.0 v3, John Kitchin, 2016/07/06
- Re: [O] links-9.0 v3, John Kitchin, 2016/07/06
- Re: [O] links-9.0 v3, Nicolas Goaziou, 2016/07/07
- Re: [O] links-9.0 v3, John Kitchin, 2016/07/07
- Re: [O] links-9.0 v3, Nicolas Goaziou, 2016/07/07
- Re: [O] links-9.0 v3, John Kitchin, 2016/07/07
- Re: [O] links-9.0 v3, Nicolas Goaziou, 2016/07/08
- Re: [O] links-9.0 v3, John Kitchin, 2016/07/07
- Re: [O] links-9.0 v3, Nicolas Goaziou, 2016/07/08
- Re: [O] links-9.0 v3, John Kitchin, 2016/07/08
- Re: [O] links-9.0 v3,
John Kitchin <=
- Re: [O] links-9.0 v3, Nicolas Goaziou, 2016/07/18
- Re: [O] links-9.0 v3, John Kitchin, 2016/07/14
- Re: [O] links-9.0 v3, Nicolas Goaziou, 2016/07/18
- Re: [O] links-9.0 v3, John Kitchin, 2016/07/18
- Re: [O] links-9.0 v3, Nicolas Goaziou, 2016/07/18
- Re: [O] links-9.0 v3, John Kitchin, 2016/07/18
- Re: [O] links-9.0 v3, Nicolas Goaziou, 2016/07/18
- Re: [O] links-9.0 v3, John Kitchin, 2016/07/18