From: David Maus <dmaus@ictsoc.de>
To: emacs-orgmode@gnu.org
Cc: David Maus <dmaus@ictsoc.de>
Subject: [PATCH 6/7] Use org-eval-in-environment, make macros functions
Date: Tue, 2 Aug 2011 11:23:39 +0200 [thread overview]
Message-ID: <1312277020-7888-7-git-send-email-dmaus@ictsoc.de> (raw)
In-Reply-To: <1312277020-7888-1-git-send-email-dmaus@ictsoc.de>
* 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
next prev parent reply other threads:[~2011-08-02 9:24 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-02 9:23 [PATCH 0/8] Org mode macros, refactored David Maus
2011-08-02 9:23 ` [PATCH 1/7] New macro: Execute BODY in enviroment with uninterned SYMBOLS David Maus
2011-08-02 13:48 ` David Maus
[not found] ` <CAJcAo8uv46JCx9cG0x_ip9DMQ-aN=buLRO_fONPoFuDkik6J1Q@mail.gmail.com>
2011-08-10 7:43 ` David Maus
2011-08-16 16:34 ` Bastien
2011-08-16 17:08 ` David Maus
2011-08-16 17:30 ` Bastien
2011-08-02 9:23 ` [PATCH 2/7] New macro: Evaluate FORM in ENVIRONMENT David Maus
2011-08-02 10:50 ` Štěpán Němec
2011-08-02 13:25 ` David Maus
2011-08-02 13:49 ` David Maus
2011-08-02 9:23 ` [PATCH 3/7] Use new macro org-with-uninterned David Maus
2011-08-02 9:23 ` [PATCH 4/7] New function: Substitute posix classes in regular expression David Maus
2011-08-02 9:23 ` [PATCH 5/7] Use macro org-with-uninterned David Maus
2011-08-02 9:23 ` David Maus [this message]
2011-08-02 9:23 ` [PATCH 7/7] Make org-batch-store-agenda-views a fun, use org-eval-in-environment David Maus
2011-08-02 9:34 ` [PATCH 0/8] Org mode macros, refactored David Maus
2011-08-02 10:44 ` Štěpán Němec
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1312277020-7888-7-git-send-email-dmaus@ictsoc.de \
--to=dmaus@ictsoc.de \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).