moved org-babel-merge-results into anonymous function in flet

This commit is contained in:
Eric Schulte 2009-07-18 14:15:43 -06:00
parent 09675f518e
commit 44ff72261c
1 changed files with 34 additions and 38 deletions

View File

@ -477,48 +477,44 @@ elements of PLISTS override the values of previous element. This
takes into account some special considerations for certain takes into account some special considerations for certain
parameters when merging lists." parameters when merging lists."
(let (params results vars var ref) (let (params results vars var ref)
(mapc (lambda (plist) (flet ((e-merge (exclusive-groups &rest result-params)
(mapc (lambda (pair) (let (output)
(case (car pair) (mapc (lambda (new-params)
(:var (mapc (lambda (new-param)
;; we want only one specification per variable (mapc (lambda (exclusive-group)
(when (string-match "^\\([^= \f\t\n\r\v]+\\)[ \t]*=[ \t]*\\([^\f\n\r\v]+\\)$" (cdr pair)) (when (member new-param exclusive-group)
;; TODO: When is this not true? (mapcar (lambda (excluded-param)
(setq var (intern (match-string 1 (cdr pair))) (setq output (delete excluded-param output)))
ref (match-string 2 (cdr pair)) exclusive-group)))
vars (cons (cons var ref) (assq-delete-all var vars))))) exclusive-groups)
(:results (setq output (org-uniquify (cons new-param output))))
;; maintain list of unique :results specifications new-params))
(setq results (org-babel-merge-results results (split-string (cdr pair))))) result-params)
(t output)))
;; replace: this covers e.g. :session (mapc (lambda (plist)
(setq params (cons pair (assq-delete-all (car pair) params)))))) (mapc (lambda (pair)
plist)) (case (car pair)
plists) (:var
;; we want only one specification per variable
(when (string-match "^\\([^= \f\t\n\r\v]+\\)[ \t]*=[ \t]*\\([^\f\n\r\v]+\\)$" (cdr pair))
;; TODO: When is this not true?
(setq var (intern (match-string 1 (cdr pair)))
ref (match-string 2 (cdr pair))
vars (cons (cons var ref) (assq-delete-all var vars)))))
(:results
;; maintain list of unique :results specifications
(setq results (e-merge '(("file" "vector" "scalar")
("replace" "silent"))
results (split-string (cdr pair)))))
(t
;; replace: this covers e.g. :session
(setq params (cons pair (assq-delete-all (car pair) params))))))
plist))
plists))
(setq vars (mapcar (lambda (pair) (format "%s=%s" (car pair) (cdr pair))) vars)) (setq vars (mapcar (lambda (pair) (format "%s=%s" (car pair) (cdr pair))) vars))
(while vars (setq params (cons (cons :var (pop vars)) params))) (while vars (setq params (cons (cons :var (pop vars)) params)))
(cons (cons :results (mapconcat 'identity results " ")) params))) (cons (cons :results (mapconcat 'identity results " ")) params)))
(defun org-babel-merge-results (&rest result-params)
"Combine all result parameter lists in RESULT-PARAMS taking
into account the fact that some groups of result params are
mutually exclusive."
(let ((exclusive-groups '(("file" "vector" "scalar")
("replace" "silent")))
output)
(mapc (lambda (new-params)
(mapc (lambda (new-param)
(mapc (lambda (exclusive-group)
(when (member new-param exclusive-group)
(mapcar (lambda (excluded-param)
(setq output (delete excluded-param output)))
exclusive-group)))
exclusive-groups)
(setq output (org-uniquify (cons new-param output))))
new-params))
result-params)
output))
(defun org-babel-clean-text-properties (text) (defun org-babel-clean-text-properties (text)
"Strip all properties from text return." "Strip all properties from text return."
(set-text-properties 0 (length text) nil text) text) (set-text-properties 0 (length text) nil text) text)