Browse Source

Use `org-eval-in-environment

* org-agenda.el (org-batch-agenda, org-batch-agenda-csv): Use
`org-eval-in-environment.
David Maus 13 years ago
parent
commit
f0958680db
1 changed files with 24 additions and 31 deletions
  1. 24 31
      lisp/org-agenda.el

+ 24 - 31
lisp/org-agenda.el

@@ -2576,15 +2576,12 @@ If CMD-KEY is a string of length 1, it is used as a key in
 longer string it is used as a tags/todo match string.
 longer string it is used as a tags/todo match string.
 Parameters are alternating variable names and values that will be bound
 Parameters are alternating variable names and values that will be bound
 before running the agenda command."
 before running the agenda command."
-  (let (pars)
-    (while parameters
-      (push (list (pop parameters) (if parameters (pop parameters))) pars))
+  (org-eval-in-environment (org-make-parameter-alist parameters)
     (if (> (length cmd-key) 2)
     (if (> (length cmd-key) 2)
-	(eval (list 'let (nreverse pars)
-		    (list 'org-tags-view nil cmd-key)))
-      (eval (list 'let (nreverse pars) (list 'org-agenda nil cmd-key))))
-    (set-buffer org-agenda-buffer-name)
-    (princ (org-encode-for-stdout (buffer-string)))))
+	(org-tags-view nil cmd-key)
+      (org-agenda nil cmd-key)))
+  (set-buffer org-agenda-buffer-name)
+  (princ (org-encode-for-stdout (buffer-string))))
 
 
 ;(defun org-encode-for-stdout (string)
 ;(defun org-encode-for-stdout (string)
 ;  (if (fboundp 'encode-coding-string)
 ;  (if (fboundp 'encode-coding-string)
@@ -2631,30 +2628,26 @@ extra        Sting with extra planning info
 priority-l   The priority letter if any was given
 priority-l   The priority letter if any was given
 priority-n   The computed numerical priority
 priority-n   The computed numerical priority
 agenda-day   The day in the agenda where this is listed"
 agenda-day   The day in the agenda where this is listed"
-
-  (let (pars)
-    (while parameters
-      (push (list (pop parameters) (if parameters (pop parameters))) pars))
-    (push (list 'org-agenda-remove-tags t) pars)
+  (org-eval-in-environment (append (org-agenda-remove-tags t)
+				   (org-make-parameter-alist parameters))
     (if (> (length cmd-key) 2)
     (if (> (length cmd-key) 2)
-	(eval (list 'let (nreverse pars)
-		    (list 'org-tags-view nil cmd-key)))
-      (eval (list 'let (nreverse pars) (list 'org-agenda nil cmd-key))))
-    (set-buffer org-agenda-buffer-name)
-    (let* ((lines (org-split-string (buffer-string) "\n"))
-	   line)
-      (while (setq line (pop lines))
-	(catch 'next
-	  (if (not (get-text-property 0 'org-category line)) (throw 'next nil))
-	  (setq org-agenda-info
-		(org-fix-agenda-info (text-properties-at 0 line)))
-	  (princ
-	   (org-encode-for-stdout
-	    (mapconcat 'org-agenda-export-csv-mapper
-		       '(org-category txt type todo tags date time extra
-				      priority-letter priority agenda-day)
-		      ",")))
-	  (princ "\n"))))))
+	(org-tags-view nil cmd-key)
+      (org-agenda nil cmd-key)))
+  (set-buffer org-agenda-buffer-name)
+  (let* ((lines (org-split-string (buffer-string) "\n"))
+	 line)
+    (while (setq line (pop lines))
+      (catch 'next
+	(if (not (get-text-property 0 'org-category line)) (throw 'next nil))
+	(setq org-agenda-info
+	      (org-fix-agenda-info (text-properties-at 0 line)))
+	(princ
+	 (org-encode-for-stdout
+	  (mapconcat 'org-agenda-export-csv-mapper
+		     '(org-category txt type todo tags date time extra
+				    priority-letter priority agenda-day)
+		     ",")))
+	(princ "\n")))))
 
 
 (defun org-fix-agenda-info (props)
 (defun org-fix-agenda-info (props)
   "Make sure all properties on an agenda item have a canonical form.
   "Make sure all properties on an agenda item have a canonical form.