0

I am trying to achieve a slightly smart package management in my init.el file but can't achieve it because of ELisp ignorance. Here is the case.

;; package loader function
(defun load-packages-context-sensitively (plist)
  (dolist (ppack plist) 
    (unless (and ((not window-system) (string= (assoc ppack plist) "GUI")))
      (require '(ppack)))))

(defconst package-assoc-list
  '((package-1 "CLI") ;here
    (package-2 "CLI") ; I 
    (package-3 "GUI") ; declare
    (package-4 "GUI") ; my packages
    (package-5 "CLI")))

(load-packages-context-sensitively (package-assoc-list)) ; here we need a happy ending

I simply want to generate an associated list (I'm not even sure if its the right data structure) and map each package name (provide 'package-x)'ed in another file to "GUI" and "CLI" strings. What I want to achieve is to pass the list to my slightly-smart-function and prevent GUI packages being loaded in CLI environments...

It gives me Symbol's function definition is void: package-assoc-list error now. Yes it looks very self-explanatory, it is well documented but I couldn't find a way to overcome it.

Any help, any correction, any suggestion, any cringe is more than welcome.

  • Side note: loading a package should have "no visible effect" (other than defining some functions and variables, that is): any visible effect is usually considered a bug (because Emacs sometimes loads packages for rather frivolous reasons). So most likely you shouldn't be thinking about which packages to load, but about which functionality to enable. – Stefan Nov 12 '17 at 1:33
1

This question is likely a duplicate, but I don't find it now.

You are using (package-assoc-list), which means to invoke the function package-assoc-list. Just use variable package-assoc-list instead.

(load-packages-context-sensitively package-assoc-list)
| improve this answer | |

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.