From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id wCDuHDYTVmM8HwEAbAwnHQ (envelope-from ) for ; Mon, 24 Oct 2022 06:23:18 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id CIfbHDYTVmPxNgAA9RJhRA (envelope-from ) for ; Mon, 24 Oct 2022 06:23:18 +0200 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 50A2E29DC3 for ; Mon, 24 Oct 2022 06:23:17 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1omnJH-0005U1-IR; Sun, 23 Oct 2022 22:35:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1omgyG-0003lJ-5a for emacs-orgmode@gnu.org; Sun, 23 Oct 2022 15:49:20 -0400 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1omgyC-0003Ed-Op for emacs-orgmode@gnu.org; Sun, 23 Oct 2022 15:49:19 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 15FB75C008B; Sun, 23 Oct 2022 15:49:15 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Sun, 23 Oct 2022 15:49:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eml.cc; h=cc:cc :content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm3; t=1666554555; x=1666640955; bh=N9Fh5euV80 5dh/Fe7/Ieoo7UnzgXzG7gEe8X6I1kiow=; b=P2CXGcHMmndDA1S6MiLY/x3O49 f3LQc4BVTT5MA0bz6XZQZiflNj+WxZWzrNOM+dfnfURG5IAclvGbmabOoqa35f7t TprPbMK3ADowUtTlflIP4WE3P8gpzJUeswyz7QSJ+Ea3cxdcRJBlbu1o3moWLnDi urV5bR8JNrjgbwn3hClKU1L9R3Gua3luko8wbvsAwRvpixupA4yKpbqVke5Duq61 M9jFJrVxYpEkD6ORVBpbm/QzI0a2VaSvfHqdOITgNBP2cVQK+uqyxO2qYcnwxRtp 4E91IoVI0LY++nHAUcIKju0CptYpZBkDOZjk8Xku/yBC/rwrOIp8uxHg5SPw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1666554555; x=1666640955; bh=N9Fh5euV805dh/Fe7/Ieoo7UnzgX zG7gEe8X6I1kiow=; b=fTzwteaPm0p+Lc50/vak891TII7ADMEp0cz2KNlGB2lf sG5Z2pYjzPPCIDUIUjfjoaWoWKfO4Z6WLTpO7bmUsJDFT2UAxwSeROqFs0nUNXwF FDqfOIjR47FkqpTaESxPHfxagjnwKjnLvTCz/Kyi9oRh3dAPkzVSOT4+YnHDE2uc fKSCrLj2e6EdhEoBqt3X47HQtE9i2alRqBapyhg266fvcpB/B7Cj28pEe/XFLm3e rka7kt3jRDznmW40tPwMOvo3WZHMBxEs8rKjbqZkG/qTSCanLPh2DB8nJ2I1Wvnw NTQhTAP68WvYWLrUYZCOivwksFFijfyBoA+GXyWs8g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrgedtvddgudegudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enfghrlhcuvffnffculddutddmnecujfgurhephffvvefuffhffggjkfggtgesmhdtreer tderjeenucfhrhhomhepofhikhhhrghilhcuufhkohhriihhihhsnhhkihhiuceomhhskh horhiihhhinhhskhhiihesvghmlhdrtggtqeenucggtffrrghtthgvrhhnpedvgfduveek feeivedvkedtffffkefhjedvfeefheegheeihfdtvdetfefggfethfenucffohhmrghinh epohhrghhmohguvgdrohhrghdpghhnuhdrohhrghdpihhmphhlvghmvghnthgrthhiohhn rdhorhhgpdhsthgrnhgurghrughsrdhorhhgpdhthhhishdrohhrghenucevlhhushhtvg hrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehmshhkohhriihhihhnshhk ihhisegvmhhlrdgttg X-ME-Proxy: Feedback-ID: i171146f6:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 23 Oct 2022 15:49:14 -0400 (EDT) From: Mikhail Skorzhisnkii To: Ihor Radchenko Cc: Org Mode Subject: Re: [PATCH] ox-icalendar.el: customizable vevent summary prefix Date: Sun, 23 Oct 2022 21:15:10 +0200 References: <0a1b98af1974ec260c4074df056715e237c08fce.camel@eml.cc> <871r1zawhp.fsf@nicolasgoaziou.fr> <8451fcc20c68d9863a4613df5a1cd5dbba0a77cd.camel@eml.cc> <87h72xn44k.fsf@localhost> <25163bf9-2455-4790-b258-84e766813de3@www.fastmail.com> <87ilndl9jx.fsf@localhost> <87o7w1j0su.fsf@eml.cc> <87v8q8obqs.fsf@localhost> <87y1ux3awf.fsf@eml.cc> <875yhypgop.fsf@localhost> <871qslsjv2.fsf@eml.cc> <874jxgety7.fsf@localhost> User-agent: mu4e 1.8.7; emacs 28.2 In-reply-to: <874jxgety7.fsf@localhost> Message-ID: <878rl6wcbv.fsf@eml.cc> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=66.111.4.28; envelope-from=mskorzhinskii@eml.cc; helo=out4-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.01, RCVD_IN_MSPIKE_WL=-0.01, 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: , Sender: "Emacs-orgmode" Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org 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=1666585398; 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:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=p/lxwZvxNmxh947ye65urkrjxtgl25kFxwGrLGBEYdA=; b=p9AUDw1A1viOSg30OxkYYUM06kxWMPO2Rsf+EeR+5/5oYRZSiDAbhziqeT4Z9zBP8Lre3s wp1XCABPDgJeht2RyhprGqLpAarlCdJQTbEjk0HxiysbksHdbyx6ecrx3E9O/dhMtIVp5b BlnOyXm0EH01kOJIMJk5v/wQuoSGvPt0ycokXjFKxn6jWW2lsKNYUGrqJnYid36vc1FvSL 95EgkeGIesjVCeUyYso5DJzanMrjQUAHz0dqfugz3JOWxyV0bryOwXbE3TeCfmNqOUtSai y8RgPXK0JXDlwsfW7XPUUvLPAw8ohGqWSDKAO98kl/JBmpZ7xB7p5SloKF4igw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1666585398; a=rsa-sha256; cv=none; b=bGm1LoOHCjYmEPbr/FMY7RaACVK4EYMc59oIv4X68Cp02oww0HK9+wMPv2WxCA7lLUigi3 n4tBtEIX/+jElQfsZJXtcu5nOH56u0ZGJSe5hUTlWNoaxuPmAvbvqN67Gax6LqC3o03U5T Ru79glozsVe2PyrQvM5vCEcfSIIMZBy/CHffbS2DniXS64OlCDiDR7U8qXDpfzOhlSWrLw 5B8a0iG1xPFYOI21fNIn7yEf0iJHlAV0DM+7EAEnMTlWy+MbKNkOy3cfWj25yftIY0QiLE QZsvpPF0zdWT3IUduZQECkMpVy0BcEe0WnkcmxohwW3YFmWUnoqH8SZivXiFCw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=eml.cc header.s=fm3 header.b=P2CXGcHM; dkim=fail ("body hash did not verify") header.d=messagingengine.com header.s=fm3 header.b=fTzwteaP; dmarc=fail reason="SPF not aligned (relaxed)" header.from=eml.cc (policy=none); 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: 6.39 Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=eml.cc header.s=fm3 header.b=P2CXGcHM; dkim=fail ("body hash did not verify") header.d=messagingengine.com header.s=fm3 header.b=fTzwteaP; dmarc=fail reason="SPF not aligned (relaxed)" header.from=eml.cc (policy=none); 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: 50A2E29DC3 X-Spam-Score: 6.39 X-Migadu-Scanner: scn0.migadu.com X-TUID: +widjp2tWzVf --=-=-= Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi, Ihor, Sorry for the delay with fixes, took some time before I got time to finish = this. Thanks for your review and looking forward for the next iteration. Se= e new version in the attachment. Comments are inline. Ihor Radchenko writes: > Mikhail Skorzhisnkii writes: > >> Thank you for suggestion, I seen an announcement about this function, bu= t somehow forgot about it. >> >> Sending next version of these patches. Changes from the next version: > > Thanks! > >> Subject: [PATCH 3/3] org-refile.el: show refile targets with a title >> >> * lisp/org-refile.el (org-refile-get-targets): Use a document >> title (#+TITLE) instead of file or buffer name in outline path, if >> a corresponding customisation option is set to =E2=80=99title. Fallback = to a >> filename if there is no title in the document. > > Please use 2 spaces between sentences in docstrings, comments, and > commit messages. Also, end sentences with =E2=80=9C.=E2=80=9D. See > and > > Fixed. >> (defcustom org-outline-path-complete-in-steps t >> =E2=80=9CNon-nil means complete the outline path in hierarchical step= s. >> @@ -319,6 +320,11 @@ converted to a headline before refiling.=E2=80=9D >> (push (list (and (buffer-file-name (buffer-base-buffer)) >> (file-truename (buffer-file-name (buf= fer-base-buffer)))) >> f nil nil) tgs)) >> + (when (eq org-refile-use-outline-path =E2=80=99title) >> + (push (list (or (org-get-title) >> + (and f (file-name-nondirectory f))) >> + f nil nil) >> + tgs)) > > We have very too many whens in this function. It will be more succinct > to use a single (pcase org-refile-use-outline-path =E2=80=A6) instead. Yes. But then I will be refactoring quite a lot of (working) code that I ha= ve not actually touching. I would prefer doing that in the separate patch. You=E2=80=99ve suggested s= ome changes in my patches which could be applied to some other places in or= g-mode files I have seen. May be once we finish this discussion I would sen= d a new series of patches with restyling? >> + ;; When `org-refile-use-outline-path=E2=80=99 is `title=E2=80=99, ret= urn extracted >> + ;; document title >> + (should >> + (equal =E2=80=99(=E2=80=9CT=E2=80=9D =E2=80=9CT/H1=E2=80=9D) >> + (org-test-with-temp-text-in-file =E2=80=9C#+title: T\n* H1=E2=80=9D > > You may as well add a test when multiple #+title lines are present. Added. >> From 62684b478ae5ceb03f66967fbebcc4d6163c826c Mon Sep 17 00:00:00 2001 >> From: Mikhail Skorzhinskii >> Date: Sat, 12 Sep 2020 18:10:05 +0200 >> Subject: [PATCH 2/3] org-agenda.el: show document title in outline path > ^Show Fixed. >> * lisp/org.el (org-display-outline-path): Show a document title (#+TITLE >> value) and an outline path in an echo area if the customisation option >> is set to =E2=80=99title. Fallback to a file or a buffer name if the doc= ument > ^ Fallback ;; (double space between sentences) Fixed. >> title is absent. > >> ** New options >> -*** New custom settings `org-icalendar-scheduled-summary-prefix' and `o= rg-icalendar-deadline-summary-prefix' > > This is removing an existing NEWS entry. I guess it is not intentional. Yes. Sorry about that =E2=80=94 fixed. >> +*** A new option for custom setting `org-agenda-show-outline-path' to s= how document title >> >> (defcustom org-agenda-show-outline-path t >> - =E2=80=9CNon-nil means show outline path in echo area after line moti= on.=E2=80=9D >> + =E2=80=9CNon-nil means show outline path in echo area after line moti= on. >> + >> +If set to =E2=80=98title, show outline path with prepended document >> +title. Fallback to file name is no title is present.=E2=80=9D >> :group =E2=80=99org-agenda-startup >> - :type =E2=80=99boolean) >> + :type =E2=80=99(choice >> + (const :tag =E2=80=9CDon=E2=80=99t show outline path in agenda view.= =E2=80=9D nil) >> + (const :tag =E2=80=9CShow outline path with prepended file name.=E2= =80=9D t) >> + (const :tag =E2=80=9CShow outline path with prepended document title= . Fallback to file name is no title is present.=E2=80=9D title))) > > I think you can leave > (const :tag =E2=80=9CShow outline path with prepended document title.=E2= =80=9D title) > > This text will be displayed in drop menu in cutomize interface alongside > with the full docstring. Mentioning the fallback in the docstring should > be good enough. Agreed. Fixed. >> From 5b15f886b22dc542220b48ae9659c4c2d56dea78 Mon Sep 17 00:00:00 2001 >> From: Mikhail Skorzhinskii >> Date: Thu, 8 Sep 2022 21:29:23 +0200 >> Subject: [PATCH 1/3] org-clock.el: rename org-clock-get-file-title > ^Rename Fixed. >> * lisp/org.el (org-get-title): A new function to collect a document >> title from an org-mode buffer, based on a org-clock-get-file-title >> implementation. > > `org-clock-get-file-title=E2=80=99. Elisp symbols should be quoted. Done. (on a side note, all my email clients show ` and =E2=80=99 quite diff= erently. I wonder why.) >> ** New functions and changes in function arguments >> +*** New function `org-get-title' to get `#+TITLE:' property from buffers > > We generally use `code' for Elisp symbols and `#+TITLE:' for verbatim > non-code text. (This has not been consistently followed in etc/NEWS, but > at least please change `#+TITLE' to `#+TITLE'). See > doc/Documentation_Standards.org Ah, yes. There are many occasions in the ORG-NEWS where this is not followe= d. Would you be interested in the patch fixing these irregularities? And if you do, would you prefer to have a fixed-up commits for these ones o= r just one big commit? I recently learned about existence of git absorb and= couldn=E2=80=99t recommend it enough. >> ** Removed or renamed functions and variables >> +*** Rename `org-clock-get-file-title' to `org-get-file-title' >> + >> +This function is now part of the `org.el' file. > > You do not need to mention this. org-clock-get-file-title was > introduced in recent commits on main. Main is development branch, and we > do not need to document changes on the changes made after the last > release. OK. Fixed, left only a note about new function. I would say some users may = find it interesting. I had a function that extracts title for many-many yea= rs. Used it for displaying document title in the frame title. >> ;;;###autoload >> (defun org-dblock-write:clocktable (params) >> =E2=80=9CWrite the standard clocktable.=E2=80=9D >> @@ -2739,7 +2729,7 @@ from the dynamic block definition.=E2=80=9C >> =E2=80=9D\n=E2=80=9C) >> >> (if filetitle >> - (org-clock-get-file-title file-name) >> + (org-get-file-title file-name) >> (file-name-nondirectory file-name)) >> (if level? =E2=80=9D| =E2=80=9C =E2=80=9D=E2=80=9C) ;level co= lumn, maybe >> (if timestamp =E2=80=9D| =E2=80=9C =E2=80=9D=E2=80=9C) ;timestam= p column, maybe > > This may introduce a compiler warning. I suggest running make after > applying your patch and fix possible compiler warnings. (I suspect that > you may need to add declare-function on top of org-clock.el) Hm, I have tried it on the latest stable emacs (28.2) and it does not produ= ce me a warning. `make compile' was just clean. Could you please refer me t= o the library/documentation why would I need to call `declare-function'? Th= is is something from cl library? >> +(defun org-get-file-title (file-name) >> + =E2=80=9CCollect title from `org-mode=E2=80=99 FILE-NAME. >> + >> +Return file name if title does not exist.=E2=80=9D >> + (or (org-get-title (find-file-noselect file-name)) >> + (file-name-nondirectory file-name))) >> + >> +(defun org-get-title (&optional buffer) >> + =E2=80=9CCollect title from the provided `org-mode=E2=80=99 BUFFER. >> + >> +Returns nil if there are no #+TITLE property.=E2=80=9D >> + (let ((buffer (or (buffer-base-buffer) >> + buffer >> + (current-buffer)))) >> + (with-current-buffer buffer >> + (org-macro-initialize-templates) >> + (let ((title (assoc-default =E2=80=9Ctitle=E2=80=9D org-macro-tem= plates))) >> + (unless (string=3D =E2=80=9C=E2=80=9D title) >> + title))))) > > These two functions can be merged into a single `org-get-title=E2=80=99 t= hat > accepts buffer or file-name as an optional argument. Merged, but a little bit differently. Now the function accepts buffer or fi= le. Also, I removed the basebuffer logic, because this logic is already inc= luded in the `org-macro-initialize-templates'. Thanks, Mikhail Skorzhinskii --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0003-org-refile.el-Show-refile-targets-with-a-title.patch >From 870f01312242fcbc56a66efb3a10d5bcf42144d6 Mon Sep 17 00:00:00 2001 From: Mikhail Skorzhinskii Date: Mon, 21 Sep 2020 14:53:13 +0200 Subject: [PATCH 3/3] org-refile.el: Show refile targets with a title * lisp/org-refile.el (org-refile-get-targets): Use a document title (#+TITLE) instead of file or buffer name in outline path, if a corresponding customisation option is set to 'title. Fallback to a filename if there is no title in the document. * lisp/org-refile.el (org-refile-use-outline-path): Add a new option 'title, see above. --- etc/ORG-NEWS | 6 +++++ lisp/org-refile.el | 17 ++++++++++--- testing/lisp/test-org.el | 55 +++++++++++++++++++++++++++++++++++++++- 3 files changed, 74 insertions(+), 4 deletions(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 7b64f1b9d..2a2501c45 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -324,6 +324,12 @@ value of ~org-babel-clojure-backend~. For example: #+end_src ** New options +*** A new option for custom setting ~org-refile-use-outline-path~ to show document title in refile targets + +Setting ~org-refile-use-outline-path~ to ~'title~ will show title +instead of the file name in refile targets. If the documen do not have +a title, the filename will be used, similar to ~'file~ option. + *** A new option for custom setting ~org-agenda-show-outline-path~ to show document title Setting ~org-agenda-show-outline-path~ to ~'title~ will show title diff --git a/lisp/org-refile.el b/lisp/org-refile.el index edab0b225..6dd76d380 100644 --- a/lisp/org-refile.el +++ b/lisp/org-refile.el @@ -160,7 +160,8 @@ When `buffer-name', use the buffer name." (const :tag "Yes" t) (const :tag "Start with file name" file) (const :tag "Start with full file path" full-file-path) - (const :tag "Start with buffer name" buffer-name))) + (const :tag "Start with buffer name" buffer-name) + (const :tag "Start with document title" title))) (defcustom org-outline-path-complete-in-steps t "Non-nil means complete the outline path in hierarchical steps. @@ -319,6 +320,11 @@ converted to a headline before refiling." (push (list (and (buffer-file-name (buffer-base-buffer)) (file-truename (buffer-file-name (buffer-base-buffer)))) f nil nil) tgs)) + (when (eq org-refile-use-outline-path 'title) + (push (list (or (org-get-title) + (and f (file-name-nondirectory f))) + f nil nil) + tgs)) (org-with-wide-buffer (goto-char (point-min)) (setq org-outline-path-cache nil) @@ -345,7 +351,12 @@ converted to a headline before refiling." (and (buffer-file-name (buffer-base-buffer)) (file-name-nondirectory (buffer-file-name (buffer-base-buffer)))))) - (`full-file-path + (`title (list + (or (org-get-title) + (and (buffer-file-name (buffer-base-buffer)) + (file-name-nondirectory + (buffer-file-name (buffer-base-buffer))))))) + (`full-file-path (list (buffer-file-name (buffer-base-buffer)))) (`buffer-name @@ -633,7 +644,7 @@ this function appends the default value from (tbl (mapcar (lambda (x) (if (and (not (member org-refile-use-outline-path - '(file full-file-path))) + '(file full-file-path title))) (not (equal filename (nth 1 x)))) (cons (concat (car x) extra " (" (file-name-nondirectory (nth 1 x)) ")") diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el index 4a6a3a0b0..334022c98 100644 --- a/testing/lisp/test-org.el +++ b/testing/lisp/test-org.el @@ -6821,7 +6821,60 @@ Paragraph" (org-test-with-temp-text "* H1" (let* ((org-refile-use-outline-path 'buffer-name) (org-refile-targets `((nil :level . 1)))) - (member (buffer-name) (mapcar #'car (org-refile-get-targets))))))) + (member (buffer-name) (mapcar #'car (org-refile-get-targets)))))) + ;; When `org-refile-use-outline-path' is `title', return extracted + ;; document title + (should + (equal '("T" "T/H1") + (org-test-with-temp-text-in-file "#+title: T\n* H1" + (let* ((org-refile-use-outline-path 'title) + (org-refile-targets `((nil :level . 1)))) + (mapcar #'car (org-refile-get-targets)))))) + ;; When `org-refile-use-outline-path' is `title' validate that + ;; deeper levels are correctly reported too (the same behaviour as + ;; 'file) + (should + (equal '("T" "T/H1" "T/H1/H2" "T/H1/H2/H3" "T/H1") + (org-test-with-temp-text-in-file "#+title: T\n* H1\n** H2\n*** H3\n* H1" + (let ((org-refile-use-outline-path 'title) + (org-refile-targets `((nil :maxlevel . 3)))) + (mapcar #'car (org-refile-get-targets)))))) + ;; When `org-refile-use-outline-path' is `title' and document do not + ;; have an extracted document title, return just the file name + (should + (org-test-with-temp-text-in-file "* H1" + (let* ((filename (buffer-file-name)) + (org-refile-use-outline-path 'title) + (org-refile-targets `((nil :level . 1)))) + (member (file-name-nondirectory filename) + (mapcar #'car (org-refile-get-targets)))))) + ;; When `org-refile-use-outline-path' is `title' and document is a + ;; temporary buffer without a file, it is still possible to extract + ;; a title + (should + (equal '("T" "T/H1") + (org-test-with-temp-text "#+title: T\n* H1\n** H2" + (let* ((org-refile-use-outline-path 'title) + (org-refile-targets `((nil :level . 1)))) + (mapcar #'car (org-refile-get-targets)))))) + ;; When `org-refile-use-outline-path' is `title' and there are two + ;; title keywords in the file, titles are concatenated into a single + ;; one. + (should + (equal '("T1 T2" "T1 T2/H1") + (org-test-with-temp-text "#+title: T1\n#+title: T2\n* H1\n** H2" + (let* ((org-refile-use-outline-path 'title) + (org-refile-targets `((nil :level . 1)))) + (mapcar #'car (org-refile-get-targets)))))) + ;; When `org-refile-use-outline-path' is `title' and there are two + ;; title keywords in the file, titles are concatenated into a single + ;; one even if they are in the middle of the file. + (should + (equal '("T1 T2" "T1 T2/H1") + (org-test-with-temp-text "#+title: T1\n* H1\n** H2\n#+title: T2\n" + (let* ((org-refile-use-outline-path 'title) + (org-refile-targets `((nil :level . 1)))) + (mapcar #'car (org-refile-get-targets))))))) -- 2.35.1 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0002-org-agenda.el-Show-document-title-in-outline-path.patch >From 12da8c1ccd1efa9c4f1282d213a46f93bf10410d Mon Sep 17 00:00:00 2001 From: Mikhail Skorzhinskii Date: Sat, 12 Sep 2020 18:10:05 +0200 Subject: [PATCH 2/3] org-agenda.el: Show document title in outline path * lisp/org-agenda.el (org-agenda-show-outline-path): Add an option to show a document title at start of an outline path, instead of a file or a buffer name. * lisp/org.el (org-display-outline-path): Show a document title (#+TITLE value) and an outline path in an echo area if the customisation option is set to 'title. Fallback to a file or a buffer name if the document title is absent. --- etc/ORG-NEWS | 6 ++++++ lisp/org-agenda.el | 12 +++++++++--- lisp/org.el | 12 +++++++++--- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index e96aa482b..7b64f1b9d 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -324,6 +324,12 @@ value of ~org-babel-clojure-backend~. For example: #+end_src ** New options +*** A new option for custom setting ~org-agenda-show-outline-path~ to show document title + +Setting ~org-agenda-show-outline-path~ to ~'title~ will show title +instead of the file name at the beginning of the outline. The title of +the document can be set by special keyword =#+title:=. + *** New custom settings =org-icalendar-scheduled-summary-prefix= and =org-icalendar-deadline-summary-prefix= These settings allow users to define prefixes for exported summary diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index 3bac53965..6c0be68ac 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -1068,9 +1068,15 @@ 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 outline path with prepended document +title. Fallback to file name is no title is present." :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." title))) (defcustom org-agenda-start-with-entry-text-mode nil "The initial value of entry-text-mode in a newly created agenda window." @@ -9468,7 +9474,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 f51e6d6d9..e93a81210 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -7437,10 +7437,12 @@ Returns nil if there are no #+TITLE property." (unless (string= "" title) title))))) -(defun org-display-outline-path (&optional file current separator just-return-string) +(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 \"/\". @@ -7448,6 +7450,7 @@ 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-prop (when (eq file-or-title 'title) (org-get-title))) (path (and (derived-mode-p 'org-mode) (org-get-outline-path))) res) (when current (setq path (append path @@ -7459,7 +7462,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 (eq file-or-title 'title) title-prop) + title-prop + (file-name-nondirectory bfn)) + separator)) separator)) (add-face-text-property 0 (length res) `(:height ,(face-attribute 'default :height)) -- 2.35.1 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-org-clock.el-Rename-org-clock-get-file-title.patch >From 669bb68aae3da16d0336bb7e6e1950bb716c8719 Mon Sep 17 00:00:00 2001 From: Mikhail Skorzhinskii Date: Thu, 8 Sep 2022 21:29:23 +0200 Subject: [PATCH 1/3] org-clock.el: Rename org-clock-get-file-title * lisp/org.el (org-get-title): A new function to collect a document title from an org-mode buffer, based on a `org-clock-get-file-title' implementation. * lisp/org-clock.el (org-clock-get-file-title): Removed --- etc/ORG-NEWS | 4 ++++ lisp/org-clock.el | 13 ++----------- lisp/org.el | 14 ++++++++++++++ 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index c18c03725..e96aa482b 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -361,6 +361,10 @@ event time when the alarm time is set to 0. The default value is nil -- do not create alarms at the event time. ** New functions and changes in function arguments +*** New function ~org-get-title~ to get =#+TITLE:= property from buffers + +A function to collect the document title from the org-mode buffer. + *** ~org-fold-show-entry~ does not fold drawers by default anymore ~org-fold-show-entry~ now accepts an optional argument HIDE-DRAWERS. diff --git a/lisp/org-clock.el b/lisp/org-clock.el index 6332399bb..e98a34f0d 100644 --- a/lisp/org-clock.el +++ b/lisp/org-clock.el @@ -2484,16 +2484,6 @@ the currently selected interval size." (org-update-dblock) t))))) -(defun org-clock-get-file-title (file-name) - "Get the file title from FILE-NAME as a string. -Return short FILE-NAME if #+title keyword is not found." - (with-current-buffer (find-file-noselect file-name) - (org-macro-initialize-templates) - (let ((title (assoc-default "title" org-macro-templates))) - (if (null title) - (file-name-nondirectory file-name) - title)))) - ;;;###autoload (defun org-dblock-write:clocktable (params) "Write the standard clocktable." @@ -2750,7 +2740,8 @@ from the dynamic block definition." "\n") (if filetitle - (org-clock-get-file-title file-name) + (or (org-get-title file-name) + (file-name-nondirectory file-name)) (file-name-nondirectory file-name)) (if level? "| " "") ;level column, maybe (if timestamp "| " "") ;timestamp column, maybe diff --git a/lisp/org.el b/lisp/org.el index 8191f0860..f51e6d6d9 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -7423,6 +7423,20 @@ the default is \"/\"." (setf (substring fpath (- width 2)) ".."))) fpath)) +(defun org-get-title (&optional buffer-or-file) + "Collect title from the provided `org-mode' BUFFER-OR-FILE. + +Returns nil if there are no #+TITLE property." + (let ((buffer (cond ((bufferp buffer-or-file) buffer-or-file) + ((stringp buffer-or-file) (find-file-noselect + buffer-or-file)) + (t (current-buffer))))) + (with-current-buffer buffer + (org-macro-initialize-templates) + (let ((title (assoc-default "title" org-macro-templates))) + (unless (string= "" title) + title))))) + (defun org-display-outline-path (&optional file current separator just-return-string) "Display the current outline path in the echo area. -- 2.35.1 --=-=-=--