* Filtering in org-agenda-filter-by-category
@ 2013-06-16 21:42 Gustav Wikström
2013-06-27 14:48 ` Bastien
0 siblings, 1 reply; 4+ messages in thread
From: Gustav Wikström @ 2013-06-16 21:42 UTC (permalink / raw)
To: Org Mode List
[-- Attachment #1: Type: text/plain, Size: 1266 bytes --]
Dear list,
I'd like to propose an addition to the function
"org-agenda-filter-by-category"; that is, the function called when pushing
"<" in an agenda.
As some might know adding a C-u in front of the command filters away the
current category instead of only listing it solemnly. I've made a change in
my source to allow multiple categories to be filtered away, instead of the
current functionality where only one category could be removed at a time.
This allows for multiple categories to be removed from the agenda. Very
simple, very effective.
Maybe some kind person could look at this and incorporate in the source?
(defun org-agenda-filter-by-category (strip)
"Keep only those lines in the agenda buffer that have a specific category.
The category is that of the current line."
(interactive "P")
(if org-agenda-filtered-by-category
(org-agenda-filter-show-all-cat)
(let ((cat (org-no-properties (get-text-property (point)
'org-category))))
(cond
((and cat (not strip))
(org-agenda-filter-apply
(list (concat "+" cat)) 'category))
((and cat strip)
(org-agenda-filter-apply
(push (concat "-" cat) org-agenda-category-filter) 'category))
((error "No category at point"))))))
/Gustav
[-- Attachment #2: Type: text/html, Size: 2455 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Filtering in org-agenda-filter-by-category
2013-06-16 21:42 Filtering in org-agenda-filter-by-category Gustav Wikström
@ 2013-06-27 14:48 ` Bastien
2013-06-27 15:22 ` Gustav Wikström
0 siblings, 1 reply; 4+ messages in thread
From: Bastien @ 2013-06-27 14:48 UTC (permalink / raw)
To: Gustav Wikström; +Cc: Org Mode List
Hi Gustav,
(please use plain text when posting code, other the code snippet
is often mangled and not readable... thanks!)
Gustav Wikström <gustav.erik@gmail.com> writes:
> I'd like to propose an addition to the function
> "org-agenda-filter-by-category"; that is, the function called when pushing
> "<" in an agenda.
>
> As some might know adding a C-u in front of the command filters away the
> current category instead of only listing it solemnly. I've made a change in
> my source to allow multiple categories to be filtered away, instead of the
> current functionality where only one category could be removed at a time.
Using C-u < multiple times to exclude entries from multiple categories
works here. What version of Org are you using (M-x org-version RET)?
Thanks,
--
Bastien
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Filtering in org-agenda-filter-by-category
2013-06-27 14:48 ` Bastien
@ 2013-06-27 15:22 ` Gustav Wikström
2013-06-27 15:45 ` Bastien
0 siblings, 1 reply; 4+ messages in thread
From: Gustav Wikström @ 2013-06-27 15:22 UTC (permalink / raw)
To: Bastien; +Cc: Org Mode List
[-- Attachment #1: Type: text/plain, Size: 2146 bytes --]
Oh, ok. Didn't realize. I did the change a long time ago in my private
installation.
One difference in my version is the visibility of the filter in the
mode-line though. Doing C-u < multiple times adds every removed
category to the display in the mode-line.
I updated to 8.0.3 recently and did some changes to "my" version to
correspond to the evolution in the main repository. Here comes an
updated version:
(defun org-agenda-filter-by-category (strip)
"Keep only those lines in the agenda buffer that have a specific category.
The category is that of the current line."
(interactive "P")
(if (and org-agenda-filtered-by-category
org-agenda-category-filter)
(org-agenda-filter-show-all-cat)
(let ((cat (org-no-properties (get-text-property (point) 'org-category))))
(cond
((and cat strip)
(org-agenda-filter-apply
(push (concat "-" cat) org-agenda-category-filter) 'category))
((and cat)
(org-agenda-filter-apply
(setq org-agenda-category-filter
(list (concat "+" cat))) 'category))
((error "No category at point"))))))
I also attached a diff between the above and the code in 8.0.3.
Regards Gustav
On Thu, Jun 27, 2013 at 4:48 PM, Bastien <bzg@gnu.org> wrote:
>
> Hi Gustav,
>
> (please use plain text when posting code, other the code snippet
> is often mangled and not readable... thanks!)
>
> Gustav Wikström <gustav.erik@gmail.com> writes:
>
> > I'd like to propose an addition to the function
> > "org-agenda-filter-by-category"; that is, the function called when pushing
> > "<" in an agenda.
> >
> > As some might know adding a C-u in front of the command filters away the
> > current category instead of only listing it solemnly. I've made a change in
> > my source to allow multiple categories to be filtered away, instead of the
> > current functionality where only one category could be removed at a time.
>
> Using C-u < multiple times to exclude entries from multiple categories
> works here. What version of Org are you using (M-x org-version RET)?
>
> Thanks,
>
> --
> Bastien
[-- Attachment #2: diff.txt --]
[-- Type: text/plain, Size: 994 bytes --]
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index fe2c743..e1fc4ec 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -7307,12 +7307,15 @@ The category is that of the current line."
org-agenda-category-filter)
(org-agenda-filter-show-all-cat)
(let ((cat (org-no-properties (get-text-property (point) 'org-category))))
- (if (and cat (not (string= "" cat)))
- (org-agenda-filter-apply
- (setq org-agenda-category-filter
- (list (concat (if strip "-" "+") cat)))
- 'category)
- (error "No category at point")))))
+ (cond
+ ((and cat strip)
+ (org-agenda-filter-apply
+ (push (concat "-" cat) org-agenda-category-filter) 'category))
+ ((and cat)
+ (org-agenda-filter-apply
+ (setq org-agenda-category-filter
+ (list (concat "+" cat))) 'category))
+ ((error "No category at point"))))))
(defun org-find-top-headline (&optional pos)
"Find the topmost parent headline and return it."
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-06-27 15:45 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-16 21:42 Filtering in org-agenda-filter-by-category Gustav Wikström
2013-06-27 14:48 ` Bastien
2013-06-27 15:22 ` Gustav Wikström
2013-06-27 15:45 ` Bastien
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.