plexus / chemacs

Emacs profile switcher
652 stars 45 forks source link

"wrong-number-of-arguments (2 . 4) 5" on startup #1

Closed esquivalient closed 6 years ago

esquivalient commented 6 years ago

I tried to set up what I think is the simplest version of chemacs to play around with it. When I execute

emacs --debug-init --with-profile spacemacs

with the following as my .emacs-profiles.el

(("default" . ((user-emacs-directory . "~/.emacs.d")))
 ("spacemacs" . ((user-emacs-directory . "~/code/emacs/spacemacs/"))))

I get the error in the title (full trace at the bottom of this issue). I'm not well versed in elisp or reading its stack traces, so there's probably something obvious that I'm missing.

Debugger entered--Lisp error: (wrong-number-of-arguments (2 . 4) 5)
  alist-get("spacemacs" (("default" (user-emacs-directory . "~/.emacs.d")) ("spacemacs" (user-emacs-directory . "~/code/emacs/spacemacs/"))) nil nil equal)
  chemacs-get-emacs-profile("spacemacs")
  (not (chemacs-get-emacs-profile profile))
  (if (not (chemacs-get-emacs-profile profile)) (progn (error "No profile `%s' in %s" profile chemacs-profiles-path)))
  chemacs-load-profile("spacemacs")
  (if (equal (car args) "--with-profile") (chemacs-load-profile (car (cdr args))) (chemacs-check-command-line-args (cdr args)))
  (progn (if (equal (car args) "--with-profile") (chemacs-load-profile (car (cdr args))) (chemacs-check-command-line-args (cdr args))))
  (if args (progn (if (equal (car args) "--with-profile") (chemacs-load-profile (car (cdr args))) (chemacs-check-command-line-args (cdr args)))))
  chemacs-check-command-line-args(("--with-profile" "spacemacs"))
  (if (equal (car args) "--with-profile") (chemacs-load-profile (car (cdr args))) (chemacs-check-command-line-args (cdr args)))
  (progn (if (equal (car args) "--with-profile") (chemacs-load-profile (car (cdr args))) (chemacs-check-command-line-args (cdr args))))
  (if args (progn (if (equal (car args) "--with-profile") (chemacs-load-profile (car (cdr args))) (chemacs-check-command-line-args (cdr args)))))
  chemacs-check-command-line-args(("/usr/local/Cellar/emacs/25.1/Emacs.app/Contents/MacOS/Emacs" "--with-profile" "spacemacs"))
  eval-buffer(#<buffer  *load*> nil "/Users/esquivalient/.emacs" nil t)  ; Reading at buffer position 4964
  load-with-code-conversion("/Users/esquivalient/.emacs" "/Users/esquivalient/.emacs" t t)
  load("~/.emacs" t t)
  #[0 "\205\266   \306=\203\307\310Q\202? \311=\204\307\312Q\202?\313\307\314\315#\203*\316\202?\313\307\314\317#\203>\320\321\322!D\nB\323\202?\316\324\325\324\211#\210\324=\203e\326\327\330\307\331Q!\"\325\324\211#\210\324=\203d\210\203\247\332!\333\232\203\247\334!\211\335P\336!\203\201\211\202\214\336!\203\213\202\214\314\262\203\245\337\"\203\243\340\341#\210\342\343!\210\266\f?\205\264\314\325\344\324\211#)\262\207" [init-file-user system-type delayed-warnings-list user-init-file inhibit-default-init inhibit-startup-screen ms-dos "~" "/_emacs" windows-nt "/.emacs" directory-files nil "^\\.emacs\\(\\.elc?\\)?$" "~/.emacs" "^_emacs\\(\\.elc?\\)?$" initialization format-message "`_emacs' init file is deprecated, please use `.emacs'" "~/_emacs" t load expand-file-name "init" file-name-as-directory "/.emacs.d" file-name-extension "elc" file-name-sans-extension ".el" file-exists-p file-newer-than-file-p message "Warning: %s is newer than %s" sit-for 1 "default"] 7]()
  command-line()
  normal-top-level()
yiufung commented 6 years ago

Try replace the function chemacs-get-emacs-profile with

(defun chemacs-get-emacs-profile (profile)
  (assoc profile chemacs-emacs-profiles))

After that, it works for me with .emacs-profiles.el

(
 ("default" . ((user-emacs-directory . "~/.emacs.d")))
 ("spacemacs-dev" . ((user-emacs-directory . "~/.test.d/")))
)
plexus commented 6 years ago

alist-get got an extra optional TEST-FN argument in Emacs 24.5 (I think, looking at the commit history).

assoc is not the same, since it returns the association pair, instead of just the value.

I'll push a fix for older Emacsen.

plexus commented 6 years ago

Thanks for reporting, it should be fixed on master now. Please give it a go!