From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Kitchin Subject: Re: links-9.0 v3 Date: Sat, 09 Jul 2016 09:27:29 -0400 Message-ID: References: <87oa6afmeu.fsf@saiph.selenimh> <87k2gxg8qm.fsf@saiph.selenimh> <8737nlfqdv.fsf@saiph.selenimh> <87y45bvm12.fsf@saiph.selenimh> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:42109) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bLsIE-0001AJ-R0 for emacs-orgmode@gnu.org; Sat, 09 Jul 2016 09:27:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bLsIA-00039E-O2 for emacs-orgmode@gnu.org; Sat, 09 Jul 2016 09:27:38 -0400 Received: from mail-qk0-x22d.google.com ([2607:f8b0:400d:c09::22d]:35749) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bLsIA-00038K-Gz for emacs-orgmode@gnu.org; Sat, 09 Jul 2016 09:27:34 -0400 Received: by mail-qk0-x22d.google.com with SMTP id s63so23617911qkb.2 for ; Sat, 09 Jul 2016 06:27:34 -0700 (PDT) In-reply-to: <87y45bvm12.fsf@saiph.selenimh> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Nicolas Goaziou Cc: "emacs-orgmode@gnu.org" 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 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