From: Mikhail Skorzhinskii <mskorzhinskiy@eml.cc>
To: emacs-orgmode@gnu.org, Ihor Radchenko <yantar92@gmail.com>
Subject: Re: [PATCHES 1, 2, 3/3] Minor customisation features for ox-icalendar and agenda
Date: Mon, 21 Sep 2020 13:29:18 +0200 [thread overview]
Message-ID: <3220650.xNLfXBERsm@trex230> (raw)
In-Reply-To: <50347242.HVZoFjIeJc@trex230>
[-- Attachment #1: Type: text/plain, Size: 15141 bytes --]
Resending the patch. There were missing parenthesis. And I didn't test build
after modification. Fixed and retested.
Mikhail
On Monday, September 21, 2020 10:23:39 AM CEST Mikhail Skorzhinskii wrote:
> On Wednesday, September 16, 2020 4:15:20 AM CEST Ihor Radchenko wrote:
> > > 1. Show document title instead of file name in org-agenda;
> > >
> > > This should be useful for any users of org-roam package or anyone who
> > > autogenerate file names and uses document titles instead for navigation.
> >
> > Interesting idea. This may also be useful as an option to
> > `org-refile-use-outline-path'. Currently, its value may be 'file to
> > prepend file names to the outline paths in refile targets. Using
> > document title (i.e. when the variable is set to 'title) in the refile
> > paths may also be handy.
>
> This is indeed better way.
>
> Fixed.
>
> Thanks,
> Mikhail
>
> > Best,
> > Ihor
> >
> > Mikhail Skorzhinskii <mskorzhinskiy@eml.cc> writes:
> > > Hello forum,
> > >
> > > I'd like to introduce three new features and request to merge the with
> > > current master:
> > >
> > > 1. Show document title instead of file name in org-agenda;
> > >
> > > This should be useful for any users of org-roam package or anyone who
> > > autogenerate file names and uses document titles instead for navigation.
> > >
> > > 2. Customise summary lines of exported events in ox-icalendar
> > >
> > > I personally export deadlines and scheduled items to the separate files
> > > so
> > > I don't need these cookies and they consume precious space of summary
> > > line. So I prefer them be disabled. This should be possible to do now
> > > with only customisation setting.
> > >
> > > 3. Force creation of an alarm when exporting event in ox-icalendar
> > >
> > > Sometimes I prefer to create icalendar alarms exactly at the event
> > > start,
> > > but it's not possible since alarm set to zero means that alarm will be
> > > disabled. Forcing alarm creation will now create alarm no matter the
> > > setting.
> > >
> > > I've updated news files and attempted to replicate the style of
> > > submissions, but I admit that I didn't read much beyond CONTRIBUTE file.
> > > Please point me to the right direction in case of any issues I can fix.
> > >
> > > Kind regards,
> > > Mikhail Skorzhinskii
> > >
> > > From 111e6886564abbf3becb2a94e66f235f502b79d9 Mon Sep 17 00:00:00 2001
> > > From: Mikhail Skorzhinskii <mskorzhinskiy@eml.cc>
> > > Date: Sat, 12 Sep 2020 18:52:39 +0200
> > > Subject: [PATCH 3/3] ox-icalendar.el: introduce setting to force alarms
> > >
> > > This is a new setting for icalendar exports to allow users set alarms
> > > exactly at the event start. With this setting set to non-nil and alarm
> > > set to zero (by global setting or APPT_WARNTIME property) it will create
> > > an alarm at the event start.
> > >
> > > Note, that zero alarm set as APPT_WARNTIME property will override
> > > default warning time.
> > > ---
> > >
> > > etc/ORG-NEWS | 10 ++++++++++
> > > lisp/ox-icalendar.el | 24 +++++++++++++++++++++---
> > > 2 files changed, 31 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
> > > index b912e807d..eb950d934 100644
> > > --- a/etc/ORG-NEWS
> > > +++ b/etc/ORG-NEWS
> > > @@ -23,6 +23,16 @@ path.
> > >
> > > Through these new options for icalendar export, one can customise the
> > > looks of summary lines in exported events.
> > >
> > > +*** New option ~org-icalendar-force-alarm~
> > > +
> > > +This is a new setting for icalendar exports to allow users set alarms
> > > +exactly at the event start. With this setting set to non-nil and alarm
> > > +set to zero (by global setting or APPT_WARNTIME property) it will
> > > +create an alarm at the event start.
> > > +
> > > +Note, that zero alarm set as =APPT_WARNTIME= property will override
> > > +default warning time.
> > > +
> > >
> > > * Version 9.4
> > > ** Incompatible changes
> > > *** Possibly broken internal file links: please check and fix
> > >
> > > diff --git a/lisp/ox-icalendar.el b/lisp/ox-icalendar.el
> > > index f110a4b2b..baed925e8 100644
> > > --- a/lisp/ox-icalendar.el
> > > +++ b/lisp/ox-icalendar.el
> > > @@ -64,6 +64,15 @@ for timed events. If non-zero, alarms are created.
> > >
> > > :version "24.1"
> > > :type 'integer)
> > >
> > > +(defcustom org-icalendar-force-alarm nil
> > > + "Non-nil means alarm will be created even if is set to zero.
> > > +
> > > +This overrides default behaviour where zero means no alarm. With
> > > +this set to non-nil and alarm set to zero, alarm will be created
> > > +and will fire at the event start."
> > > + :group 'org-export-icalendar
> > > + :type 'bool)
> > > +
> > >
> > > (defcustom org-icalendar-combined-name "OrgMode"
> > >
> > > "Calendar name for the combined iCalendar representing all agenda
> > > files."
> > >
> > > :group 'org-export-icalendar
> > >
> > > @@ -797,8 +806,11 @@ Return VALARM component as a string, or nil if it
> > > isn't allowed.">
> > >
> > > (let ((alarm-time
> > >
> > > (let ((warntime
> > >
> > > (org-element-property :APPT_WARNTIME entry)))
> > >
> > > - (if warntime (string-to-number warntime) 0))))
> > > - (and (or (> alarm-time 0) (> org-icalendar-alarm-time 0))
> > > + (if warntime (string-to-number warntime) nil))))
> > > + (and (or (and alarm-time
> > > + (> alarm-time 0))
> > > + (> org-icalendar-alarm-time 0)
> > > + org-icalendar-force-alarm)
> > >
> > > (org-element-property :hour-start timestamp)
> > > (format "BEGIN:VALARM
> > >
> > > ACTION:DISPLAY
> > >
> > > @@ -806,7 +818,13 @@ DESCRIPTION:%s
> > >
> > > TRIGGER:-P0DT0H%dM0S
> > > END:VALARM\n"
> > >
> > > summary
> > >
> > > - (if (zerop alarm-time) org-icalendar-alarm-time
>
> alarm-time)))))
>
> > > + (if org-icalendar-force-alarm
> > > + (if alarm-time
> > > + alarm-time
> > > + org-icalendar-alarm-time)
> > > + (if (zerop alarm-time)
> > > + org-icalendar-alarm-time
> > > + alarm-time))))))
> > >
> > > ;;;; Template
> > >
> > > From 1c30be14e2e7a6774d499388ec207b1950963746 Mon Sep 17 00:00:00 2001
> > > From: Mikhail Skorzhinskii <mskorzhinskiy@eml.cc>
> > > Date: Sat, 12 Sep 2020 18:27:23 +0200
> > > Subject: [PATCH 2/3] ox-icalendar.el: allow to customise deadline and
> > >
> > > scheduled items summary
> > >
> > > In some of export schemes these cookies at the start of each event can
> > > be a distraction rather then storage of useful information.
> > > ---
> > >
> > > etc/ORG-NEWS | 5 +++++
> > > lisp/ox-icalendar.el | 10 ++++++++--
> > > 2 files changed, 13 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
> > > index 32f64d84e..b912e807d 100644
> > > --- a/etc/ORG-NEWS
> > > +++ b/etc/ORG-NEWS
> > > @@ -18,6 +18,11 @@ When set to 'title, will show document title in
> > > outline
> > > path in echo>
> > >
> > > area instead of file name. When set to nil will show only outline
> > > path.
> > >
> > > +*** New options ~org-icalendar-scheduled-summary-prepend~ and
> > > ~org-icalendar-deadline-summary-prepend~ +
> > > +Through these new options for icalendar export, one can customise the
> > > +looks of summary lines in exported events.
> > > +
> > >
> > > * Version 9.4
> > > ** Incompatible changes
> > > *** Possibly broken internal file links: please check and fix
> > >
> > > diff --git a/lisp/ox-icalendar.el b/lisp/ox-icalendar.el
> > > index 0f890534a..f110a4b2b 100644
> > > --- a/lisp/ox-icalendar.el
> > > +++ b/lisp/ox-icalendar.el
> > > @@ -82,6 +82,12 @@ keyword."
> > >
> > > :group 'org-export-icalendar
> > > :type '(repeat (string :tag "Tag")))
> > >
> > > +(defcustom org-icalendar-scheduled-summary-prepend "S: "
> > > + "String used for prepending summary in exported scheduled
> > > headlines.")
> > > +
> > > +(defcustom org-icalendar-deadline-summary-prepend "DL: "
> > > + "String used for prepending summary in exported deadlines.")
> > > +
> > >
> > > (defcustom org-icalendar-use-deadline '(event-if-not-todo todo-due)
> > >
> > > "Contexts where iCalendar export should use a deadline time stamp.
> > >
> > > @@ -606,7 +612,7 @@ inlinetask within the section."
> > >
> > > (_ (memq 'event-if-not-todo use-deadline)))
> > >
> > > (org-icalendar--vevent
> > >
> > > entry deadline (concat "DL-" uid)
> > >
> > > - (concat "DL: " summary) loc desc cat tz class)))
> > > + (concat org-icalendar-deadline-summary-prepend
>
> summary) loc desc cat
>
> > > tz class)))>
> > >
> > > (let ((scheduled (org-element-property :scheduled entry))
> > >
> > > (use-scheduled (plist-get info :icalendar-use-
>
> scheduled)))
>
> > > (and scheduled
> > >
> > > @@ -617,7 +623,7 @@ inlinetask within the section."
> > >
> > > (_ (memq 'event-if-not-todo use-scheduled)))
> > >
> > > (org-icalendar--vevent
> > >
> > > entry scheduled (concat "SC-" uid)
> > >
> > > - (concat "S: " summary) loc desc cat tz class)))
> > > + (concat org-icalendar-scheduled-summary-prepend
>
> summary) loc desc cat
>
> > > tz class)))>
> > >
> > > ;; When collecting plain timestamps from a headline and its
> > > ;; title, skip inlinetasks since collection will happen once
> > > ;; ENTRY is one of them.
> > >
> > > From 6468b0402bf55ee21eb199395e41bc706fa17354 Mon Sep 17 00:00:00 2001
> > > From: Mikhail Skorzhinskii <mskorzhinskiy@eml.cc>
> > > Date: Sat, 12 Sep 2020 18:10:05 +0200
> > > Subject: [PATCH 1/3] org-agenda.el: allow to customize outline path in
> > > echo
> > >
> > > area
> > >
> > > Some of the org-mode data bases auto-generate file names, so they don't
> > > carry a lot of information and can be noisy. Allowing user to show
> > > document titles instead could be useful. Showing titles is disabled by
> > > default.
> > > ---
> > >
> > > etc/ORG-NEWS | 7 +++++++
> > > lisp/org-agenda.el | 10 +++++++++-
> > > lisp/org.el | 25 ++++++++++++++++++++++---
> > > 3 files changed, 38 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
> > > index 0ed626fb7..32f64d84e 100644
> > > --- a/etc/ORG-NEWS
> > > +++ b/etc/ORG-NEWS
> > > @@ -11,6 +11,13 @@ See the end of the file for license conditions.
> > >
> > > Please send Org bug reports to mailto:emacs-orgmode@gnu.org.
> > >
> > > * Version 9.5 (not yet released)
> > >
> > > +** New options and settings
> > > +*** New option ~org-agenda-show-outline-path-prepend~
> > > +
> > > +When set to 'title, will show document title in outline path in echo
> > > +area instead of file name. When set to nil will show only outline
> > > +path.
> > > +
> > >
> > > * Version 9.4
> > > ** Incompatible changes
> > > *** Possibly broken internal file links: please check and fix
> > >
> > > diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
> > > index 82fe6091c..25c9051e2 100644
> > > --- a/lisp/org-agenda.el
> > > +++ b/lisp/org-agenda.el
> > > @@ -1044,6 +1044,14 @@ current item's tree, in an indirect buffer."
> > >
> > > :group 'org-agenda-startup
> > > :type 'boolean)
> > >
> > > +(defcustom org-agenda-show-outline-path-prepend t
> > > + "Non-nil means show outline path with document title (if present) in
> > > echo area instead of file name." + :group 'org-agenda-startup
> > > + :type '(choice
> > > + (const :tag "Show only outline path without file name or document
> > > title." nil) + (const :tag "Prepend outline path with file name."
>
> t)
>
> > > + (const :tag "Prepend outline path with title name. 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."
> > >
> > > :group 'org-agenda-startup
> > >
> > > @@ -8777,7 +8785,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-prepend))))))>
> > >
> > > (defun org-agenda-show-tags ()
> > >
> > > "Show the tags applicable to the current item."
> > >
> > > diff --git a/lisp/org.el b/lisp/org.el
> > > index 020cfc873..d13d78dbf 100644
> > > --- a/lisp/org.el
> > > +++ b/lisp/org.el
> > > @@ -8024,10 +8024,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 \"/\".
> > >
> > > @@ -8035,6 +8049,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
> > >
> > > @@ -8046,7 +8062,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)
> > >
> > > `((t :height ,(face-attribute 'default
> :
> :height)))
[-- Attachment #2: 0001-org-agenda.el-allow-to-customize-outline-path-in-ech.patch --]
[-- Type: text/x-patch, Size: 4652 bytes --]
From 4eb0c3011fecb69c6ac5867970e033c62352c2b2 Mon Sep 17 00:00:00 2001
From: Mikhail Skorzhinskii <mskorzhinskiy@eml.cc>
Date: Sat, 12 Sep 2020 18:10:05 +0200
Subject: [PATCH] org-agenda.el: allow to customize outline path in echo area
Some of the org-mode data bases auto-generate file names, so they don't
carry a lot of information and can be noisy. Allowing user to show
document titles instead could be useful. Showing titles is disabled by
default.
---
etc/ORG-NEWS | 6 ++++++
lisp/org-agenda.el | 11 ++++++++---
lisp/org.el | 25 ++++++++++++++++++++++---
3 files changed, 36 insertions(+), 6 deletions(-)
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 0ed626fb7..e30336f45 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -11,6 +11,12 @@ See the end of the file for license conditions.
Please send Org bug reports to mailto:emacs-orgmode@gnu.org.
* Version 9.5 (not yet released)
+** New options and settings
+*** New option value for ~org-agenda-show-outline-path~
+
+When set to 'title, will show document title in outline path in echo
+area instead of file name.
+
* Version 9.4
** Incompatible changes
*** Possibly broken internal file links: please check and fix
diff --git a/lisp/org-agenda.el b/lisp/org-agenda.el
index 82fe6091c..17e189317 100644
--- a/lisp/org-agenda.el
+++ b/lisp/org-agenda.el
@@ -1040,9 +1040,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."
@@ -8777,7 +8782,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 a9fdc7b77..191918860 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -8023,10 +8023,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 \"/\".
@@ -8034,6 +8048,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
@@ -8045,7 +8061,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)
`((t :height ,(face-attribute 'default :height)))
--
2.28.0
prev parent reply other threads:[~2020-09-21 11:29 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-15 8:45 [PATCHES 1, 2, 3/3] Minor customisation features for ox-icalendar and agenda Mikhail Skorzhinskii
2020-09-16 2:15 ` Ihor Radchenko
2020-09-21 8:23 ` Mikhail Skorzhinskii
2020-09-21 11:29 ` Mikhail Skorzhinskii [this message]
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=3220650.xNLfXBERsm@trex230 \
--to=mskorzhinskiy@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).