emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Marco Wahl <marcowahlsoft@gmail.com>
To: emacs-orgmode@gnu.org
Subject: [idea] Dynamic agenda filtering
Date: Sat, 02 May 2020 12:32:30 +0200	[thread overview]
Message-ID: <87k11u8w5d.fsf@gmail.com> (raw)

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



                 reply	other threads:[~2020-05-02 10:33 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87k11u8w5d.fsf@gmail.com \
    --to=marcowahlsoft@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --subject='Re: [idea] Dynamic agenda filtering' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Code repositories for project(s) associated with this 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).