all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stephen Berman <stephen.berman@gmx.net>
To: Matthias Pfeifer <mpfeifer77@gmail.com>
Cc: help-gnu-emacs@gnu.org
Subject: Re: How to use code from solar.el
Date: Fri, 25 Nov 2016 14:13:24 +0100	[thread overview]
Message-ID: <87vavbbt3f.fsf@rub.de> (raw)
In-Reply-To: <CAPzsW6jFYUSPZnYEas5Bupjjpa54Xm+0DOYO=9X3fyRj_uWEGg@mail.gmail.com> (Matthias Pfeifer's message of "Fri, 25 Nov 2016 10:02:31 +0100")

On Fri, 25 Nov 2016 10:02:31 +0100 Matthias Pfeifer <mpfeifer77@gmail.com> wrote:

> solar.el is an emacs lisp library that comes with emacs. It (defun)s the
> function solar-sunrise-sunset that calculates sunrise, sunset and daylight.
> I was wanting to have this information available in the mode-line and added
> to my init.el file this piece of emacs lisp:
>
>
> (require 'solar)
>
> (defun mp:sunrise-sunset-for-modeline ()
>   (let ((calendar-time-display-form '(24-hours ":" minutes))
>         (l (solar-sunrise-sunset (calendar-current-date))))
>     (format "[↑%s, ↓%s]"
>             (apply 'solar-time-string (car l))
>             (apply 'solar-time-string (cadr l)))))
>
> When i was testing the code it was working find. However when I invoke
> emacs i get during loading of init.el this error message:
>
> Debugger entered--Lisp error: (wrong-type-argument arrayp nil)
>   solar-exact-local-noon((11 25 2016))
>   solar-sunrise-sunset((11 25 2016))
>   (let ((calendar-time-display-form (quote (24-hours ":" minutes))) (l
> (solar-sunrise-sunset (calendar-current-date)))) (format "[↑%s, ↓%s]"
> (apply (quote solar-time-string) (car l)) (apply (quote solar-time-string)
> (car (cdr l)))))
>   mp:sunrise-sunset-for-modeline()
>   eval((mp:sunrise-sunset-for-modeline) nil)
>   elisp--eval-last-sexp(nil)
>   eval-last-sexp(nil)
>   funcall-interactively(eval-last-sexp nil)
>   call-interactively(eval-last-sexp nil nil)
>   command-execute(eval-last-sexp)
>
>
> Why is the function not executing? If I invoke calendar before
> mp:sunrise-sunset-for-modeline then it works without error. Is it possible
> that i have to require some more dependencies? The debugger error message
> does not seem to indicate this, but it seems likely to me.

The error is raised because the value of the variable calendar-longitude
is nil.  Both this variable and also calendar-latitude need to be set
before your function above is invoked.  One way to do that is with `M-x
customize-option' and making sure your customizations are evaluated
before mp:sunrise-sunset-for-modeline is invoked in your init file.

Steve Berman



  reply	other threads:[~2016-11-25 13:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-25  9:02 How to use code from solar.el Matthias Pfeifer
2016-11-25 13:13 ` Stephen Berman [this message]
  -- strict thread matches above, loose matches on Subject: below --
2016-11-25 13:31 Matthias Pfeifer

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=87vavbbt3f.fsf@rub.de \
    --to=stephen.berman@gmx.net \
    --cc=help-gnu-emacs@gnu.org \
    --cc=mpfeifer77@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 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.