[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] Filter out agenda items using elisp

From: Karl Voit
Subject: [O] Filter out agenda items using elisp
Date: Sun, 22 Jan 2017 12:09:24 +0100
User-agent: slrn/pre1.0.0-18 (Linux)


I want to write my own flexible narrow function for my agenda using

I found org-agenda-filter-by-regexp() which seems a perfect hit for
my task. However, I need to call it with a universal prefix in order
to remove lines matching my RegEx:

(defun my-narrow-agenda ()
  "Getting rid of all org-agenda entries matching the RegEx"
  (setq current-prefix-arg '(4))    ;; "add" prefix C-u
  (org-agenda-filter-by-regexp "\(WAITING\|:reward:\|:lp:\)")

When I call the function when being in my agenda, I get asked for
entering the RegEx string to narrow the items as if I did not state
the prefix-arg nor the regex as parameters.

Then I took a look at org-agenda-filter-by-regexp() (see code
below), found a new best friend in trace-function(), and tried to
mimic the function call for org-agenda-filter-apply() when I do the
task manually/interactive:

(defun my-narrow-agenda ()
  (org-agenda-filter-apply ("-NEXT.*:\\(@BWG\\|reward\\):" "+") regexp)

This returns wrong number of arguments. But why? I used the exact
output of trace-function().

How can I accomplish my code?

The related code for org-agenda-filter-by-regexp is:

(defun org-agenda-filter-by-regexp (strip)
  "Filter agenda entries by a regular expression.
Regexp filters are cumulative.
With no prefix argument, keep entries matching the regexp.
With one prefix argument, filter out entries matching the regexp.
With two prefix arguments, remove the regexp filters."
  (interactive "P")
  (if (not (equal strip '(16)))
      (let ((flt (concat (if (equal strip '(4)) "-" "+")
              (if (equal strip '(4))
                  "Filter out entries matching regexp: "
                "Narrow to entries matching regexp: ")))))
    (push flt org-agenda-regexp-filter)
    (org-agenda-filter-apply org-agenda-regexp-filter 'regexp))
    (message "Regexp filter removed")))

get mail|git|SVN|photos|postings|SMS|phonecalls|RSS|CSV|XML into Org-mode:
       > get Memacs from https://github.com/novoid/Memacs <
Personal Information Management > http://Karl-Voit.at/tags/pim/
Emacs-related > http://Karl-Voit.at/tags/emacs/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]