all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* How to use code from solar.el
@ 2016-11-25  9:02 Matthias Pfeifer
  2016-11-25 13:13 ` Stephen Berman
  0 siblings, 1 reply; 3+ messages in thread
From: Matthias Pfeifer @ 2016-11-25  9:02 UTC (permalink / raw)
  To: help-gnu-emacs

Hi there,


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.




Matthias


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How to use code from solar.el
  2016-11-25  9:02 How to use code from solar.el Matthias Pfeifer
@ 2016-11-25 13:13 ` Stephen Berman
  0 siblings, 0 replies; 3+ messages in thread
From: Stephen Berman @ 2016-11-25 13:13 UTC (permalink / raw)
  To: Matthias Pfeifer; +Cc: help-gnu-emacs

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



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How to use code from solar.el
@ 2016-11-25 13:31 Matthias Pfeifer
  0 siblings, 0 replies; 3+ messages in thread
From: Matthias Pfeifer @ 2016-11-25 13:31 UTC (permalink / raw)
  To: help-gnu-emacs

> 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

Thank you. That was exactly the issue!

Matthias


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-11-25 13:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-25  9:02 How to use code from solar.el Matthias Pfeifer
2016-11-25 13:13 ` Stephen Berman
  -- strict thread matches above, loose matches on Subject: below --
2016-11-25 13:31 Matthias Pfeifer

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.