[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[idea] Dynamic agenda filtering
From: |
Marco Wahl |
Subject: |
[idea] Dynamic agenda filtering |
Date: |
Sat, 02 May 2020 12:32:30 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
Hi,
These are a few lines of experimental code to bring dynamic filtering to
the agenda. I think it's not too bad already.
I'd like to invite you to check it out. Just mark the code and do
{M-x eval-region RET}. Then you have the "dynamic filtering" on key "&"
in the agenda. Just type to see the effect.
BTW recall key "|" to remove all filters.
#+begin_src emacs-lisp
(defun org-agenda-dynamic-filter-minibuffer-contents ()
"Return the contents of the minibuffer when it is active."
(when (active-minibuffer-window)
(with-current-buffer (window-buffer (active-minibuffer-window))
(minibuffer-contents))))
(defun org-agenda-dynamic-filter-update-regexp ()
(with-current-buffer "*Org Agenda*"
(org-agenda-remove-filter 'regexp))
(setq org-agenda-regexp-filter
(if (string= "" (org-agenda-dynamic-filter-minibuffer-contents))
nil
(list (concat "+" (org-agenda-dynamic-filter-minibuffer-contents)))))
(with-current-buffer "*Org Agenda*"
(cl-flet ((recenter (&optional arg redisplay) nil))
(org-agenda-finalize))))
(defun org-agenda-dynamic-filter-regexp-read ()
"Read string with PROMPT and display results dynamically.
See also `org-agenda-filter-by-regexp'."
(interactive)
(unwind-protect
(catch 'click
(add-hook 'post-command-hook #'org-agenda-dynamic-filter-update-regexp)
(read-string "Regexp: "))
(remove-hook 'post-command-hook #'org-agenda-dynamic-filter-update-regexp)))
(org-defkey org-agenda-mode-map "&" #'org-agenda-dynamic-filter-regexp-read)
#+end_src
As always comments and all are very much appreciated. Possibly this can be
developed into something useful.
BTW for the implementation I glanced at the--in my opinion very
nice--org-velocity.el .
Ciao,
--
Marco
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [idea] Dynamic agenda filtering,
Marco Wahl <=