0
0
Fork 1
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-09-30 02:30:03 +00:00

Compactify the modeline display of filters

* lisp/org-agenda.el (org-agenda-filter-variables): New constant.
(org-agenda-filter-any): New function.
This commit is contained in:
Carsten Dominik 2019-08-29 07:10:05 +02:00
parent 36dc6ae644
commit 6543716d67
2 changed files with 29 additions and 19 deletions

View file

@ -3636,6 +3636,7 @@ removed from the entry content. Currently only `planning' is allowed here."
(defvar org-agenda-regexp-filter nil) (defvar org-agenda-regexp-filter nil)
(defvar org-agenda-effort-filter nil) (defvar org-agenda-effort-filter nil)
(defvar org-agenda-top-headline-filter nil) (defvar org-agenda-top-headline-filter nil)
(defvar org-agenda-represented-categories nil (defvar org-agenda-represented-categories nil
"Cache for the list of all categories in the agenda.") "Cache for the list of all categories in the agenda.")
(defvar org-agenda-represented-tags nil (defvar org-agenda-represented-tags nil
@ -3650,6 +3651,19 @@ the entire agenda view. In a block agenda, it will not work reliably to
define a filter for one of the individual blocks. You need to set it in define a filter for one of the individual blocks. You need to set it in
the global options and expect it to be applied to the entire view.") the global options and expect it to be applied to the entire view.")
(defconst org-agenda-filter-variables
'((category . org-agenda-category-filter)
(tag . org-agenda-tag-filter)
(effort . org-agenda-effort-filter)
(regexp . org-agenda-regexp-filter))
"Alist of filter types and associated variables")
(defun org-agenda-filter-any ()
"Is any filter active?"
(eval (cons 'or (mapcar (lambda (x)
(or (symbol-value (cdr x))
(get :preset-filter x)))
org-agenda-filter-variables))))
(defvar org-agenda-category-filter-preset nil (defvar org-agenda-category-filter-preset nil
"A preset of the category filter used for secondary agenda filtering. "A preset of the category filter used for secondary agenda filtering.
This must be a list of strings, each string must be a single category This must be a list of strings, each string must be a single category
@ -3747,6 +3761,7 @@ FILTER-ALIST is an alist of filters we need to apply when
(put 'org-agenda-tag-filter :preset-filter nil) (put 'org-agenda-tag-filter :preset-filter nil)
(put 'org-agenda-category-filter :preset-filter nil) (put 'org-agenda-category-filter :preset-filter nil)
(put 'org-agenda-regexp-filter :preset-filter nil) (put 'org-agenda-regexp-filter :preset-filter nil)
(put 'org-agenda-effort-filter :preset-filter nil)
;; Popup existing buffer ;; Popup existing buffer
(org-agenda-prepare-window (get-buffer org-agenda-buffer-name) (org-agenda-prepare-window (get-buffer org-agenda-buffer-name)
filter-alist) filter-alist)
@ -8392,56 +8407,51 @@ When called with a prefix argument, include all archive files as well."
((eq org-agenda-show-log 'clockcheck) " ClkCk") ((eq org-agenda-show-log 'clockcheck) " ClkCk")
(org-agenda-show-log " Log") (org-agenda-show-log " Log")
(t "")) (t ""))
(if (org-agenda-filter-any) " " "")
(if (or org-agenda-category-filter (if (or org-agenda-category-filter
(get 'org-agenda-category-filter :preset-filter)) (get 'org-agenda-category-filter :preset-filter))
'(:eval (propertize '(:eval (propertize
(concat " <" (concat "["
(mapconcat (mapconcat
'identity 'identity
(append (append
(get 'org-agenda-category-filter :preset-filter) (get 'org-agenda-category-filter :preset-filter)
org-agenda-category-filter) org-agenda-category-filter)
"") "")
">") "]")
'face 'org-agenda-filter-category 'face 'org-agenda-filter-category
'help-echo "Category used in filtering")) "") 'help-echo "Category used in filtering")) "")
(if (or org-agenda-tag-filter (if (or org-agenda-tag-filter
(get 'org-agenda-tag-filter :preset-filter)) (get 'org-agenda-tag-filter :preset-filter))
'(:eval (propertize '(:eval (propertize
(concat " {" (concat (mapconcat
(mapconcat
'identity 'identity
(append (append
(get 'org-agenda-tag-filter :preset-filter) (get 'org-agenda-tag-filter :preset-filter)
org-agenda-tag-filter) org-agenda-tag-filter)
"") ""))
"}")
'face 'org-agenda-filter-tags 'face 'org-agenda-filter-tags
'help-echo "Tags used in filtering")) "") 'help-echo "Tags used in filtering")) "")
(if (or org-agenda-effort-filter (if (or org-agenda-effort-filter
(get 'org-agenda-effort-filter :preset-filter)) (get 'org-agenda-effort-filter :preset-filter))
'(:eval (propertize '(:eval (propertize
(concat " {" (concat (mapconcat
(mapconcat
'identity 'identity
(append (append
(get 'org-agenda-effort-filter :preset-filter) (get 'org-agenda-effort-filter :preset-filter)
org-agenda-effort-filter) org-agenda-effort-filter)
"") ""))
"}")
'face 'org-agenda-filter-effort 'face 'org-agenda-filter-effort
'help-echo "Effort conditions used in filtering")) "") 'help-echo "Effort conditions used in filtering")) "")
(if (or org-agenda-regexp-filter (if (or org-agenda-regexp-filter
(get 'org-agenda-regexp-filter :preset-filter)) (get 'org-agenda-regexp-filter :preset-filter))
'(:eval (propertize '(:eval (propertize
(concat " [" (concat (mapconcat
(mapconcat (lambda (x) (concat (substring x 0 1) "/" (substring x 1) "/"))
'identity
(append (append
(get 'org-agenda-regexp-filter :preset-filter) (get 'org-agenda-regexp-filter :preset-filter)
org-agenda-regexp-filter) org-agenda-regexp-filter)
"") ""))
"]")
'face 'org-agenda-filter-regexp 'face 'org-agenda-filter-regexp
'help-echo "Regexp used in filtering")) "") 'help-echo "Regexp used in filtering")) "")
(if org-agenda-archives-mode (if org-agenda-archives-mode

View file

@ -559,10 +559,6 @@ month and 365.24 days for a year)."
"Face for tag(s) in the mode-line when filtering the agenda." "Face for tag(s) in the mode-line when filtering the agenda."
:group 'org-faces) :group 'org-faces)
(defface org-agenda-filter-regexp '((t :inherit mode-line))
"Face for regexp(s) in the mode-line when filtering the agenda."
:group 'org-faces)
(defface org-agenda-filter-category '((t :inherit mode-line)) (defface org-agenda-filter-category '((t :inherit mode-line))
"Face for categories in the mode-line when filtering the agenda." "Face for categories in the mode-line when filtering the agenda."
:group 'org-faces) :group 'org-faces)
@ -571,6 +567,10 @@ month and 365.24 days for a year)."
"Face for effort in the mode-line when filtering the agenda." "Face for effort in the mode-line when filtering the agenda."
:group 'org-faces) :group 'org-faces)
(defface org-agenda-filter-regexp '((t :inherit mode-line))
"Face for regexp(s) in the mode-line when filtering the agenda."
:group 'org-faces)
(defface org-time-grid ;Copied from `font-lock-variable-name-face' (defface org-time-grid ;Copied from `font-lock-variable-name-face'
'((((class color) (min-colors 16) (background light)) (:foreground "DarkGoldenrod")) '((((class color) (min-colors 16) (background light)) (:foreground "DarkGoldenrod"))
(((class color) (min-colors 16) (background dark)) (:foreground "LightGoldenrod")) (((class color) (min-colors 16) (background dark)) (:foreground "LightGoldenrod"))