Compare commits

...

3 Commits

Author SHA1 Message Date
Daniel - a4823651a1
Use Common Lisp indentation by default
It's not perfect, but I think it's still closer to what I like.
2023-04-29 17:29:53 +02:00
Daniel - a44b7b660e
Remove obsolete function to skip tags in agenda views 2023-04-29 17:28:35 +02:00
Daniel - 8c9c47f6e3
Prominently display of active filters in agenda view
Displaying the current filters in the mode line alone often goes unnoticed for
me, so I need a more direct display.  Let's add it to the first structural
header.
2023-04-29 17:27:50 +02:00
2 changed files with 47 additions and 24 deletions

23
init.el
View File

@ -741,7 +741,7 @@
org-dblock-write:db/org-workload-report org-dblock-write:db/org-workload-report
endless/org-ispell endless/org-ispell
db/org-agenda-list-deadlines db/org-agenda-list-deadlines
db/org-agenda-skip-tag db/org-agenda-insert-active-filters
hydra-org-agenda-view/body hydra-org-agenda-view/body
db/org-agenda-insert-efforts db/org-agenda-insert-efforts
db/org-eval-subtree-no-confirm db/org-eval-subtree-no-confirm
@ -1134,9 +1134,6 @@
org-agenda-search-headline-for-time nil org-agenda-search-headline-for-time nil
org-agenda-search-view-always-boolean t org-agenda-search-view-always-boolean t
;; Show daily efforts directly in the agenda
org-agenda-finalize-hook '(db/org-agenda-insert-efforts)
org-agenda-clock-consistency-checks org-agenda-clock-consistency-checks
'(:max-duration 9999999 '(:max-duration 9999999
:min-duration 0 :min-duration 0
@ -1257,15 +1254,25 @@
(org-agenda-skip-deadline-prewarning-if-scheduled t))))))) (org-agenda-skip-deadline-prewarning-if-scheduled t)))))))
:config (progn :config (progn
;; avoid important buffers to end up in `org-agenda-new-buffers by ;; Avoid important buffers to end up in `org-agenda-new-buffers by
;; opening them manually ;; opening them manually
(mapc #'find-file-noselect org-agenda-files) (mapc #'find-file-noselect org-agenda-files)
(add-hook 'org-agenda-mode-hook #'hl-line-mode 'append) ;; Check that all expected agenda files are being displayed.
(advice-add 'org-agenda (advice-add 'org-agenda
:before #'db/check-special-org-files-in-agenda) :before #'db/check-special-org-files-in-agenda)
(add-hook 'org-agenda-mode-hook #'hl-line-mode 'append)
;; Show daily efforts directly in the agenda
(add-hook 'org-agenda-finalize-hook #'db/org-agenda-insert-efforts)
;; Prominently display active filters on top of agenda view; also
;; update current agenda view when updating filters to make sure our
;; display is always correct.
(add-hook 'org-agenda-finalize-hook #'db/org-agenda-insert-active-filters)
(add-hook 'org-agenda-filter-hook #'org-agenda-redo-all)
(define-advice org-agenda-redo-all (:around (old-func &rest r) goto-top-and-execute) (define-advice org-agenda-redo-all (:around (old-func &rest r) goto-top-and-execute)
"Avoid recentering the Org agenda buffer after redo by moving "Avoid recentering the Org agenda buffer after redo by moving
point to the beginning of buffer first." point to the beginning of buffer first."
@ -2791,7 +2798,7 @@ With given ARG, display files in `db/important-document-path."
;; General Stuff first ;; General Stuff first
(use-package lisp-mode (use-package lisp-mode
:init (setq lisp-indent-function #'lisp-indent-function)) :init (setq lisp-indent-function #'common-lisp-indent-function))
(use-package lispy (use-package lispy
:ensure t :ensure t

View File

@ -112,23 +112,39 @@ deadlines."
(setq buffer-read-only t) (setq buffer-read-only t)
(message "")))) (message ""))))
(defun db/org-agenda-skip-tag (tag &optional others) (defun db/org-agenda-insert-active-filters (&optional match)
;; https://stackoverflow.com/questions/10074016/org-mode-filter-on-tag-in-agenda-view "Insert string showing the current agenda filters.
"Skip all entries that correspond to TAG.
If OTHERS is true, skip all entries that do not correspond to TAG." The filter display is added after the structural header.
(let* ((next-headline (save-mark-and-excursion
(or (outline-next-heading) (point-max)))) If no agenda filters are active, nothing will be inserted.
(current-headline (or (and (org-at-heading-p)
(point)) Add this function to `org-agenda-finalize-hook' to enable this."
(save-mark-and-excursion ;; First delete any present active filter display, as it might be obsolete.
;; remember to also consider invisible headings (save-excursion
(org-back-to-heading t)))) (when-let ((pos (text-property-any
(has-tag (member tag (org-get-tags current-headline)))) (point) (point-max) 'db/active-filter-display t)))
(if (or (and others (not has-tag)) (goto-char pos)
(and (not others) has-tag)) (kill-line)))
next-headline
nil))) ;; Insert current active filters if there are any.
(when (org-agenda-filter-any)
(save-excursion
(when-let ((pos (text-property-any
(point) (point-max) 'org-agenda-structural-header t)))
(goto-char pos)
(end-of-line)
;; Current filter display shamelessly stolen from `org-agenda-filter'.
;; Is there a function to do this?
(let* ((cf (mapconcat #'identity org-agenda-category-filter ""))
(tf (mapconcat #'identity org-agenda-tag-filter ""))
(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 "/")))))
(insert-and-inherit
(propertize (format " [%s]" ff)
'db/active-filter-display t)))))))
;; A Hydra for changing agenda appearance ;; A Hydra for changing agenda appearance
;; http://oremacs.com/2016/04/04/hydra-doc-syntax/ ;; http://oremacs.com/2016/04/04/hydra-doc-syntax/