From: John Kitchin <jkitchin@andrew.cmu.edu>
To: Nicolas Goaziou <mail@nicolasgoaziou.fr>
Cc: "emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
Subject: Re: links-9.0 v3
Date: Sat, 09 Jul 2016 09:27:29 -0400 [thread overview]
Message-ID: <m27fcvosam.fsf@Johns-MacBook-Air.local> (raw)
In-Reply-To: <87y45bvm12.fsf@saiph.selenimh>
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 <jkitchin@andrew.cmu.edu> 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
next prev parent reply other threads:[~2016-07-09 13:27 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-06 14:41 links-9.0 v3 John Kitchin
2016-07-06 22:10 ` Nicolas Goaziou
2016-07-06 23:06 ` John Kitchin
2016-07-07 1:55 ` John Kitchin
2016-07-07 8:20 ` Nicolas Goaziou
2016-07-07 13:27 ` John Kitchin
2016-07-07 14:56 ` Nicolas Goaziou
2016-07-07 19:17 ` John Kitchin
2016-07-08 21:32 ` Nicolas Goaziou
2016-07-07 19:21 ` John Kitchin
2016-07-08 21:48 ` Nicolas Goaziou
2016-07-08 22:04 ` John Kitchin
2016-07-09 13:27 ` John Kitchin [this message]
2016-07-18 12:02 ` Nicolas Goaziou
2016-07-15 1:12 ` John Kitchin
2016-07-18 11:48 ` Nicolas Goaziou
2016-07-18 15:20 ` John Kitchin
2016-07-18 16:05 ` Nicolas Goaziou
2016-07-18 16:55 ` John Kitchin
2016-07-18 21:59 ` Nicolas Goaziou
2016-07-18 23:37 ` John Kitchin
2016-08-06 1:14 ` [PATCH] " Matt Lundin
2016-08-08 0:12 ` John Kitchin
2016-08-08 5:30 ` Robert Klein
2016-08-08 9:21 ` Nicolas Goaziou
2016-08-08 9:08 ` Nicolas Goaziou
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m27fcvosam.fsf@Johns-MacBook-Air.local \
--to=jkitchin@andrew.cmu.edu \
--cc=emacs-orgmode@gnu.org \
--cc=mail@nicolasgoaziou.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).