{"id":904,"date":"2012-07-07T11:35:00","date_gmt":"2012-07-07T15:35:00","guid":{"rendered":"http:\/\/irreal.org\/blog\/?p=904"},"modified":"2012-07-07T11:36:51","modified_gmt":"2012-07-07T15:36:51","slug":"elpa-with-emacs-24","status":"publish","type":"post","link":"https:\/\/irreal.org\/blog\/?p=904","title":{"rendered":"ELPA With Emacs 24"},"content":{"rendered":"<p>I just installed Emacs 24 and, as expected, everything went very well except for the package system, ELPA. I don&#8217;t have very many packages that I load with ELPA so at least the number of problems were limited.<\/p>\n<p>First, following Xah Lee&#8217;s <a href=\"http:\/\/ergoemacs.org\/emacs\/emacs_package_system.html\">Guide on Emacs 24 Package System<\/a> page, I moved the old <code>~\/.emacs.d\/elpa<\/code> directory out of the way and then reloaded my packages. The first problem is that you need to replace the<\/p>\n<pre class=\"src src-emacs-lisp\">(<span style=\"color: #7f007f;\">when<\/span>\r\n    (load\r\n     (expand-file-name <span style=\"color: #8b2252;\">\"~\/.emacs.d\/elpa\/package.el\"<\/span>))\r\n  (package-initialize))<\/pre>\n<p>with<\/p>\n<pre class=\"src src-emacs-lisp\">(<span style=\"color: #7f007f;\">require<\/span> '<span style=\"color: #008b8b;\">package<\/span>)<\/pre>\n<p>After that change I was able to add Marmalade to the list of package sites.<\/p>\n<p>The next problem was that when I restarted Emacs, I got an error saying it couldn&#8217;t load <code>smex<\/code>, one of the packages that I load with ELPA. Everything seemed OK: <code>smex<\/code> was loaded onto my machine and seemed fine. The bit of Elisp in <code>init.el<\/code> was what the documentation said it should be but I couldn&#8217;t get it to load from <code>init.el<\/code>. I went searching on the Web and after a few useless links I found this page on <a href=\"http:\/\/xahlee.blogspot.com\/2012\/06\/emacs-24-package-system-problems.html\">Emacs 24 Package System Problems<\/a>, again from Xah Lee. In order to get things to work you have to add an explicit load path for <em>some<\/em> of the packages (<code>smex<\/code>, <code>magit<\/code>, <code>dired+<\/code>, and <code>key-chord<\/code> for me). My first pass at this was to add commands to explicitly add the load paths:<\/p>\n<pre class=\"src src-emacs-lisp\">(add-to-list 'load-path <span style=\"color: #8b2252;\">\"~\/.emacs.d\/elpa\/smex-1.1.2\/\"<\/span>) <span style=\"color: #b22222;\">; <\/span><span style=\"color: #b22222;\">XXX Emacs bug<\/span>\r\n(<span style=\"color: #7f007f;\">require<\/span> '<span style=\"color: #008b8b;\">smex<\/span>)\r\n(smex-initialize)\r\n(global-set-key (kbd <span style=\"color: #8b2252;\">\"M-x\"<\/span>) 'smex)\r\n...<\/pre>\n<p>This is annoying because the path will have to be changed when I upgrade. It&#8217;s doubly annoying because ELPA worked just fine without having to do this in Emacs 23. Rather than keep dealing with this every time I upgrade one of the problem packages, I added<\/p>\n<pre class=\"src src-emacs-lisp\">(<span style=\"color: #7f007f;\">defconst<\/span> <span style=\"color: #a0522d;\">elpa-loads<\/span> '(<span style=\"color: #8b2252;\">\"smex\"<\/span> <span style=\"color: #8b2252;\">\"magit\"<\/span> <span style=\"color: #8b2252;\">\"dired\"<\/span> <span style=\"color: #8b2252;\">\"key-chord\"<\/span>))\r\n(mapc (<span style=\"color: #7f007f;\">lambda<\/span> (p) (<span style=\"color: #7f007f;\">if<\/span> (file-directory-p p) (add-to-list 'load-path p)))\r\n      (directory-files <span style=\"color: #8b2252;\">\"~\/.emacs.d\/elpa\"<\/span> t\r\n                       (concat <span style=\"color: #8b2252;\">\"^<\/span><span style=\"color: #8b2252; font-weight: bold;\">\\\\<\/span><span style=\"color: #8b2252; font-weight: bold;\">(<\/span><span style=\"color: #8b2252;\">\"<\/span>\r\n                               (mapconcat 'identity elpa-loads <span style=\"color: #8b2252;\">\"<\/span><span style=\"color: #8b2252; font-weight: bold;\">\\\\<\/span><span style=\"color: #8b2252; font-weight: bold;\">|<\/span><span style=\"color: #8b2252;\">\"<\/span>)\r\n                               <span style=\"color: #8b2252;\">\"<\/span><span style=\"color: #8b2252; font-weight: bold;\">\\\\<\/span><span style=\"color: #8b2252; font-weight: bold;\">)<\/span><span style=\"color: #8b2252;\">.*\"<\/span>)))<\/pre>\n<p>to my <code>init.el<\/code>. With that change, the only maintenance required is to add any new problem packages to <code>elpa-loads<\/code>.<\/p>\n<p>The Emacs 24 ELPA problem appears, from some of the other links I looked at, to be that Emacs 24 deals with the ELPA packages after it has finished processing the <code>.emacs<\/code> or <code>init.el<\/code> file and, therefore the <code>.emacs<\/code> or <code>init.el<\/code> file knows nothing about the packages. That means you can&#8217;t set package variables because they haven&#8217;t been loaded yet. As far as I could find out, the only solution is to load the files with <code>require<\/code> and that requires that there be a path to the <code>.el<\/code> or <code>.elc<\/code> files.<\/p>\n<p>Doubtless, this will all be resolved soon so I&#8217;m not overly exercised about it. Now that I have things working again, it&#8217;s time to explore the new Emacs 24 and see how it improves my life.<\/p>\n<p><strong>Update<\/strong>: Added explicit check for directory when setting paths.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I just installed Emacs 24 and, as expected, everything went very well except for the package system, ELPA. I don&#8217;t have very many packages that I load with ELPA so at least the number of problems were limited. First, following &hellip; <a href=\"https:\/\/irreal.org\/blog\/?p=904\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[18],"class_list":["post-904","post","type-post","status-publish","format-standard","hentry","category-general","tag-emacs"],"_links":{"self":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/904","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=904"}],"version-history":[{"count":5,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/904\/revisions"}],"predecessor-version":[{"id":914,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/904\/revisions\/914"}],"wp:attachment":[{"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=904"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=904"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/irreal.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=904"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}