From: RĂ¼diger Sonderfeld Date: Wed, 14 Nov 2012 20:04:18 +0000 (+0100) Subject: org-hacks: Lunar phases: use cl-lib instead of ugly mapc hack X-Git-Tag: release_7.9.3~48 X-Git-Url: http://orgmode.org/w/?p=worg.git;a=commitdiff_plain;h=9725d3a3567ca93851d2d9f34bcc1ad9429b41a9 org-hacks: Lunar phases: use cl-lib instead of ugly mapc hack Signed-off-by: RĂ¼diger Sonderfeld --- diff --git a/org-hacks.org b/org-hacks.org index e7ec4b0..c8f6900 100644 --- a/org-hacks.org +++ b/org-hacks.org @@ -2611,18 +2611,18 @@ This can be used to display lunar phases in the agenda display with the following function: #+begin_src emacs-lisp +(require 'cl-lib) + (org-no-warnings (defvar date)) (defun org-lunar-phases () "Show lunar phase in Agenda buffer." (require 'lunar) - (let ((phase-list (lunar-phase-list (nth 0 date) (nth 2 date))) - ret) - (mapc (lambda (phase) - (when (equal (car phase) date) - (setq ret (concat (lunar-phase-name (nth 2 phase)) " " - (substring (nth 1 phase) 0 5))))) - phase-list) - ret)) + (let* ((phase-list (lunar-phase-list (nth 0 date) (nth 2 date))) + (phase (cl-find-if (lambda (phase) (equal (car phase) date)) + phase-list))) + (when phase + (setq ret (concat (lunar-phase-name (nth 2 phase)) " " + (substring (nth 1 phase) 0 5)))))) #+end_src Add the following line to an agenda file: