help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Challenges around displaying phase of moon in calfw


From: John Magolske
Subject: Re: Challenges around displaying phase of moon in calfw
Date: Sat, 3 Jun 2017 19:13:38 -0700
User-agent: Mutt/1.5.23 (2014-03-12)

Ok, hacked together a workaround...

* John Magolske <listmail@b79.net> [170601 00:32]:
> * John Magolske <listmail@b79.net> [170528 02:05]:
> 
> > [...] the lunar phases show up in calfw, but for some
> > reason the time is displayed twice, like so:
> > 
> >     19:48 ◐ q1↑ 7:48pm (PDT)
> >     14:40 ● Full 2:40pm (PDT)
> >     12:46 ◯ New 12:46pm (PDT)
>
> [...]
>
> I'm wondering if this issue may be related to this post on emacs-devel:
> 
> calendar/diary/appt: diary-lunar-phases should not create appointments
> [...]
> https://lists.gnu.org/archive/html/emacs-devel/2011-11/msg00329.html
> no resolution...picked up again a few years later:
> https://lists.gnu.org/archive/html/emacs-devel/2015-02/msg01347.html

I see this does appear to be the same issue mentioned in the emacs-devel
posts as well (thanks to an off-list exchange with Toto). Apparently
with time shown, an appointment is created out of the diary entry.
So I edited the output of lunar.el to show these times substituting
∶ (RATIO, U+2236) for : (COLON, U+003A), a for am, and p for pm.
This way they aren't recognized at "times" and the time doesn't show
up twice in calfw. Also got rid of the parenthesis around time zones
to keep things concise. Below is the modified version of lunar.el as
placed in my init file, displays in calfw like so:

    ◐ q1↑ 7:48p PDT
    ● Full 2:40p PDT
    ◯ New 12:46p PDT

Cheers,

John

----

(with-eval-after-load 'lunar
  (defun diary-lunar-phases (&optional mark)
    "Moon phases diary entry.
An optional parameter MARK specifies a face or single-character string to
use when highlighting the day in the calendar.
    Note: edited from lunar.el, changed the part that calls out hour of lunar
phase substituting ∶ (RATIO, U+2236) for : (COLON, U+003A), a for am, p for pm
so that lunar phase times aren't recognized as timestamps. Otherwise appointment
will be created out of these diary entries and times will show up twice in 
calfw.
Also removed the parenthesis around timezone to shorten what's displayed."
    (let* ((index (lunar-index date))
           (phase (lunar-phase index)))
      (while (calendar-date-compare phase (list date))
        (setq index (1+ index)
              phase (lunar-phase index)))
      (if (calendar-date-equal (car phase) date)
          ;; (cons mark (lunar-phase-name (nth 2 phase)))))))
          (cons
           mark
           (concat 
            (lunar-phase-name (nth 2 phase)) " "
            (replace-regexp-in-string
             ":" "∶"
             (replace-regexp-in-string
              "am" "a"
              (replace-regexp-in-string
               "pm" "p"
               (replace-regexp-in-string
                "(" ""
                (replace-regexp-in-string
                 ")" ""
                 (cadr phase))))))
            ))))))


-- 
John Magolske
http://b79.net/contact



reply via email to

[Prev in Thread] Current Thread [Next in Thread]