From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: links-9.0 v3 Date: Mon, 18 Jul 2016 14:02:20 +0200 Message-ID: <87y44zf92r.fsf@saiph.selenimh> 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]:36264) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bP7Fj-0001Je-IO for emacs-orgmode@gnu.org; Mon, 18 Jul 2016 08:02:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bP7Fe-0004VH-Hq for emacs-orgmode@gnu.org; Mon, 18 Jul 2016 08:02:26 -0400 Received: from relay4-d.mail.gandi.net ([2001:4b98:c:538::196]:60436) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bP7Fe-0004VD-Bj for emacs-orgmode@gnu.org; Mon, 18 Jul 2016 08:02:22 -0400 In-Reply-To: (John Kitchin's message of "Sat, 09 Jul 2016 09:27:29 -0400") 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: John Kitchin Cc: "emacs-orgmode@gnu.org" John Kitchin 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,