[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to use code from solar.el
From: |
Stephen Berman |
Subject: |
Re: How to use code from solar.el |
Date: |
Fri, 25 Nov 2016 14:13:24 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) |
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