summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <n.goaziou@gmail.com>2012-02-25 13:02:01 +0100
committerNicolas Goaziou <n.goaziou@gmail.com>2012-02-25 14:53:35 +0100
commit9f7965a80ea46f509f7b00787d9f7287871e291f (patch)
treebdea7a5ff96fd49b97f159a434eb29ceb677869b
parent3b3936b9a98f42c737eea03c8bff0c1c2487024b (diff)
downloadorg-mode-9f7965a80ea46f509f7b00787d9f7287871e291f.tar.gz
org-element: Function mapped through org-element-map accepts only one argument
* contrib/lisp/org-element.el (org-element-map): Remove use of an alternate communication channel. Function is now called with only one argument. * contrib/lisp/org-export.el (org-export-collect-tree-properties): (org-export-collect-headline-numbering, org-export--selected-trees, org-export-collect-footnote-definitions, org-export-footnote-first-reference-p, org-export-get-footnote-number, org-export-resolve-fuzzy-link, org-export-resolve-id-link, org-export-resolve-ref-link, org-export-resolve-coderef, org-export-get-ordinal, org-export-get-loc, org-export-collect-headlines): Apply changes. * EXPERIMENTAL/org-e-ascii.el (org-e-ascii--unique-links): Apply changes. * EXPERIMENTAL/org-e-publish.el (org-e-publish-collect-index): Apply changes.
-rw-r--r--EXPERIMENTAL/org-e-ascii.el2
-rw-r--r--EXPERIMENTAL/org-e-publish.el4
-rw-r--r--contrib/lisp/org-element.el20
-rw-r--r--contrib/lisp/org-export.el40
4 files changed, 31 insertions, 35 deletions
diff --git a/EXPERIMENTAL/org-e-ascii.el b/EXPERIMENTAL/org-e-ascii.el
index fbf8bd8..0eb547b 100644
--- a/EXPERIMENTAL/org-e-ascii.el
+++ b/EXPERIMENTAL/org-e-ascii.el
@@ -809,7 +809,7 @@ the following section and in any inlinetask's title there."
(funcall harvest-links-in-title headline)
;; Get all links in SECTION.
(org-element-map
- section 'link (lambda (link local) (funcall unique-link-p link)) info))))
+ section 'link (lambda (link) (funcall unique-link-p link)) info))))
(defun org-e-ascii--describe-links (links width info)
"Return a string describing a list of links.
diff --git a/EXPERIMENTAL/org-e-publish.el b/EXPERIMENTAL/org-e-publish.el
index f73836f..92e58f9 100644
--- a/EXPERIMENTAL/org-e-publish.el
+++ b/EXPERIMENTAL/org-e-publish.el
@@ -975,11 +975,11 @@ keyword."
(delete-dups
(org-element-map
tree 'keyword
- (lambda (k local)
+ (lambda (k)
(when (string= (downcase (org-element-property :key k))
"index")
(let ((index (org-element-property :value k))
- (parent (org-export-get-parent-headline k local)))
+ (parent (org-export-get-parent-headline k info)))
(list index (plist-get info :input-file) parent))))
info)))
;; Return parse-tree to avoid altering output.
diff --git a/contrib/lisp/org-element.el b/contrib/lisp/org-element.el
index 9985c46..ac389f3 100644
--- a/contrib/lisp/org-element.el
+++ b/contrib/lisp/org-element.el
@@ -2897,9 +2897,7 @@ cdr a plist of keywords and values."
;; The (almost) almighty `org-element-map' allows to apply a function
;; on elements or objects matching some type, and accumulate the
;; resulting values. In an export situation, it also skips unneeded
-;; parts of the parse tree, transparently walks into included files,
-;; and maintain a list of local properties (i.e. those inherited from
-;; parent headlines) for function's consumption.
+;; parts of the parse tree.
(defun org-element-parse-buffer (&optional granularity visible-only)
"Recursively parse the buffer and return structure.
@@ -2950,9 +2948,8 @@ the current buffer."
DATA is the parsed tree, as returned by, i.e,
`org-element-parse-buffer'. TYPES is a symbol or list of symbols
of elements or objects types. FUN is the function called on the
-matching element or object. It must accept two arguments: the
-element or object itself and a plist holding contextual
-information.
+matching element or object. It must accept one arguments: the
+element or object itself.
When optional argument INFO is non-nil, it should be a plist
holding export options. In that case, parts of the parse tree
@@ -3004,16 +3001,15 @@ Nil values returned from FUN are ignored in the result."
nil
,@(org-element-property
(cdr (assq --type org-element-secondary-value-alist))
- --blob))
- info))
+ --blob))))
(when (memq --type types)
- (let ((result (funcall fun --blob info)))
+ (let ((result (funcall fun --blob)))
(cond ((not result))
(first-match (throw 'first-match result))
(t (push result --acc))))))))
(--walk-tree
(function
- (lambda (--data info)
+ (lambda (--data)
;; Recursively walk DATA. INFO, if non-nil, is
;; a plist holding contextual information.
(mapc
@@ -3042,10 +3038,10 @@ Nil values returned from FUN are ignored in the result."
;; Recursion is possible and allowed: Maybe apply
;; FUN to --BLOB, then move into it.
(t (funcall --check-blob --type types fun --blob info)
- (funcall --walk-tree --blob info)))))
+ (funcall --walk-tree --blob)))))
(org-element-contents --data))))))
(catch 'first-match
- (funcall --walk-tree data info)
+ (funcall --walk-tree data)
;; Return value in a proper order.
(reverse --acc))))
diff --git a/contrib/lisp/org-export.el b/contrib/lisp/org-export.el
index 3439aec..57a94f6 100644
--- a/contrib/lisp/org-export.el
+++ b/contrib/lisp/org-export.el
@@ -1286,7 +1286,7 @@ Following tree properties are set:
`(:parse-tree
,data
:target-list
- ,(org-element-map data 'target (lambda (target local) target) info)
+ ,(org-element-map data 'target 'identity info)
:headline-numbering ,(org-export-collect-headline-numbering data info)
:back-end ,backend)
info))
@@ -1321,9 +1321,9 @@ associated numbering \(in the shape of a list of numbers\)."
(org-element-map
data
'headline
- (lambda (headline info)
+ (lambda (headline)
(let ((relative-level
- (1- (org-export-get-relative-level headline info))))
+ (1- (org-export-get-relative-level headline options))))
(cons
headline
(loop for n across numbering
@@ -1391,7 +1391,7 @@ INFO is a plist holding export options."
(setq selected-trees
(append
(cons data genealogy)
- (org-element-map data 'headline (lambda (h p) h))
+ (org-element-map data 'headline 'identity)
selected-trees))
;; Else, continue searching in tree, recursively.
(funcall walk-data data (cons data genealogy))))))))))
@@ -2458,11 +2458,11 @@ ignored."
;; Collect seen references in REFS.
(org-element-map
data 'footnote-reference
- (lambda (footnote local)
- (when (org-export-footnote-first-reference-p footnote local)
- (list (org-export-get-footnote-number footnote local)
+ (lambda (footnote)
+ (when (org-export-footnote-first-reference-p footnote info)
+ (list (org-export-get-footnote-number footnote info)
(org-element-property :label footnote)
- (org-export-get-footnote-definition footnote local))))
+ (org-export-get-footnote-definition footnote info))))
info)))
(defun org-export-footnote-first-reference-p (footnote-reference info)
@@ -2476,7 +2476,7 @@ INFO is the plist used as a communication channel."
footnote-reference
(org-element-map
(plist-get info :parse-tree) 'footnote-reference
- (lambda (footnote local)
+ (lambda (footnote)
(when (string= (org-element-property :label footnote) label)
footnote))
info 'first-match)))))
@@ -2496,7 +2496,7 @@ INFO is the plist used as a communication channel."
(let ((label (org-element-property :label footnote)) seen-refs)
(org-element-map
(plist-get info :parse-tree) 'footnote-reference
- (lambda (fn local)
+ (lambda (fn)
(let ((fn-lbl (org-element-property :label fn)))
(cond
((and (not fn-lbl) (equal fn footnote)) (1+ (length seen-refs)))
@@ -2674,7 +2674,7 @@ Assume LINK type is \"fuzzy\"."
(lambda (name data)
(org-element-map
data 'headline
- (lambda (headline local)
+ (lambda (headline)
(when (string=
(org-element-property :raw-value headline)
name)
@@ -2702,7 +2702,7 @@ is either \"id\" or \"custom-id\"."
(let ((id (org-element-property :path link)))
(org-element-map
(plist-get info :parse-tree) 'headline
- (lambda (headline local)
+ (lambda (headline)
(when (or (string= (org-element-property :id headline) id)
(string= (org-element-property :custom-id headline) id))
headline))
@@ -2718,7 +2718,7 @@ element whose `:name' property matches LINK's `:path', or nil."
(let ((name (org-element-property :path link)))
(org-element-map
(plist-get info :parse-tree) org-element-all-elements
- (lambda (el local)
+ (lambda (el)
(when (string= (org-element-property :name el) name) el))
info 'first-match)))
@@ -2731,7 +2731,7 @@ Return associated line number in source code, or REF itself,
depending on src-block or example element's switches."
(org-element-map
(plist-get info :parse-tree) '(src-block example)
- (lambda (el local)
+ (lambda (el)
(let ((switches (or (org-element-property :switches el) "")))
(with-temp-buffer
(insert (org-trim (org-element-property :value el)))
@@ -2752,7 +2752,7 @@ depending on src-block or example element's switches."
((not (string-match "-[kr]\\>" switches)) ref)
((string-match "-n\\>" switches) (line-number-at-pos))
((string-match "\\+n\\>" switches)
- (+ (org-export-get-loc el local) (line-number-at-pos)))
+ (+ (org-export-get-loc el info) (line-number-at-pos)))
(t ref)))))))
info 'first-match))
@@ -2827,7 +2827,7 @@ like inline images, which are a subset of links \(in that case,
;; Increment counter until ELEMENT is found again.
(org-element-map
data (or types (org-element-type element))
- (lambda (el local)
+ (lambda (el)
(cond
((equal element el) (1+ counter))
((not predicate) (incf counter) nil)
@@ -2854,7 +2854,7 @@ ELEMENT is excluded from count."
(org-element-map
(plist-get info :parse-tree)
`(src-block example-block ,(org-element-type element))
- (lambda (el local)
+ (lambda (el)
(cond
;; ELEMENT is reached: Quit the loop.
((equal el element) t)
@@ -3095,9 +3095,9 @@ Return a list of all exportable headlines as parsed elements."
(org-element-map
(plist-get info :parse-tree)
'headline
- (lambda (headline local)
+ (lambda (headline)
;; Strip contents from HEADLINE.
- (let ((relative-level (org-export-get-relative-level headline local)))
+ (let ((relative-level (org-export-get-relative-level headline info)))
(unless (and n (> relative-level n)) headline)))
info))
@@ -3117,7 +3117,7 @@ value when that element should be collected.
Return a list of all elements found, in order of appearance."
(org-element-map
(plist-get info :parse-tree) type
- (lambda (element local)
+ (lambda (element)
(and (or (org-element-property :caption element)
(org-element-property :name element))
(or (not predicate) (funcall predicate element))