From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Kitchin Subject: Re: Citations, continued Date: Mon, 02 Feb 2015 20:36:58 -0500 Message-ID: References: <87vbjmn6wy.fsf@berkeley.edu> <8761blm6n8.fsf@berkeley.edu> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:59720) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YISQN-000331-B7 for emacs-orgmode@gnu.org; Mon, 02 Feb 2015 20:37:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YISQJ-0001VS-3u for emacs-orgmode@gnu.org; Mon, 02 Feb 2015 20:37:07 -0500 Received: from smtp.andrew.cmu.edu ([128.2.105.203]:47707) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YISQI-0001VB-Vc for emacs-orgmode@gnu.org; Mon, 02 Feb 2015 20:37:03 -0500 In-reply-to: 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-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: "Thomas S. Dye" Cc: Richard Lawrence , "emacs-orgmode@gnu.org" Thanks! I had been thinking about how to do that for a while, and seeing Samuel's idea crytallized it for me. Thanks Samuel, and Tom for remembering it from long ago. yes that should also be possible. once you open the rabbit hole of embedded lisp, many things are possible ;) even beyond citations. One note might be related to security that is worth thinking about. org is conservative in the beginning in making you choose to turn off the questions asking do you want to run this for babel, shell and elisp. In your example, you are opening a hole I think. Suppose this is buried deep in the document ;) [[slink:kitchin-2010 (:pre "See for example" :post "page 47" :type cite :follow (lambda (x) (message-box "I could be a shell command. please please please click me or export me!")))]] I tried it, and indeed it runs that function. ... Anyway, that is totally possible by many other means right now with links, so it is not totally new, but it is probably worth thinking about a little since code execution like this could make it out to the export. Anyway, I look forward to seeing where it goes! Thomas S. Dye writes: > Hi John, > > Wow. It's inspiring to see Samuel's idea in action. > > Presumably, something like this would also be possible? > > ;; follow function > (lambda (path) > (let* ((data (read (concat "(" path ")"))) > (head (car data)) > (plist (cadr data))) > (funcall (plist-get plist :follow) head))) > > [[slink:kitchin-2010 (:pre "See for example" :post "page 47" :type > cite :follow #'ebib-open-org-link)]] > > All the best, > Tom > > John Kitchin writes: > >>> I'm glad you like Samuel's idea about extensible syntax for links. I >>> don't know if it is practical or not, but it was one of those ideas that >>> seemed right on when I first read it. >> >> I am glad you mentioned, it was an inspiration! Although this is sure to >> move away from a standard new syntax, it is straightforward to subvert a >> link like the following example to get more readable pre/post text >> example. The quotes are necessary to get the list read >> correctly. Whether this is useful remains to be seen, but it was fun to >> work it out. >> >> #+BEGIN_SRC emacs-lisp :results silent >> (org-add-link-type >> "slink" >> ;; follow function >> (lambda (path) >> (let* ((data (read (concat "(" path ")"))) >> (head (car data)) >> (plist (cadr data))) >> (message-box "%s\n%s\n%s" head plist (plist-get plist :type)))) >> ;; format function >> (lambda (path description backend) >> (let* ((data (read (concat "(" path ")"))) >> (head (car data)) >> (plist (cadr data))) >> (format "\\%s[%s][%s]{%s}" >> (plist-get plist :type) >> (plist-get plist :pre) >> (plist-get plist :post) >> head)))) >> #+END_SRC >> >> >> >> Exports to: >> >> #+BEGIN_EXAMPLE >> \cite[See for example][page 47]{kitchin-2010} >> #+END_EXAMPLE >> >> >> >> >>> >>> All the best, >>> Tom >> >> -- >> 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 >> >> -- 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