[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] org-insert-link with HTML title as default description
From: |
Sylvain Rousseau |
Subject: |
Re: [O] org-insert-link with HTML title as default description |
Date: |
Sat, 29 Sep 2012 17:09:15 +0200 |
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.