Browse Source

org-agenda.el: Small `org-agenda-filter' enhancement

* lisp/org-agenda.el (org-agenda-filter): Use existing filters as
the initial prompt input.
Bastien 5 months ago
parent
commit
9fe7dbfd15
1 changed files with 8 additions and 2 deletions
  1. 8 2
      lisp/org-agenda.el

+ 8 - 2
lisp/org-agenda.el

@@ -7614,7 +7614,6 @@ consistency with the other filter commands."
 	       (if keep current nil)))
 	(org-agenda-filter-apply org-agenda-effort-filter 'effort)))))
 
-
 (defun org-agenda-filter (&optional strip-or-accumulate)
   "Prompt for a general filter string and apply it to the agenda.
 
@@ -7665,11 +7664,18 @@ the variable `org-agenda-auto-exclude-function'."
     (let* ((tag-list (org-agenda-get-represented-tags))
 	   (category-list (org-agenda-get-represented-categories))
 	   (negate (equal strip-or-accumulate '(4)))
+	   (cf (mapconcat #'identity org-agenda-category-filter ""))
+	   (tf (mapconcat #'identity org-agenda-tag-filter ""))
+	   (rpl-fn (lambda (c) (replace-regexp-in-string "^\+" "" (or (car c) ""))))
+	   (ef (replace-regexp-in-string "^\+" "" (or (car org-agenda-effort-filter) "")))
+	   (rf (replace-regexp-in-string "^\+" "" (or (car org-agenda-regexp-filter) "")))
+	   (ff (concat cf tf ef (when (not (equal rf "")) (concat "/" rf "/"))))
 	   (f-string (completing-read
 		      (concat
 		       (if negate "Negative filter" "Filter")
 		       " [+cat-tag<0:10-/regexp/]: ")
-		      'org-agenda-filter-completion-function))
+		      'org-agenda-filter-completion-function
+		      nil nil ff))
 	   (keep (or (if (string-match "^\\+[+-]" f-string)
 			 (progn (setq f-string (substring f-string 1)) t))
 		     (equal strip-or-accumulate '(16))))