[emacs-berlin] A doubt about use-package
Narendra Joshi
narendraj9 at gmail.com
Thu Jan 14 21:19:36 UTC 2021
jman <emacs-berlin at storiepvtride.it> writes:
> Hello folks,
>
> freues neues Jahr :)
>
> I have a question which I can't seem to solve by searching around.
>
> I've found this snippet to configure mu4e (the email client inside
> emacs) [0] so I copied some parts of it but they don't seem to
> work. In fact, they do look wrong to me.
>
> Just an example:
>
> (use-package mu4e
> ...
> :custom
> (mu4e-attachment-dir "~/Downloads")
> ...
>
> it just doesn't work for me, I need to instead move each command to the
> `:init` to make it work:
>
> (use-package mu4e
> ...
> :init
> (setq mu4e-attachment-dir "~/Downloads")
> ...
--8<---------------cut here---------------start------------->8---
(use-package mu4e
...
:custom
(mu4e-attachment-dir "~/Downloads"))
--8<---------------cut here---------------end--------------->8---
macro-expands to (try `pp-macroexpand-last-sexp', I use `macrostep-mode'
for quickly checking macro expansions in the same buffer).
--8<---------------cut here---------------start------------->8---
......
(funcall
(or
(get 'mu4e-attachment-dir 'custom-set)
#'set-default)
'mu4e-attachment-dir "~/Downloads")
......
--8<---------------cut here---------------end--------------->8---
`set-default` here is going to set the top-level (i.e. outside all let
bindings and buffers [for buffer local variables]) value.
`defcustom` will not change the value of a variable that already has a
top-level value. If you are trying to check this (with C-x C-e), try
something like:
--8<---------------cut here---------------start------------->8---
(eval '(defcustom mu4e-attachment-dir "~/Downloads" "Docstring"))
--8<---------------cut here---------------end--------------->8---
That's because C-x C-e (`eval-last-sexp') handles `defvar' and
`defcustom' differently during interactive use. If these are in a file
which is loaded, they are evaluated differently.
Getting back to your problem, I think you probably have a `set{q}`
somewhere that is causing this issue. Whenever I face similar problems,
the first file that I check for interfering bindings is the
`custom-file'. If you have not explicitly set the `custom-file'
variable, your init file will contain these, probably at the end of the
file.
To debug this problem, setting a variable watcher at the beginning of
your init.el might help:
--8<---------------cut here---------------start------------->8---
(add-variable-watcher 'the-var-to-be-watched
(lambda (sym new-value operation where)
(message "Value for %s getting modified to %s with %s in buffer %s"
sym new-value operation where)))
--8<---------------cut here---------------end--------------->8---
Best regards,
> This applies for any variable in that code. I need to use `setq`,
> otherwise it is not loaded. If I check the value with `C-h v` it doesn't
> pick up my customization. If I check it with `M-x customize-variable`
> emacs says that the variable is "CHANGED outside Customize" but I don't
> see any effect.
>
> I'm sure I'm missing something here so, It's driving me nuts :)
>
> thanks for any hint!
>
> ein lieben Grüß,
>
> [0] https://github.com/adimit/config/blob/7aa03bda553ad3cbddc1976c431427f1586c0=7b8/newmacs/main.org#mu4e
> _______________________________________________
> emacs-berlin mailing list
> emacs-berlin at emacs-berlin.org
> https://mailb.org/mailman/listinfo/emacs-berlin
>
--
Narendra Joshi
More information about the emacs-berlin
mailing list