From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: custom link export and ox-md Date: Tue, 25 Feb 2014 18:20:17 +0100 Message-ID: <874n3nun1q.fsf@gmail.com> References: <530AAA84.3000402@gmail.com> <87ob1xgl5e.fsf@gmail.com> <8761o4714y.fsf@alphaville.bos.redhat.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:50110) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WILfm-0004vW-60 for emacs-orgmode@gnu.org; Tue, 25 Feb 2014 12:20:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WILfg-0003k9-7V for emacs-orgmode@gnu.org; Tue, 25 Feb 2014 12:20:02 -0500 Received: from mail-wg0-x22f.google.com ([2a00:1450:400c:c00::22f]:54529) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WILfg-0003k2-0c for emacs-orgmode@gnu.org; Tue, 25 Feb 2014 12:19:56 -0500 Received: by mail-wg0-f47.google.com with SMTP id n12so670431wgh.6 for ; Tue, 25 Feb 2014 09:19:55 -0800 (PST) In-Reply-To: <8761o4714y.fsf@alphaville.bos.redhat.com> (Nick Dokos's message of "Mon, 24 Feb 2014 14:37:33 -0500") 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: Nick Dokos Cc: emacs-orgmode@gnu.org Hello, Nick Dokos writes: > can you take a look at this patch? Thank you for the patch. Here we go. > If it looks OK, I can push it to maint. Why maint? It isn't a bugfix. > commit f820173bf514549134e8ba10bbbba1e539cb89f6 > Author: Nick Dokos > Date: Mon Feb 24 14:31:33 2014 -0500 > > Add handling of user-defined custom links to org-md-link > > * ox-md.el (org-md-link): Add code to handle user-defined custom links. > Refactor raw-path calculation to simplify the code. > > Reported by John Peloquin (http://thread.gmane.org/gmane.emacs.orgmode/82627) > > diff --git a/lisp/ox-md.el b/lisp/ox-md.el > index 39843d5..fbc5d6f 100644 > --- a/lisp/ox-md.el > +++ b/lisp/ox-md.el > @@ -278,7 +278,8 @@ a communication channel." > (if (string= ".org" (downcase (file-name-extension raw-path "."))) > (concat (file-name-sans-extension raw-path) ".md") > raw-path)))) > - (type (org-element-property :type link))) > + (type (org-element-property :type link)) > + (raw-path (org-element-property :path link))) I'd rather not bind RAW-PATH here, as only half the branches in the `cond' are using it. Also, I think it is clearer to mostly do bindings close to the areas where they are needed. > - (let ((path (let ((raw-path (org-element-property :path link))) > - (if (not (file-name-absolute-p raw-path)) raw-path > - (expand-file-name raw-path)))) > + (let ((path (if (not (file-name-absolute-p raw-path)) raw-path > + (expand-file-name raw-path))) See above. > - (let ((ref (org-element-property :path link))) > + (let ((ref raw-path)) If you want to go further, you could even remove REF, but, see above. > - (t (let* ((raw-path (org-element-property :path link)) > - (path > + ;; Link type is handled by a special function. > + ((functionp (setq protocol (nth 2 (assoc type org-link-protocols)))) > + (funcall protocol raw-path contents 'md)) > + This raises an interesting question. What do we do with derived back-ends? E.g., what should happen if TYPE is handled in `org-link-protocols' for `html' but not `md'? Also the blank line is not needed. Regards, -- Nicolas Goaziou