Hi, This patch adds a 'none setting for org-agenda-overriding-header, which allows it to be disabled completely, rather than inserting a blank line as it does when set to an empty string.
This was requested by a user here: <https://github.com/alphapapa/org-super-agenda/issues/10>, but I guess it may also be useful for Org users who don't use that package. Thanks, Adam
>From 8ae87be7ba98dec23b6875b72234272b78ea76a8 Mon Sep 17 00:00:00 2001 From: Adam Porter <a...@alphapapa.net> Date: Tue, 15 Aug 2017 23:01:32 -0500 Subject: [PATCH] org-agenda: Add 'none setting for org-agenda-overriding-header * lisp/org-agenda.el (org-agenda-overriding-header): Update docstring. (org-agenda-list): Handle 'none setting. (org-search-view): Handle 'none setting. (org-todo-list): Handle 'none setting. (org-tags-view): Handle 'none setting. * etc/ORG-NEWS: Mention new setting. --- etc/ORG-NEWS | 5 ++ lisp/org-agenda.el | 151 +++++++++++++++++++++++++++++------------------------ 2 files changed, 89 insertions(+), 67 deletions(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 9631411..ba6eb32 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -118,6 +118,11 @@ See docstring for details. automatically align tags to the right edge of the window. This is now the default setting. +**** New =none= setting for =org-agenda-overriding-header= + +=org-agenda-overriding-header= may now be set to the symbol =none=, which +will prevent the header from being inserted into the agenda buffer. + *** New value for ~org-publish-sitemap-sort-folders~ The new ~ignore~ value effectively allows toggling inclusion of diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index a661a78..836ebd2 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -4159,17 +4159,20 @@ items if they have an hour specification like [h]h:mm." (w1 (org-days-to-iso-week d1)) (w2 (org-days-to-iso-week d2))) (setq s (point)) - (if org-agenda-overriding-header - (insert (org-add-props (copy-sequence org-agenda-overriding-header) - nil 'face 'org-agenda-structure) "\n") - (insert (org-agenda-span-name span) - "-agenda" - (if (< (- d2 d1) 350) - (if (= w1 w2) - (format " (W%02d)" w1) - (format " (W%02d-W%02d)" w1 w2)) - "") - ":\n"))) + (pcase org-agenda-overriding-header + ((pred stringp) + (insert (org-add-props (copy-sequence org-agenda-overriding-header) + nil 'face 'org-agenda-structure) "\n")) + ('none nil) + ((pred null) + (insert (org-agenda-span-name span) + "-agenda" + (if (< (- d2 d1) 350) + (if (= w1 w2) + (format " (W%02d)" w1) + (format " (W%02d-W%02d)" w1 w2)) + "") + ":\n")))) (add-text-properties s (1- (point)) (list 'face 'org-agenda-structure 'org-date-line t)) (org-agenda-mark-header-line s)) @@ -4580,25 +4583,28 @@ in `org-agenda-text-search-extra-files'." (goto-char (1- end)))))))))) (setq rtn (nreverse ee)) (setq rtnall (append rtnall rtn))) - (if org-agenda-overriding-header - (insert (org-add-props (copy-sequence org-agenda-overriding-header) - nil 'face 'org-agenda-structure) "\n") - (insert "Search words: ") - (add-text-properties (point-min) (1- (point)) - (list 'face 'org-agenda-structure)) - (setq pos (point)) - (insert string "\n") - (add-text-properties pos (1- (point)) (list 'face 'org-warning)) - (setq pos (point)) - (unless org-agenda-multi - (insert (substitute-command-keys "\ + (pcase org-agenda-overriding-header + ((pred stringp) + (insert (org-add-props (copy-sequence org-agenda-overriding-header) + nil 'face 'org-agenda-structure) "\n")) + ('none nil) + ((pred null) + (insert "Search words: ") + (add-text-properties (point-min) (1- (point)) + (list 'face 'org-agenda-structure)) + (setq pos (point)) + (insert string "\n") + (add-text-properties pos (1- (point)) (list 'face 'org-warning)) + (setq pos (point)) + (unless org-agenda-multi + (insert (substitute-command-keys "\ Press `\\[org-agenda-manipulate-query-add]', \ `\\[org-agenda-manipulate-query-subtract]' to add/sub word, \ `\\[org-agenda-manipulate-query-add-re]', \ `\\[org-agenda-manipulate-query-subtract-re]' to add/sub regexp, \ `\\[universal-argument] \\[org-agenda-redo]' to edit\n")) - (add-text-properties pos (1- (point)) - (list 'face 'org-agenda-structure)))) + (add-text-properties pos (1- (point)) + (list 'face 'org-agenda-structure))))) (org-agenda-mark-header-line (point-min)) (when rtnall (insert (org-agenda-finalize-entries rtnall 'search) "\n")) @@ -4676,31 +4682,34 @@ for a keyword. A numeric prefix directly selects the Nth keyword in (org-check-agenda-file file) (setq rtn (org-agenda-get-day-entries file date :todo)) (setq rtnall (append rtnall rtn)))) - (if org-agenda-overriding-header - (insert (org-add-props (copy-sequence org-agenda-overriding-header) - nil 'face 'org-agenda-structure) "\n") - (insert "Global list of TODO items of type: ") - (add-text-properties (point-min) (1- (point)) - (list 'face 'org-agenda-structure - 'short-heading - (concat "ToDo: " - (or org-select-this-todo-keyword "ALL")))) - (org-agenda-mark-header-line (point-min)) - (insert (org-agenda-propertize-selected-todo-keywords - org-select-this-todo-keyword)) - (setq pos (point)) - (unless org-agenda-multi - (insert (substitute-command-keys "Available with \ + (pcase org-agenda-overriding-header + ((pred stringp) + (insert (org-add-props (copy-sequence org-agenda-overriding-header) + nil 'face 'org-agenda-structure) "\n")) + ('none nil) + ((pred null) + (insert "Global list of TODO items of type: ") + (add-text-properties (point-min) (1- (point)) + (list 'face 'org-agenda-structure + 'short-heading + (concat "ToDo: " + (or org-select-this-todo-keyword "ALL")))) + (org-agenda-mark-header-line (point-min)) + (insert (org-agenda-propertize-selected-todo-keywords + org-select-this-todo-keyword)) + (setq pos (point)) + (unless org-agenda-multi + (insert (substitute-command-keys "Available with \ `N \\[org-agenda-redo]': (0)[ALL]")) - (let ((n 0) s) - (mapc (lambda (x) - (setq s (format "(%d)%s" (setq n (1+ n)) x)) - (if (> (+ (current-column) (string-width s) 1) (frame-width)) - (insert "\n ")) - (insert " " s)) - kwds)) - (insert "\n")) - (add-text-properties pos (1- (point)) (list 'face 'org-agenda-structure))) + (let ((n 0) s) + (mapc (lambda (x) + (setq s (format "(%d)%s" (setq n (1+ n)) x)) + (if (> (+ (current-column) (string-width s) 1) (frame-width)) + (insert "\n ")) + (insert " " s)) + kwds)) + (insert "\n")) + (add-text-properties pos (1- (point)) (list 'face 'org-agenda-structure)))) (org-agenda-mark-header-line (point-min)) (when rtnall (insert (org-agenda-finalize-entries rtnall 'todo) "\n")) @@ -4778,24 +4787,27 @@ The prefix arg TODO-ONLY limits the search to TODO entries." matcher org--matcher-tags-todo-only)) (setq rtnall (append rtnall rtn)))))))) - (if org-agenda-overriding-header - (insert (org-add-props (copy-sequence org-agenda-overriding-header) - nil 'face 'org-agenda-structure) "\n") - (insert "Headlines with TAGS match: ") - (add-text-properties (point-min) (1- (point)) - (list 'face 'org-agenda-structure - 'short-heading - (concat "Match: " match))) - (setq pos (point)) - (insert match "\n") - (add-text-properties pos (1- (point)) (list 'face 'org-warning)) - (setq pos (point)) - (unless org-agenda-multi - (insert (substitute-command-keys - "Press `\\[universal-argument] \\[org-agenda-redo]' \ + (pcase org-agenda-overriding-header + ((pred stringp) + (insert (org-add-props (copy-sequence org-agenda-overriding-header) + nil 'face 'org-agenda-structure) "\n")) + ('none nil) + ((pred null) + (insert "Headlines with TAGS match: ") + (add-text-properties (point-min) (1- (point)) + (list 'face 'org-agenda-structure + 'short-heading + (concat "Match: " match))) + (setq pos (point)) + (insert match "\n") + (add-text-properties pos (1- (point)) (list 'face 'org-warning)) + (setq pos (point)) + (unless org-agenda-multi + (insert (substitute-command-keys + "Press `\\[universal-argument] \\[org-agenda-redo]' \ to search again with new search string\n"))) - (add-text-properties pos (1- (point)) - (list 'face 'org-agenda-structure))) + (add-text-properties pos (1- (point)) + (list 'face 'org-agenda-structure)))) (org-agenda-mark-header-line (point-min)) (when rtnall (insert (org-agenda-finalize-entries rtnall 'tags) "\n")) @@ -4820,7 +4832,12 @@ used by user-defined selections using `org-agenda-skip-function'.") (defvar org-agenda-overriding-header nil "When set during agenda, todo and tags searches it replaces the header. This variable should not be set directly, but custom commands can bind it -in the options section.") +in the options section. See `org-agenda-custom-commands'. + +This may be a string, in which case it will be displayed +as-written; the symbol `none', in which case no header will be +inserted; or nil, in which case a header will be generated +automatically depending on the command.") (defun org-agenda-skip-entry-if (&rest conditions) "Skip entry if any of CONDITIONS is true. -- 2.7.4