[Remind-Fans] [diff] Adjusting width for ANSI sequences in calprefix/calsuffix

Tim Chase remind at tim.thechases.com
Tue Jan 14 11:52:33 EST 2020


On 2020-01-13 14:58, Dianne Skoll wrote:
> >   SET Esc Char(27)
> >   SET Red Esc + "[0;31m"
> >   SET Nrm Esc + "[0m"
> >   FSET calprefix(x) Red
> >   FSET calsuffix(x) Nrm
> >   MSG "this is a very important thing"  
> 
> > things go all bonkers.  
> 
> However, Remind can color reminders natively.  If you have
> something like:
> 
>     REM Fri SPECIAL COLOR 255 0 0 Friday!!!
> 
> and then invoke Remind as: remind -cc ...  (or remind -clc ... to
> use line-drawing characters) then it colors the calendar using ANSI
> sequences and doesn't mess up formatting.

Handy for one-offs, but for my use case, I tend to have my reminders
in multiple files (birthdays, anniversaries, one for work, one for the
kids' school calendars, etc), and then have one color per file, using
msgprefix/msgsuffix

  # base remind.rem
  INCLUDE .../colors.rem
  SET calcolor Nrm
  FSET msgprefix(x) calcolor
  FSET msgsuffix(x) Nrm
  INCLUDE .../birthdays.rem
  INCLUDE .../anniversaries.rem
  INCLUDE .../tim.rem
  INCLUDE .../school.rem

  # birthdays.rem
  SET calcolor Grn
  REM Jan 6 MSG Dianne's birthday
  REM Feb 14 MSG Tim's birthday

  # tim.rem
  SET calcolor Blu
  REM Jan 14 2020 MSG Reply to email about colors in remind

  # school.rem
  SET calcolor Cyn
  REM Aug 13 2019 MSG School begins

This lets me set the color a mere 41 (as reported by `grep
"SET calcolor" ~/.config/remind/*.rem | wc -l`) times rather than
individually for all my (roughly) 1560 individual REM statements (as
determined by a `grep "MS[GF]" ~/.config/remind | wc -l`).

I know you've been busy hacking in some new functionality for JSON
output and the like, but I'll put a bug in your ear hoping for a
global default color that could be tweaked as above. It wouldn't be
onorous to adjust my files to change the "SET calcolor Foo" to
something like

  # birthdays.rem
  COLOR 0 128 0
  # or
  SET $DefaultColor "0 128 0"

[an hour passes]

As matter of fact, I wanted it badly enough to implement it and
attach at least the code changes as a .diff :-)

I'm afraid I don't have tests for it or updates for the man-page but
my manual testing worked (almost) exactly as desired:

  $ cat ~/.reminders
  MSG Normal daily%
  SPECIAL COLOR 128 0 0 MSG Explicitly red%
  SET $DefaultColor "0 0 128"
  MSG Normal but blue?%
  SPECIAL COLOR 0 128 0 MSG Explicitly green now%
  MSG Back to blue?%
  MSG Look, more blue with no further effort%
  SET $DefaultColor "128 0 128"
  MSG And purple now?%
  MSG The default color is [$DefaultColor]%

and tested with

  $ remind -cc+ ~/.reminders

It built and worked on the first try! (I love it when that happens!)

The "almost" aspect of it is that because of how the repeat days
work, the "Normal daily" comes out normal for the first day, but in
subsequent iterations, it's the new default color (at this point, the
purple that the previous one ended with).  It's expected yet also a
bit of a surprise. Just kinda requires that you set the $DefaultColor
at the very top before any reminders trigger.

I'm not sure if the patch adheres to your coding style but consider it
licsensed WTFPL/CC0/BSD/GPLv{whatever} so you're welcome to do as you
please with it.

-tim




-------------- next part --------------
A non-text attachment was scrubbed...
Name: remind_default_color.diff
Type: text/x-patch
Size: 2976 bytes
Desc: not available
URL: <http://dianne.skoll.ca/pipermail/remind-fans/attachments/20200114/27e1e3e5/attachment.bin>


More information about the Remind-fans mailing list