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 mNjROhA4x2H4JwEAgWs5BA (envelope-from ) for ; Sat, 25 Dec 2021 16:26:08 +0100 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 cPWLNhA4x2FYQAAA1q6Kng (envelope-from ) for ; Sat, 25 Dec 2021 15:26:08 +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 CB9B3C015 for ; Sat, 25 Dec 2021 16:26:07 +0100 (CET) Received: from localhost ([::1]:55986 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n18vu-0002BE-V8 for larch@yhetil.org; Sat, 25 Dec 2021 10:26:06 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57354) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n18ua-00029x-Tg for emacs-orgmode@gnu.org; Sat, 25 Dec 2021 10:24:44 -0500 Received: from out2-smtp.messagingengine.com ([66.111.4.26]:45921) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n18uZ-00036S-0B for emacs-orgmode@gnu.org; Sat, 25 Dec 2021 10:24:44 -0500 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 933B25C00FF for ; Sat, 25 Dec 2021 10:24:42 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Sat, 25 Dec 2021 10:24:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eml.cc; h= message-id:subject:from:to:content-type:date:mime-version :content-transfer-encoding; s=fm2; bh=VvxrsrFhE75hBPQoAs/j7rCCYh GsAQcmiPKh/XJAVxg=; b=Q+JcSxkJnMAiCqxyw1uzI7/Ie9g6P56wh9dKgPYDHx abobTKkwLJCBdwR+QwVbWeSZmeXKkPE9Qg1MEgd8kEwVrOLuG6LRS0ecI5SDowzW nax4+a2fn5nW9lvXRzvg8zI6Zd7S5B6t9koBCGL+9gM7yBdfZH79K/hkpZdBx5B6 M1ifENuk2uNAJUR6a9V8GUQt2Vt0CNfzl5odrwWf91bVmuxeyTYm4f/u6TGrEQRa CoAQ9rEQgT29kotVWS6xMes/CnOUsw/zuBSsG/Ra2TIPgwdgrkezu9ZxwMC5/Trh Pf/mesTabOktMjpU02PnpDqo8mnTAetDfd7gCPIgGvnA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:message-id:mime-version:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=Vvxrsr FhE75hBPQoAs/j7rCCYhGsAQcmiPKh/XJAVxg=; b=RDq97WJY/3BvRNmpDjpIZk AYlG6LtD7VPRBJSVVWJ+KevThtRHq6waogUpS6RI7AmsNx1av4X+bvNvv+exmbgK SGJJwOkmjq+Mo+/pvzdWNGjGl/aGZEs2Dzx0pWJUKAm4w/OauqJaGYLo9HyhxbR5 UWKXMWfn8UB+pbn/wYsV0rp31iZs0fmjdITuDk42Bb9ymV6RnfWBF8I0h8t+dOv5 M0xxUD+mp3Ecxb80f7TNw3rBn8uDe9VF/vKN51mBPLYJcyw2qvG49HAqFBB6jsnI dZllGr+58tYUoYZcp2OKbKk3UeaMc0qVJazu5mK9EzCyyD+qq4JoziaWHqMZsc0g == X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvuddrudduvddgieehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne gfrhhlucfvnfffucdlfedtmdenucfjughrpefkuffhvfgtffggfgfgsehtkeertddtreej necuhfhrohhmpefoihhkhhgrihhlucfukhhorhiihhhinhhskhhiihcuoehmshhkohhrii hhihhnshhkihihsegvmhhlrdgttgeqnecuggftrfgrthhtvghrnhepueeihfefheeuudeh gedutdekvdeijeekveeltedtvdfhfefgueeufeffuefhleejnecuffhomhgrihhnpeifvg hllhdrohhrghdpmhgvshhsrghgvgdrohhrghenucevlhhushhtvghrufhiiigvpedtnecu rfgrrhgrmhepmhgrihhlfhhrohhmpehmshhkohhriihhihhnshhkihihsegvmhhlrdgttg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Sat, 25 Dec 2021 10:24:41 -0500 (EST) Message-ID: <645e9e94235057a7b8f4b541fe11677d6f74ccf8.camel@eml.cc> Subject: [PATCH] org-agenda.el: customise outline path in echo area From: Mikhail Skorzhinskii To: Org Mode Content-Type: text/plain; charset="UTF-8" Date: Sat, 25 Dec 2021 16:24:26 +0100 MIME-Version: 1.0 User-Agent: Evolution 3.40.0-1 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=66.111.4.26; envelope-from=mskorzhinskiy@eml.cc; helo=out2-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1640445968; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=VvxrsrFhE75hBPQoAs/j7rCCYhGsAQcmiPKh/XJAVxg=; b=cDXtWIOe4wjQ3iHE+/tldNOfMMjcZeU3Td7TcgQmU30Q9IHcm5IOYvqN+Jj9wRgFKSwMjg h1o6rY66xS5jeg9MMsSnYzSdstyBDocOmCiGkz6x/wHkp2JcEjH4asYDEHV5yoIVge3EnJ d7GfSDEbR/MRydTAi6iXh+rfqj3vSK7nrM2AheEJWI9BgZKHp290ULdu0eUVAjVnZdxJ03 eXGC7BMWRMEcpsnIlkcNAJTB8jpfMfUUruKTgUs5MzRsMzOopfs5eaMiagA9iCMQ7Tjv7y 6kXSsA0HvOsLp91wAIioNXQQKYewUBbykLTbC1mPI6CzZwfMsu4eHPzxchEctA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1640445968; a=rsa-sha256; cv=none; b=CZFYgVH6BJP/LsCcs8/yoSGud41FHt/vgIAHHqsuUeKi4QLO6vHTxW9RpOMaoI+JeKeN1m 3FrdWEXCD2qkYE7F+y3RHbUwo5QD4rRuNh01/dVfcoexcDWDG08OlnIg2+e9PZtZxdbgPi rOYCwTBCGgCcUzKrE/jlQJ1zPd/x+FswonNdKT9AWWREGMaQwLQxJGX7YxsB25Oppa1M5s nDe3J5+JG3w+sdJ6d+gCPs8v2pq9fLRbirQ+JhNXcVbsG5FjoAPCJJQOu40k82oQkzHJuo vIOWYNlNhjaE8XxuN4pPGRFDy4KzaZM1fuMDcX0gEpPWtTJT9DbbFEI7c7s7ag== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=eml.cc header.s=fm2 header.b=Q+JcSxkJ; dkim=pass header.d=messagingengine.com header.s=fm1 header.b=RDq97WJY; dmarc=pass (policy=none) header.from=eml.cc; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -7.56 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=eml.cc header.s=fm2 header.b=Q+JcSxkJ; dkim=pass header.d=messagingengine.com header.s=fm1 header.b=RDq97WJY; dmarc=pass (policy=none) header.from=eml.cc; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: CB9B3C015 X-Spam-Score: -7.56 X-Migadu-Scanner: scn0.migadu.com X-TUID: aUF/UB782hic * lisp/org-agenda.el (org-agenda-show-outline-path): add an option to show document title in outline path (instead of file name) * lisp/org.el (org-get-title-from-file): a function to collect the document title from the org-mode file * lisp/org.el (org-display-outline-path): add logic that will collect a document title and put it into the outline path if org-agenda-show-outline-path set to 'title ---  lisp/org-agenda.el | 11 ++++++++---  lisp/org.el        | 25 ++++++++++++++++++++++---  2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index 721ef2ced..817354659 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -1045,9 +1045,14 @@ current item's tree, in an indirect buffer."    :type 'boolean)    (defcustom org-agenda-show-outline-path t -  "Non-nil means show outline path in echo area after line motion." +  "Non-nil means show outline path in echo area after line motion. + +If set to 'title, show document title."    :group 'org-agenda-startup -  :type 'boolean) +  :type '(choice +         (const :tag "Don't show outline path in agenda view." nil) +         (const :tag "Show outline path with prepended file name." t) +         (const :tag "Show outline path with prepended document title. Fallback to file name is no title is present." title)))    (defcustom org-agenda-start-with-entry-text-mode nil    "The initial value of entry-text-mode in a newly created agenda window." @@ -9354,7 +9359,7 @@ When called with a prefix argument, include all archive files as well."                (org-agenda-tree-to-indirect-buffer nil)              (org-agenda-show)))        (and org-agenda-show-outline-path -          (org-with-point-at m (org-display-outline-path t)))))) +          (org-with-point-at m (org-display-outline-path org-agenda- show-outline-path))))))    (defun org-agenda-show-tags ()    "Show the tags applicable to the current item." diff --git a/lisp/org.el b/lisp/org.el index ce4e08eab..eab3aed3c 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -8166,10 +8166,24 @@ the default is \"/\"."         (setf (substring fpath (- width 2)) "..")))      fpath))   -(defun org-display-outline-path (&optional file current separator just-return-string) +(defun org-get-title-from-file (file) +  "Collect tilte from the provided `org-mode' FILE." +  (let (title) +    (when file +      (with-current-buffer +         (get-file-buffer file) +       (pcase (org-collect-keywords '("TITLE")) +         (`(("TITLE" . ,val)) +          (setq title (car val))))) +      title))) + + +(defun org-display-outline-path (&optional file-or-title current separator just-return-string)    "Display the current outline path in the echo area.   -If FILE is non-nil, prepend the output with the file name. +If FILE-OR-TITLE is 'title, prepend outline with file title.  If +it is non-nil or title is not present in document, prepend +outline path with the file name.  If CURRENT is non-nil, append the current heading to the output.  SEPARATOR is passed through to `org-format-outline-path'.  It separates  the different parts of the path and defaults to \"/\". @@ -8177,6 +8191,8 @@ If JUST-RETURN-STRING is non-nil, return a string, don't display a message."    (interactive "P")    (let* (case-fold-search          (bfn (buffer-file-name (buffer-base-buffer))) +        (title (when (and file-or-title (string= file-or-title 'title)) +                 (org-get-title-from-file bfn)))          (path (and (derived-mode-p 'org-mode) (org-get-outline-path)))          res)      (when current (setq path (append path @@ -8188,7 +8204,10 @@ If JUST-RETURN-STRING is non-nil, return a string, don't display a message."           (org-format-outline-path            path            (1- (frame-width)) -          (and file bfn (concat (file-name-nondirectory bfn) separator)) +          (and file-or-title bfn (concat (if (and (string= file-or- title 'title) title) +                                             title +                                           (file-name-nondirectory bfn)) +                                separator))            separator))      (add-face-text-property 0 (length res)                             `(:height ,(face-attribute 'default :height))