From: Mikhail Skorzhisnkii <mskorzhinskii@eml.cc>
To: Ihor Radchenko <yantar92@gmail.com>
Cc: Org Mode <emacs-orgmode@gnu.org>
Subject: Re: [PATCH] ox-icalendar.el: customizable vevent summary prefix
Date: Mon, 05 Sep 2022 20:50:48 +0200 [thread overview]
Message-ID: <87y1ux3awf.fsf@eml.cc> (raw)
In-Reply-To: <87v8q8obqs.fsf@localhost>
[-- Attachment #1: Type: text/plain, Size: 4938 bytes --]
Thanks for your comment, Ihor. I have addressed your comments, see some comments inline. Attaching new version of the patch.
Ihor Radchenko <yantar92@gmail.com> writes:
> Mikhail Skorzhisnkii <mskorzhinskii@eml.cc> writes:
>
>> I have signed FSF papers. Attaching a rebased patch with additional changes to
>> ORG-NEWS
>
> Thanks!
>
>> Subject: [PATCH 1/2] org-agenda.el: customize outline path in echo area
>>
>> * lisp/org-agenda.el (org-agenda-show-outline-path): add an option to
>> show document title in outline path (instead of file name)
>
> Please follow the commit message conventions as described in
> <https://orgmode.org/worg/org-contribute.html#commit-messages> In
> particular, start sentences from capital letters, end them with “.”,
> separate sentences with double space, and quote lisp symbols as
> `symbol’.
>
>> * lisp/org.el (org-get-title-from-buffer): a function to collect the
> New
>> document title from the org-mode buffer
> .
Sorry — missed these rules. Fixed now.
>> * 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
>
> This is not what the patch does. From this message, it looks like
> `org-agenda-show-outline-path’ is affecting the output of
> `org-display-outline-path’, which is not true.
Hm, for me it doesn’t look like it from my perspectrive, but my command of the
English is not that good. I have reworded it. Is it better now?
Feel free to reword it on final apply or let me know if you would like to
improve — I will someone to proofread it.
>> (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.”
>
> This is not very clear. I’d rather put more detailed explanation as in
> the defcustom :type spec below.
Fixed.
>> :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)))
>> -(defun org-display-outline-path (&optional file current separator just-return-string)
>> +(defun org-get-title-from-buffer (&optional buffer)
>> + “Collect title from the provided `org-mode’ BUFFER.”
>> + (let* ((buffer (or buffer (current-buffer)))
>> + (buffer (or (buffer-base-buffer buffer)
>> + buffer))
>
> Why not just
>
> (or (buffer-base-buffer buffer)
> buffer
> (current-buffer))
Applied your suggestion.
>> + title)
>> + (with-current-buffer buffer
>> + (pcase (org-collect-keywords ’(“TITLE”))
>> + (`((“TITLE” . ,val))
>> + (setq title (car val)))))
>> + title))
>
> Extra `title’ variable is unnecessary here. You can simply do
>
> (with-current-buffer buffer
> (pcase (org-collect-keywords ’(“TITLE”))
> (`((“TITLE” ,val . _))
> val)))
Indeed — remnant of previous implementation iteration. Applied your suggestion.
> Also, what will happen in a file like
>
> #+TITLE: Begin title
> #+TITLE: .. end title
>
> ?
Hm, never did this myself. Now concatenate the list of property values. I have
tested it and space as a separator looks good, if the intention of several
titles is to have one big title.
But what if several titles are title and subtitles? We can provide a way control
that behaviour, but my gut feeling that it would be a rather confusing.
>> +(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 \”/\“.
>> @@ -7407,6 +7421,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-prop (when (and file-or-title (eq file-or-title ’title))
>
> can be simply (eq file-or-title ’title)
Indeed. Fixed.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-agenda.el-customize-outline-path-in-echo-area.patch --]
[-- Type: text/x-diff, Size: 5685 bytes --]
From ebad0bb39221217233283905f39b99644b07f36b Mon Sep 17 00:00:00 2001
From: Mikhail Skorzhinskii <mskorzhinskii@eml.cc>
Date: Sat, 12 Sep 2020 18:10:05 +0200
Subject: [PATCH 1/2] org-agenda.el: customize outline path in echo area
* 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-buffer): A new function to collect the
document title from the org-mode buffer.
* lisp/org.el (org-display-outline-path): Show document title (#+TITLE
value) and outline path in echo area if customisation option is set to
'title. Fallback to file name if there is document title is absent.
---
etc/ORG-NEWS | 10 ++++++++++
lisp/org-agenda.el | 12 +++++++++---
lisp/org.el | 25 ++++++++++++++++++++++---
3 files changed, 41 insertions(+), 6 deletions(-)
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 7dae03dc6..529fea41a 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -290,6 +290,12 @@ level used for top level headings, much like how
headings in HTML export.
** 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:=.
+
*** A new custom setting =org-hide-drawer-startup= to control initial folding state of drawers
Previously, all the drawers were always folded when opening an Org
@@ -320,6 +326,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-from-buffer~ to get ~#+TITLE:~ property
+
+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-agenda.el b/lisp/org-agenda.el
index b98041ea8..aad7f279e 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -1058,9 +1058,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."
@@ -9424,7 +9430,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 858123e67..1babd5d8d 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -7396,10 +7396,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-buffer (&optional buffer)
+ "Collect title from the provided `org-mode' BUFFER.
+
+Returns nil if there are no #+TITLE property."
+ (let ((buffer (or (buffer-base-buffer)
+ buffer
+ (current-buffer))))
+ (with-current-buffer buffer
+ (pcase (org-collect-keywords '("TITLE"))
+ (`(("TITLE" . ,val))
+ (mapconcat 'identity val " "))))))
+
+(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 \"/\".
@@ -7407,6 +7421,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-prop (when (eq file-or-title 'title)
+ (org-get-title-from-buffer)))
(path (and (derived-mode-p 'org-mode) (org-get-outline-path)))
res)
(when current (setq path (append path
@@ -7418,7 +7434,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
next prev parent reply other threads:[~2022-09-05 19:06 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-25 15:24 [PATCH] ox-icalendar.el: customizable vevent summary prefix Mikhail Skorzhinskii
2021-12-26 21:26 ` Nicolas Goaziou
2021-12-28 12:10 ` Mikhail Skorzhinskii
2022-07-31 7:16 ` Ihor Radchenko
2022-07-31 7:35 ` Mikhail Skorzhinskiy
2022-07-31 13:02 ` Ihor Radchenko
2022-08-30 13:50 ` Mikhail Skorzhisnkii
2022-08-31 12:09 ` Ihor Radchenko
2022-09-05 18:50 ` Mikhail Skorzhisnkii [this message]
2022-09-08 5:40 ` Ihor Radchenko
2022-09-08 20:10 ` Mikhail Skorzhisnkii
2022-09-09 10:13 ` Ihor Radchenko
2022-10-23 19:15 ` Mikhail Skorzhisnkii
2022-10-25 6:59 ` Ihor Radchenko
2022-08-31 12:11 ` Ihor Radchenko
2022-09-01 7:29 ` Bastien
2022-08-31 12:13 ` Ihor Radchenko
2022-09-05 18:59 ` Mikhail Skorzhisnkii
2022-09-05 19:28 ` Mikhail Skorzhisnkii
2022-09-08 5:33 ` Ihor Radchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87y1ux3awf.fsf@eml.cc \
--to=mskorzhinskii@eml.cc \
--cc=emacs-orgmode@gnu.org \
--cc=yantar92@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).