Re: [misc] Formatting options
- Date: Wed, 3 Jan 2018 12:00:02 +0100
- From: Lars Henriksen <LarsHenriksen@xxxxxxxxxx>
- Subject: Re: [misc] Formatting options
On Mon, Jan 01, 2018 at 04:14:09PM +0100, Lukas Fleischer wrote:
> On Mon, 01 Jan 2018 at 12:28:30, Lars Henriksen wrote:
> > Calcurse has five formatting options, two of which are for recurring
> > appointments/events: --format-recur-apt and format-recur-event. In the man
> > page it is stated that the available fields (format specifiers) depend
> > on the item type.
> > The recurring items have some extra properties (e.g. a stop time), but
> > as far as formatting fields are concerned, there are no differences.
> > So why the special formatting options?
> The main reason is convenience. We often want a different formatting for
> recurrent appointments.
> > Why not use the formatting options --format-apt and --format-event for
> > the recurring ones as well? A separate format for recurring appointments
> > may then be accomplished by combining --filter-type and --format-apt.
> > Eliminating the two recurring formats would simplify the internal interfaces
> > (long argument lists).
> > What I miss is another format option, --format-inst-apt, for instant
> > appointments, i.e. appointments with zero duration, or otherwise put, with
> > end time equal to start time. At the moment it is not possible to format
> > the command line output from queries as done in the appointment panel for
> > instant appointments.
> I like the general idea.
I do not - any longer. The more I think about it, the less I like it. There
are too many formatting options already. A new one for instant appointments
(and one for recurrent ones) makes it worse. Further below.
> However, there are some things to keep in mind.
> Firstly, having to use --filter-type to format different item types
> differently means that calcurse needs to be invoked multiple times for
> basics things like printing all appointments/events of a given day.
> Sometimes, this is inconvenient (wrapper scripts need to be created
> where a single command did the job before) and there is a small
> performance impact. Secondly, and more importantly, I do not see how we
> can make appointments appear in the correct order (without any
> additional post-processing).
I agree on both points.
> Maybe, we can add conditional formatting elements? Something like
> %(if-recur) and %(end-if)? And then also something like %(if-punctual)?
> Not sure how convenient that would be.
Hmm. Maybe the approach is wrong, trying to have calcurse do too much?
Back to the UNIX philosophy: do one thing well and write to standard output.
How about this idea.
1. the built-in default formats remain
2. a new general format option --format is added
3. if --format is present, it is applied to all items
4. a new format specifier '%t' is added which is replaced by the item type:
apt, recur-apt, event, recur-event, todo
5. a format specifier that does not apply to an item, is ignored
(now a '?' is printed)
The actual formatting is then done by postprocessing the output as needed
based on item type, duration, etc.
The two points you raised are respected.
The existing formatting options could be dropped or left for backward