Parcourir la source

org-e-ascii: Small refactoring

* contrib/lisp/org-e-ascii.el (org-e-ascii--unique-links): Small refactoring.
Nicolas Goaziou il y a 12 ans
Parent
commit
4721052ec6
1 fichiers modifiés avec 9 ajouts et 26 suppressions
  1. 9 26
      contrib/lisp/org-e-ascii.el

+ 9 - 26
contrib/lisp/org-e-ascii.el

@@ -814,10 +814,7 @@ generation.  INFO is a plist used as a communication channel."
   "Return a list of unique link references in ELEMENT.
   "Return a list of unique link references in ELEMENT.
 
 
 ELEMENT is either an headline element or a section element.  INFO
 ELEMENT is either an headline element or a section element.  INFO
-is a plist used as a communication channel.
+is a plist used as a communication channel."
-
-It covers links that may be found current headline's title, in
-the following section and in any inlinetask's title there."
   (let* (seen
   (let* (seen
 	 (unique-link-p
 	 (unique-link-p
 	  (function
 	  (function
@@ -829,28 +826,14 @@ the following section and in any inlinetask's title there."
 			  (org-element-contents link))))
 			  (org-element-contents link))))
 	       (unless (member footprint seen)
 	       (unless (member footprint seen)
 		 (push footprint seen) link)))))
 		 (push footprint seen) link)))))
-	 (harvest-links-in-title
+	 ;; If at a section, find parent headline, if any, in order to
-	  (function
+	 ;; count links that might be in the title.
-	   ;; Return a list of all unique links in ELEMENT.  ELEMENT
+	 (headline
-	   ;; may be an headline or an inlinetask element.
+	  (if (eq (org-element-type element) 'headline) element
-	   (lambda (element)
+	    (or (org-export-get-parent-headline element info) element))))
-	     (let (acc)
+    ;; Get all links in HEADLINE.
-	       (dolist (obj (org-element-property :title element) acc)
+    (org-element-map
-		 (when (eq (org-element-type obj) 'link)
+     headline 'link (lambda (link) (funcall unique-link-p link)) info)))
-		   (let ((link (funcall unique-link-p obj)))
-		     (and link (push link acc)))))))))
-	 ;; Retrieve HEADLINE's section, if it exists.
-	 (section (if (eq (org-element-type element) 'section) element
-		    (let ((sec (car (org-element-contents element))))
-		      (and (eq (org-element-type sec) 'section) sec))))
-	 (headline (if (eq (org-element-type element) 'headline) element
-		     (org-export-get-parent-headline element info))))
-    (append
-     ;; Links that may be in HEADLINE's title.
-     (funcall harvest-links-in-title headline)
-     ;; Get all links in SECTION.
-     (org-element-map
-      section 'link (lambda (link) (funcall unique-link-p link)) info))))
 
 
 (defun org-e-ascii--describe-links (links width info)
 (defun org-e-ascii--describe-links (links width info)
   "Return a string describing a list of links.
   "Return a string describing a list of links.