瀏覽代碼

ol: Prettify suggested description for stored links

* lisp/ol.el (org-store-link): Remove statistics cookies and spurious
white spaces from description, if possible.
Nicolas Goaziou 5 年之前
父節點
當前提交
5b96988706
共有 1 個文件被更改,包括 11 次插入1 次删除
  1. 11 1
      lisp/ol.el

+ 11 - 1
lisp/ol.el

@@ -1643,7 +1643,17 @@ non-nil."
 		      (t (org-link-heading-search-string)))))
 	       (when (org-string-nw-p context)
 		 (setq cpltxt (format "%s::%s" cpltxt context))
-		 (setq desc (or name (org-get-heading t t t t) "NONE")))))
+		 (setq desc
+		       (or name
+			   ;; Although description is not a search
+			   ;; string, use `org-link--normalize-string'
+			   ;; to prettify it (contiguous white spaces)
+			   ;; and remove volatile contents (statistics
+			   ;; cookies).
+			   (and (not (org-before-first-heading-p))
+				(org-link--normalize-string
+				 (org-get-heading t t t t)))
+			   "NONE")))))
 	   (setq link cpltxt)))))
 
        ((buffer-file-name (buffer-base-buffer))