From mboxrd@z Thu Jan 1 00:00:00 1970 From: Karl Voit Subject: Filter out agenda items using elisp Date: Sun, 22 Jan 2017 12:09:24 +0100 Message-ID: <2017-01-22T11-44-29@devnull.Karl-Voit.at> Reply-To: Karl Voit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:35665) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cVG20-0007vZ-Dj for emacs-orgmode@gnu.org; Sun, 22 Jan 2017 06:09:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cVG1x-0007ZZ-9B for emacs-orgmode@gnu.org; Sun, 22 Jan 2017 06:09:56 -0500 Received: from [195.159.176.226] (port=38178 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cVG1x-0007X7-2C for emacs-orgmode@gnu.org; Sun, 22 Jan 2017 06:09:53 -0500 Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1cVG1n-00034t-IE for emacs-orgmode@gnu.org; Sun, 22 Jan 2017 12:09:43 +0100 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" To: emacs-orgmode@gnu.org Hi! I want to write my own flexible narrow function for my agenda using RegEx. 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" (interactive) (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 () (interactive) (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)) "-" "+") (read-from-minibuffer (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)) (org-agenda-filter-show-all-re) (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/