瀏覽代碼

Allow '%h' in link abbreviations to insert a url-encoded target value

Patch by Steve Purcell.
Carsten Dominik 16 年之前
父節點
當前提交
597a1be6e2
共有 2 個文件被更改,包括 8 次插入1 次删除
  1. 3 0
      lisp/ChangeLog
  2. 5 1
      lisp/org.el

+ 3 - 0
lisp/ChangeLog

@@ -1,5 +1,8 @@
 2008-11-13  Carsten Dominik  <carsten.dominik@gmail.com>
 
+	* org.el (org-link-expand-abbrev): Implement %h as an escape for a
+	hexified version of the tag.
+
 	* org-vm.el (org-vm-follow-link): Require `vm-search'.
 
 	* org.el (org-up-heading-safe, org-forward-same-level): Always

+ 5 - 1
lisp/org.el

@@ -843,7 +843,9 @@ links in Org-mode buffers can have an optional tag after a double colon, e.g.
      [[linkkey:tag][description]]
 
 If REPLACE is a string, the tag will simply be appended to create the link.
-If the string contains \"%s\", the tag will be inserted there.
+If the string contains \"%s\", the tag will be inserted there.  Alternatively,
+the placeholder \"%h\" will cause a url-encoded version of the tag to
+be inserted at that point (see the function `url-hexify-string').
 
 REPLACE may also be a function that will be called with the tag as the
 only argument to create the link, which should be returned as a string.
@@ -5976,6 +5978,8 @@ Possible values in the list of contexts are `table', `headline', and `item'."
 	  (cond
 	   ((symbolp rpl) (funcall rpl tag))
 	   ((string-match "%s" rpl) (replace-match (or tag "") t t rpl))
+	   ((string-match "%h" rpl)
+	    (replace-match (url-hexify-string (or tag "")) t t rpl))
 	   (t (concat rpl tag)))))
     link))