From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Kitchin Subject: Re: Help on org-export-filter-link-functions Date: Sat, 04 Oct 2014 12:40:41 -0400 Message-ID: References: <87lhox2yf0.fsf@tanger.home> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:46751) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XaSO4-00080Q-Lx for emacs-orgmode@gnu.org; Sat, 04 Oct 2014 12:40:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XaSNw-0005ly-50 for emacs-orgmode@gnu.org; Sat, 04 Oct 2014 12:40:52 -0400 Received: from smtp.andrew.cmu.edu ([128.2.157.38]:41197) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XaSNw-0005lX-09 for emacs-orgmode@gnu.org; Sat, 04 Oct 2014 12:40:44 -0400 In-Reply-To: <87lhox2yf0.fsf@tanger.home> (daimrod@gmail.com's message of "Fri, 03 Oct 2014 13:19:31 +0200") 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: Daimrod Cc: emacs-orgmode@gnu.org Daimrod writes: Why don't you just define how the link should be exported in your link definition? for example: https://github.com/jkitchin/jmax/blob/master/org/org-ref.org#the-links You can see a link that is defined, with different export formats for different backends. I am intrigued by your function! It does not seem to work for all types of links though, for example I tried on on some file links, e.g. file:bib.bib, and [[file.bib]], but these fall in the (t data) case. [[file:bib.bib][bibliography]] on the other hand gets handled and you can access the element properties. I tried a similar approach on a table, but it did not work as I expected. Apparently the next property change puts you in a table-cell, rather than the parent table. I too am wondering if there is a defined way to get to the element properties within a filter function. For example, in this post http://kitchingroup.cheme.cmu.edu/blog/2014/09/22/Showing-what-data-went-into-a-code-block-on-export/ I concocted a preprocess scheme to get a list of table names, and then a filter function to put the names in the export on each table. It would be much more elegant to get it directly from the table element somehow. > Hi, > > I've wrote a simple filter to customize how links are exported in > latex: > > #+BEGIN_SRC > (defun dmd--latex-bib-link-filter (data backend info) > "Convert a bib link to a citation (e.g. bib:foo93 -> \cite{foo93})." > (let* ((beg (next-property-change 0 data)) > (link (if beg (get-text-property beg :parent data)))) > (cond ((and link > (org-export-derived-backend-p backend 'latex) > (string= (org-element-property :type link) "bib")) > (format "\\cite{%s}" (org-element-property :path link))) > ((and link > (org-export-derived-backend-p backend 'latex) > (string= (org-element-property :type link) "file") > (string= (org-element-property :path link) "~/.bib.bib")) > (format "\\cite{%s}" (org-element-property :search-option link))) > (t data)))) > #+END_SRC > > And I was wondering whether there is an easier way to retrieve the org > properties stored in the text properties of DATA. > > Best, -- ----------------------------------- John Kitchin Professor Doherty Hall A207F Department of Chemical Engineering Carnegie Mellon University Pittsburgh, PA 15213 412-268-7803 http://kitchingroup.cheme.cmu.edu