From mboxrd@z Thu Jan 1 00:00:00 1970 From: Miro Bezjak Subject: Re: org-insert-link with HTML title as default description Date: Sat, 29 Sep 2012 20:43:12 +0200 Message-ID: References: <87r4pklwkb.fsf@bzg.ath.cx> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Return-path: Received: from eggs.gnu.org ([208.118.235.92]:37068) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TI214-0002zP-9g for emacs-orgmode@gnu.org; Sat, 29 Sep 2012 14:43:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TI213-0007dp-Au for emacs-orgmode@gnu.org; Sat, 29 Sep 2012 14:43:54 -0400 Received: from mail-ie0-f169.google.com ([209.85.223.169]:39530) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TI213-0007dd-5v for emacs-orgmode@gnu.org; Sat, 29 Sep 2012 14:43:53 -0400 Received: by ied10 with SMTP id 10so10829433ied.0 for ; Sat, 29 Sep 2012 11:43:52 -0700 (PDT) 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: Sylvain Rousseau Cc: Bastien , emacs-orgmode@gnu.org Hi Sylvain, Bastien, I have indeed noticed `org-make-link-description-function'. Though, from its documentation I've somehow concluded that it makes the final (and not default) description. By rereading documentation and source code for `org-insert-link', it appears that with addition of Sylvain's patch I could indeed use `org-make-link-description-function' and not wrap around `org-insert-link'. Cheers, Miro P.S. I'm sending SSH public key in a separate mail. On Sat, Sep 29, 2012 at 5:09 PM, Sylvain Rousseau wrote: > Hi Miro and Bastien, > > This can be done by setting the function > `org-make-link-description-function'. However when set, the function > is supposed to handle all type of links and return a string no matter > what. There is no fallback mechanism. Here is a patch that fixes it: > > > diff --git a/lisp/org.el b/lisp/org.el > index bdb85de..3630623 100644 > --- a/lisp/org.el > +++ b/lisp/org.el > @@ -9527,10 +9527,12 @@ Use TAB to complete link prefixes, then RET for type-spe > (setq desc path)))) > > (if org-make-link-description-function > - (setq desc (funcall org-make-link-description-function link desc)) > - (if default-description (setq desc default-description) > - (setq desc (or (and auto-desc desc) > - (read-string "Description: " desc))))) > + (setq desc (or (funcall org-make-link-description-function link desc) > + desc))) > + > + (if default-description (setq desc default-description) > + (setq desc (or (and auto-desc desc) > + (read-string "Description: " desc)))) > > (unless (string-match "\\S-" desc) (setq desc nil)) > (if remove (apply 'delete-region remove)) > > > For example my `org-make-link-description-function' is: > > (setq org-link-to-description > '(("\\`file:.*/\\([^/:]+\\)\\(::.*\\)" . "\\1") > ("\\`file:.*/\\([^/:]+\\)" . "\\1"))) > > (setq org-make-link-description-function > (lambda (link description) > (let ((found (assoc-default link org-link-to-description > 'string-match))) > (cond > ((stringp found) (match-substitute-replacement found t > nil link)))))) > > > HTH, > > Sylvain.