Closed mananamenos closed 3 years ago
What is the emacs package? I don't think thats anything that comes with emacs.
You are probably looking for something like this.
(use-package ido
:init ;; is run BEFORE package is loaded, when emacs starts
(setq ido-enable-flex-matching t)
(setq ido-everywhere t)
(setq ido-auto-merge-work-directories-length -1)
(ido-mode 1) ;; causes ido to load
:config ;; is run AFTER package is loaded
(message "doing something that required ido to be loaded first" )
:bind* ("C-," . ido-switch-buffer) ;; using th binding also causes ido to be loaded
)
Expanding the use-package macro gives some insight in what the code above does where among other things the :config:
block is wrapped inside eval-after-load
(progn
(defvar use-package--warning3
(function
(lambda
(keyword err)
(let
((msg
(format "%s/%s: %s" 'ido keyword
(error-message-string err))))
(display-warning 'use-package msg :error)))))
(condition-case-unless-debug err
(progn
(unless
(fboundp 'ido-switch-buffer)
(autoload
(function ido-switch-buffer)
"ido" nil t))
(condition-case-unless-debug err
(progn
(setq ido-enable-flex-matching t)
(setq ido-everywhere t)
(setq ido-auto-merge-work-directories-length -1)
(ido-mode 1))
(error
(funcall use-package--warning3 :init err)))
(eval-after-load 'ido
'(condition-case-unless-debug err
(progn
(message "doing something that required ido to be loaded first")
t)
(error
(funcall use-package--warning3 :config err))))
(bind-keys* :package ido
("C-," . ido-switch-buffer)))
(error
(funcall use-package--warning3 :catch err))))
This means that in your example, the code in your :config
will run after the package (feature) emacs
is loaded which probably doesn't exist so it will never be executed:
...
(eval-after-load 'emacs
'(condition-case-unless-debug err
(progn
(ido-mode 1)
(setq ido-enable-flex-matching t)
(setq ido-everywhere t)
(setq ido-auto-merge-work-directories-length -1)
t)
(error
(funcall use-package--warning376 :config err))))
....
@thomasf thank you very much for a great explanation.
hi, I have this in my init.el
However, on the emacs startup the line
(setq ido-auto-merge-work-directories-length -1)
does not do its job. I have to manually evaluate that expression once emacs has started up. How can I achieve this to work on the startup?