From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id 2IS0B+OcFWEWMwAAgWs5BA (envelope-from ) for ; Fri, 13 Aug 2021 00:12:51 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id wI85A+OcFWH9RQAA1q6Kng (envelope-from ) for ; Thu, 12 Aug 2021 22:12:51 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 4E4EF110D8 for ; Fri, 13 Aug 2021 00:12:50 +0200 (CEST) Received: from localhost ([::1]:47708 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mEIwT-0004NZ-B5 for larch@yhetil.org; Thu, 12 Aug 2021 18:12:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37250) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mEIvP-0003kn-AP for emacs-orgmode@gnu.org; Thu, 12 Aug 2021 18:11:43 -0400 Received: from relay8-d.mail.gandi.net ([217.70.183.201]:49239) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mEIvN-0002Tn-JO for emacs-orgmode@gnu.org; Thu, 12 Aug 2021 18:11:43 -0400 Received: (Authenticated sender: league@contrapunctus.net) by relay8-d.mail.gandi.net (Postfix) with ESMTPSA id 431261BF206; Thu, 12 Aug 2021 22:11:37 +0000 (UTC) From: Christopher League To: emacs-orgmode@gnu.org Subject: [PATCH] org-agenda: Allow org-agenda-overriding-header to be a function Date: Thu, 12 Aug 2021 18:09:35 -0400 Message-Id: <20210812220934.178834-2-league@contrapunctus.net> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210812220934.178834-1-league@contrapunctus.net> References: <20210812220934.178834-1-league@contrapunctus.net> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=217.70.183.201; envelope-from=league@contrapunctus.net; helo=relay8-d.mail.gandi.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christopher League Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1628806370; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=QfstuA8rGBLbvNe0rARsRkV8dZoCEO6P4mz4kQEHzbk=; b=ADdBynA7MBD6lZOalEe/bUw2aGek+CBY07cSSpi/wuv/U9THyTZfnVQoB48+q/4QpSCn3i QGHaO8YJEEj5Z5dnxwo759CXfwVFryGdp/aGywEUUpUxo6mr1sCi17i0s03Nu2cNlVNTqa 3f4v87+J2rJGO61mm5J87oKKP0x46pX/mXl1e0qLPWvkdXZkxI/5mYp4vYnj2FomgzjI28 Ay7x/Q5m15ZwIa5cYLaMY/Rj4uG+ZCbjRgJdRYBzQ8/z50HbBZP/2kz7C64icmaBMXIxsr sXBQHwuV922XP+z3U5Ppwlsc6L5DHD8nbilUkMzDyYaH4zPpBIDXyh0Kpcj3HQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1628806370; a=rsa-sha256; cv=none; b=RPlBwdgyg1Z8KK/74ezTfwA2dv4/3OZ1KTylw0ocGo5mUh8kQ6N0ysXESixXu4P2NOXFUw DyAOrMPSowbowEqnYQVvAwqvUtD5Kc79IZ6J2o0t1xYqVOpoWalfCkceCG3ujpCVvSnpvt /qyOyq0lrVfOaT3ErtHn+s0RpWOJjvzHF1dAdXS12k2TZBeshdHjj1ZCl88Gche1oYuF1G M8hTtU/iyDc2Xhy4GGcZIeadTUs8+pU2ecH5zYJp85nEQr3KuZtE+Mxxda7vv2LgM5sgG6 1wBe2N0CBRCwwLNvRcUI5OsM00RHC+5wtz5vn6oCulJf3rHM55vN6GdcvKOabA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Spam-Score: -1.41 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Queue-Id: 4E4EF110D8 X-Spam-Score: -1.41 X-Migadu-Scanner: scn0.migadu.com X-TUID: 7Z4Ep1B+PKNm * org-agenda.el (org-agenda--insert-overriding-header): Allow `org-agenda-overriding-header' to be a function in addition to a string or nil. When the custom agenda is created or updated, call that function and insert the string it returns as the agenda header. This allows custom commands to produce dynamic headers that include up-to-date information. For example, this produces a header with a current timestamp: (push '("DHD" "Dynamic header demo" ((alltodo "" ((org-agenda-overriding-header (lambda () (propertize (format-time-string "-- Get crackin’, it’s %H:%M:%S!!\n") 'face 'org-agenda-structure))))))) org-agenda-custom-commands) User is free to add any face properties, use Org links, and include a blank line or not. I am using this to count how many items are in various inboxes and display them in an agenda. --- lisp/org-agenda.el | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index b4e5547d7..f5e332a29 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -2131,7 +2131,8 @@ works you probably want to add it to `org-agenda-custom-commands' for good." The inserted header depends on `org-agenda-overriding-header'. If the empty string, don't insert a header. If any other string, insert it as a header. If nil, insert DEFAULT, which should -evaluate to a string." +evaluate to a string. If a function, call it and insert the +string that it returns." (declare (debug (form)) (indent defun)) `(cond ((not org-agenda-overriding-header) (insert ,default)) @@ -2140,6 +2141,8 @@ evaluate to a string." (insert (propertize org-agenda-overriding-header 'face 'org-agenda-structure) "\n")) + ((functionp org-agenda-overriding-header) + (insert (funcall org-agenda-overriding-header))) (t (user-error "Invalid value for `org-agenda-overriding-header': %S" org-agenda-overriding-header)))) @@ -5046,10 +5049,11 @@ 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. If an empty string, no header will be inserted. If any other -string, it will be inserted as a header. If nil, a header will -be generated automatically according to the command. This -variable should not be set directly, but custom commands can bind -it in the options section.") +string, it will be inserted as a header. If a function, insert +the string returned by the function as a header. If nil, a +header will be generated automatically according to the command. +This variable should not be set directly, but custom commands can +bind it in the options section.") (defun org-agenda-skip-entry-if (&rest conditions) "Skip entry if any of CONDITIONS is true. -- 2.31.1