What you are doing is defining the key to the result of the evaluation of the expression (display-message-or-buffer (message "`%s'" (eval '(solar-sunrise-sunset-string (calendar-current-date)))))
. When I evaluate that expression in my *scratch*
buffer, I get the string "‘Sunrise 7:04am (EST), sunset 4:10pm (EST) at 42.4N, 71.2W (9:06 hrs daylight)’"
. IOW, what you did is equivalent to this:
(define-key global-map (kbd "µ") "‘Sunrise 7:04am (EST), sunset 4:10pm (EST) at 42.4N, 71.2W (9:06 hrs daylight)’")
Of course, geographical differences will give you a different string, but that is irrelevant to the main point.
If you want to define the key to run a command, you first define the function that you want to run and then you give the function to define-key
- like this:
(defun my/func ()
(interactive)
(display-message-or-buffer (message "`%s'" (eval '(solar-sunrise-sunset-string (calendar-current-date)))))
(define-key global-map (kbd "µ") #'my/func)
BTW, you don't need the eval
: (display-message-or-buffer (message "`%s'" (solar-sunrise-sunset-string (calendar-current-date))))
will work just as well (or better: explicit use of eval
is generally frowned upon - see the first paragraph of the eval
section of the Emacs Lisp manual, which you can get to with C-h v i g(elisp)eval
).