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 * 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 | 9 ++++----- lisp/org-agenda.el | 12 +++++++++--- lisp/org.el | 12 +++++++++--- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index 44f0024fb..8f57d252f 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -295,12 +295,11 @@ Use the header argument =:var x=code-block[]= or to pass the contents of a named code block as a string argument. ** New options -*** New custom settings =org-icalendar-scheduled-summary-prefix= and =org-icalendar-deadline-summary-prefix= +*** A new option for custom setting =org-agenda-show-outline-path= to show document title -These settings allow users to define prefixes for exported summary -lines in ICS exports. The customization can be used to disable -the prefixes completely or make them a little bit more verbose -(e.g. "Deadline: " instead of the default "DL: "). +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:=. *** A new custom setting =org-hide-drawer-startup= to control initial folding state of drawers diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el index 053232078..c817aefd0 100644 --- a/lisp/org-agenda.el +++ b/lisp/org-agenda.el @@ -1061,9 +1061,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. 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." @@ -9427,7 +9433,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 f3f9c4096..c2b8a2a40 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -7429,10 +7429,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 \"/\". @@ -7440,6 +7442,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 @@ -7451,7 +7454,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