summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Dominik <carsten.dominik@gmail.com>2019-08-29 07:10:05 +0200
committerCarsten Dominik <carsten.dominik@gmail.com>2019-08-29 11:38:14 +0200
commit6543716d67be4d61ca94f5fc24b6143be4ca7329 (patch)
treedc5be3ea88e15967e0c92559524a09807386a946
parent36dc6ae644d54ad9cdbbdd4c88fcf9f3738c2ae2 (diff)
downloadorg-mode-6543716d67be4d61ca94f5fc24b6143be4ca7329.tar.gz
Compactify the modeline display of filters
* lisp/org-agenda.el (org-agenda-filter-variables): New constant. (org-agenda-filter-any): New function.
-rw-r--r--lisp/org-agenda.el40
-rw-r--r--lisp/org-faces.el8
2 files changed, 29 insertions, 19 deletions
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 1c4f057..8cdaf2c 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -3636,6 +3636,7 @@ removed from the entry content. Currently only `planning' is allowed here."
(defvar org-agenda-regexp-filter nil)
(defvar org-agenda-effort-filter nil)
(defvar org-agenda-top-headline-filter nil)
+
(defvar org-agenda-represented-categories nil
"Cache for the list of all categories in the agenda.")
(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
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
"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
@@ -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-category-filter :preset-filter nil)
(put 'org-agenda-regexp-filter :preset-filter nil)
+ (put 'org-agenda-effort-filter :preset-filter nil)
;; Popup existing buffer
(org-agenda-prepare-window (get-buffer org-agenda-buffer-name)
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")
(org-agenda-show-log " Log")
(t ""))
+ (if (org-agenda-filter-any) " " "")
(if (or org-agenda-category-filter
(get 'org-agenda-category-filter :preset-filter))
'(:eval (propertize
- (concat " <"
+ (concat "["
(mapconcat
'identity
(append
(get 'org-agenda-category-filter :preset-filter)
org-agenda-category-filter)
"")
- ">")
+ "]")
'face 'org-agenda-filter-category
'help-echo "Category used in filtering")) "")
(if (or org-agenda-tag-filter
(get 'org-agenda-tag-filter :preset-filter))
'(:eval (propertize
- (concat " {"
- (mapconcat
+ (concat (mapconcat
'identity
(append
(get 'org-agenda-tag-filter :preset-filter)
org-agenda-tag-filter)
- "")
- "}")
+ ""))
'face 'org-agenda-filter-tags
'help-echo "Tags used in filtering")) "")
(if (or org-agenda-effort-filter
(get 'org-agenda-effort-filter :preset-filter))
'(:eval (propertize
- (concat " {"
- (mapconcat
+ (concat (mapconcat
'identity
(append
(get 'org-agenda-effort-filter :preset-filter)
org-agenda-effort-filter)
- "")
- "}")
+ ""))
'face 'org-agenda-filter-effort
'help-echo "Effort conditions used in filtering")) "")
(if (or org-agenda-regexp-filter
(get 'org-agenda-regexp-filter :preset-filter))
'(:eval (propertize
- (concat " ["
- (mapconcat
- 'identity
+ (concat (mapconcat
+ (lambda (x) (concat (substring x 0 1) "/" (substring x 1) "/"))
(append
(get 'org-agenda-regexp-filter :preset-filter)
org-agenda-regexp-filter)
- "")
- "]")
+ ""))
'face 'org-agenda-filter-regexp
'help-echo "Regexp used in filtering")) "")
(if org-agenda-archives-mode
diff --git a/lisp/org-faces.el b/lisp/org-faces.el
index 8e9726c..b792598 100644
--- a/lisp/org-faces.el
+++ b/lisp/org-faces.el
@@ -559,10 +559,6 @@ month and 365.24 days for a year)."
"Face for tag(s) in the mode-line when filtering the agenda."
: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))
"Face for categories in the mode-line when filtering the agenda."
: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."
: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'
'((((class color) (min-colors 16) (background light)) (:foreground "DarkGoldenrod"))
(((class color) (min-colors 16) (background dark)) (:foreground "LightGoldenrod"))