From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Maus Subject: [PATCH 6/7] Use org-eval-in-environment, make macros functions Date: Tue, 2 Aug 2011 11:23:39 +0200 Message-ID: <1312277020-7888-7-git-send-email-dmaus@ictsoc.de> References: <1312277020-7888-1-git-send-email-dmaus@ictsoc.de> Return-path: Received: from eggs.gnu.org ([140.186.70.92]:53384) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QoBD0-0000VF-Da for emacs-orgmode@gnu.org; Tue, 02 Aug 2011 05:24:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QoBCy-0000Ie-Bd for emacs-orgmode@gnu.org; Tue, 02 Aug 2011 05:24:18 -0400 Received: from app1b.xlhost.de ([213.202.242.162]:59952) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QoBCx-0000IG-W6 for emacs-orgmode@gnu.org; Tue, 02 Aug 2011 05:24:16 -0400 In-Reply-To: <1312277020-7888-1-git-send-email-dmaus@ictsoc.de> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Cc: David Maus * org-agenda.el (org-batch-agenda, org-batch-agenda-csv): Make a function, use org-eval-in-environment. --- lisp/org-agenda.el | 59 ++++++++++++++++++++++----------------------------- 1 files changed, 26 insertions(+), 33 deletions(-) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index 25a556e..6079377 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -2569,22 +2569,19 @@ s Search for keywords C Configure custom agenda commands (org-let (nth 1 series) '(org-finalize-agenda))) ;;;###autoload -(defmacro org-batch-agenda (cmd-key &rest parameters) +(defun org-batch-agenda (cmd-key &rest parameters) "Run an agenda command in batch mode and send the result to STDOUT. If CMD-KEY is a string of length 1, it is used as a key in `org-agenda-custom-commands' and triggers this command. If it is a longer string it is used as a tags/todo match string. Parameters are alternating variable names and values that will be bound 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) - (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) ; (if (fboundp 'encode-coding-string) @@ -2597,7 +2594,7 @@ before running the agenda command." (defvar org-agenda-info nil) ;;;###autoload -(defmacro org-batch-agenda-csv (cmd-key &rest parameters) +(defun org-batch-agenda-csv (cmd-key &rest parameters) "Run an agenda command in batch mode and send the result to STDOUT. If CMD-KEY is a string of length 1, it is used as a key in `org-agenda-custom-commands' and triggers this command. If it is a @@ -2631,30 +2628,26 @@ extra Sting with extra planning info priority-l The priority letter if any was given priority-n The computed numerical priority 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) - (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) "Make sure all properties on an agenda item have a canonical form. -- 1.7.2.5