0

I use Prelude, and I want to use use-package for loading and configuring my personal config files.

In ~/.emacs.d/personal/load-private-config.el, my code is below: (like https://github.com/jwiegley/dot-emacs/blob/master/init.el#L99)

(defconst zwb-private-emacs-config-path "~/.emacs.d-private/")

(eval-and-compile
  (mapc
   #'(lambda (path)
       (push (expand-file-name path zwb-private-emacs-config-path) load-path))
   '("lib""theme" "")))

(eval-and-compile
  (defvar use-package-verbose t)
  (require 'cl)
  (require 'use-package))

(use-package zwb :load-path (lambda () (expand-file-name (concat zwb-private-emacs-config-path "lib/zwb"))))

In ~/.emacs.d-private/lib/zwb/zwb.el

(message "test-zwb")
(provide 'zwb)

restart emacs, in *Message* buffer, I cann't see test-zwb

I add (message load-path) at the end of load-private-config.el, restart emacs got:

Warning (initialization): An error occurred while loading `/Users/zwb/.emacs.d/init.elc':

Wrong type argument: stringp, (/Users/zwb/.emacs.d-private/lib/zwb /Users/zwb/.emacs.d-private /Users/zwb/.emacs.d-private/theme /Users/zwb/.emacs.d-private/lib ~/.emacs.d/themes/color-theme-ahei-20141223.221

It seems the lib/zwb is in the load-path, so I don't how:

  1. Why I cann't get test-zwb in *Message* buffer?
  2. Has zwb.el been already loaded? If not, how to load it?
  3. How to print load-path (use message method seems has some problem)?

My OS version: Mac OS X 10.11.2 beta4
My Emacs version: 24.5.1 (brew emacs-mac-emacs)

0
  1. Your zwb.el is wrong.

    (message "test-zwb") ; " and ' are not couple.
    (provide 'zwb) ; This means the zwb.el provides the feature zwb
    

    This one is ok. See this: https://stackoverflow.com/questions/3349223/running-my-own-code-when-during-emacs-startup

  2. :defer means the zwb package is autoloaded. You can remove :defer t to see the message immediately.

  3. Print load-path. I did it by describe-variable load-path. And you may do:

    (message "%S" load-path)
    

P.S. You can expand the use-package macro and try to understand how the package is loaded. With :defer, the macro only does one thing: add the return of the lambda function to load-path. Without :defer, the macro expands to (require 'zwb) and timing.

  • Thank you @jiegec, I did as you told, It seems zwb has been loaded, but I still cann't get test-zwb in *Message*, I tried to add (require 'zwb) in load-private-config.el, but still get nothing out. – zwb Nov 21 '15 at 7:39
  • @zwb Kill emacs and start it again. The message only appears at the first time. – jiegec Nov 21 '15 at 7:46
  • It's OK now. Sorry, I edited a wrong buffer with the same test filename zwb.el. Thank you for your help! – zwb Nov 21 '15 at 7:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.