help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to set calendar-date-style in init?


From: Michael Heerdegen
Subject: Re: How to set calendar-date-style in init?
Date: Sun, 11 Oct 2020 09:50:20 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Pankaj Jangid <pankaj@codeisgreat.org> writes:

> I have tried following options. What am I doing wrong here?
>
> ;; option-1
> ;;(declare-function calendar-set-date-style "calendar.el")
> ;;(calendar-set-date-style 'european)

Since `calendar-set-date-style' is not autoloaded, you need to
explicitly (require 'calendar).  The `declare-function' call only
tells the byte compiler that it should not barf, but you are responsible
to ensure that the function is known at load time.

> ;; option-2
> ;; (custom-set-variables
> ;;  '(calendar-date-style 'european))

I think this will also only work if you require 'calendar.

> ;; option-3
> ;; (defvar calendar-date-style)
> ;; (setq calendar-date-style 'european)

`defvar' without an argument makes the variable only special in the
loaded buffer.  (defvar calendar-date-style 'european) should work
(though calling `calendar-set-date-style' will set even more variables).

> ;; option-4
> (eval-when-compile (require 'calendar))
> (setq calendar-date-style 'european)

requiring calendar only at compile time will not make the variable
special when your file is loaded.

Ok, finally, which option should you use?  Most of the time people
choose option-5, using `with-eval-after-load'.


Regards,

Michael.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]