all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: John Magolske <listmail@b79.net>
To: help-gnu-emacs@gnu.org
Subject: Re: Challenges around displaying phase of moon in calfw
Date: Sat, 3 Jun 2017 19:13:38 -0700	[thread overview]
Message-ID: <20170604021338.GA26566@s70206.gridserver.com> (raw)
In-Reply-To: <20170601052912.GB15070@s70206.gridserver.com>

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



      parent reply	other threads:[~2017-06-04  2:13 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-28  8:23 Challenges around displaying phase of moon in calfw John Magolske
2017-06-01  5:29 ` John Magolske
2017-06-01 14:43   ` Jude DaShiell
2017-06-01 14:51     ` Óscar Fuentes
2017-06-01 15:13       ` tomas
2017-06-01 15:40       ` Jude DaShiell
2017-06-01 16:05         ` Óscar Fuentes
2017-06-01 20:30           ` John Ankarström
2017-06-04  2:13   ` John Magolske [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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170604021338.GA26566@s70206.gridserver.com \
    --to=listmail@b79.net \
    --cc=help-gnu-emacs@gnu.org \
    /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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.