emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [idea] Dynamic agenda filtering
@ 2020-05-02 10:32 Marco Wahl
  0 siblings, 0 replies; only message in thread
From: Marco Wahl @ 2020-05-02 10:32 UTC (permalink / raw)
  To: emacs-orgmode

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



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-05-02 10:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-05-02 10:32 [idea] Dynamic agenda filtering Marco Wahl

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).