3

I use package manager to update my packages automatically by doing package-list-packages, package-menu-mark-upgrades, package-menu-execute. (I assume this is the easiest way to automatically update all my packages, though I don't really know.)

When I do this, org-mode winds up in a directory with a path like this:

~/Dropbox/emacs/prelude/elpa/org-20150511/

I use packages that are part of contrib, so my .emacs includes these lines:

(add-to-list 'load-path "~/Dropbox/emacs/prelude/elpa/org-20150511/lisp" load-path)  
(add-to-list 'load-path "~/Dropbox/emacs/prelude/elpa/org-20150511/contrib" load-path)
(add-to-list 'load-path "~/Dropbox/emacs/prelude/elpa/org-20150511/contrib/lisp" load-path)

Since the org directory is named according to the date of the release, this means I have to either: 1. edit the directory name in the load paths 2. rename the org folder

Is there a way to get org-mode to find the contrib directories automatically when I upgrade org?

  • 2
    Another way is to add orgmode.org/elpa to package-archives as per the instructions here and install org-plus-contrib from the package manager. That install the regular org files plus the contrib content in a flat folder hierarchy. – Kaushal Modi May 20 '15 at 3:52
  • 1
    BTW, the last argument you're passing to add-to-list does not do what you think does, and you probably don't want it. – Malabarba May 20 '15 at 17:59
  • As for the easiest way to upgrade packages: you're doing it right, but here's a shortcut. – Malabarba May 20 '15 at 18:06
3

This solution is specific to how to add the org contrib packages to the load path.

You can add orgmode.org/elpa/ to package-archives as per the instructions here and install org-plus-contrib using the package manager. That will install the regular org files plus the contrib content in a flat folder hierarchy.

The installation instructions from the reference link are repeated here for convenience:

Add this to your Emacs init file to be able to list the Org mode archives:

(require 'package)

(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/") t)

Then M-x list-packages RET will list both the latest org and org-plus-contrib packages.

org contains the same set of files that are included in GNU Emacs. org-plus-contrib contains these files plus all contribs files, the ones you find in contrib/ from the git repo.

2

This is a hacky answer but it works (add the code to your .emacs file):

;; First, define a variable to hold the directory name. It will always
;; be updated whenever there's a new Org version.
;; The important part is this function:
;; (file-name-completion "org-20" "~/Dropbox/emacs/prelude/elpa/")
;; returns:
;; "org-20150511/"
;; or in the future:
;; "org-20250314/"
;; etc.

(setq my-org-from-elpa-dir (expand-file-name (file-name-completion "org-20" "~/Dropbox/emacs/prelude/elpa/") "~/Dropbox/emacs/prelude/elpa/")

;; Finally, add the directories to load-path.
;; (concat my-org-from-elpa-dir "lisp/")
;; returns:
;; "/home/YOU/Dropbox/emacs/prelude/elpa/org-20150511/lisp/"
;; and so on.

(add-to-list 'load-path (concat my-org-from-elpa-dir "lisp/"))
(add-to-list 'load-path (concat my-org-from-elpa-dir "contrib/"))
(add-to-list 'load-path (concat my-org-from-elpa-dir "contrib/lisp/"))

Caveats:

This code will be evaluated only at startup so you'll have to restart Emacs after you've upgraded your packages. Or else run eval-buffer. Or define a command based on this answer.

In the year 3000 you'll have to change "org-20" for "org-30".

  • This looks great. I do have a bunch of other org- packages like org-bullets and org-mac-link so maybe that's why I'm getting end of file during parsing? What if it just looked for something that began with org-2015? – incandescentman May 20 '15 at 3:47
  • @PeterSalazar Yes! Once I replied & left the computer I thought I left out that very important detail. Just changed my answer to correct that. – undostres May 20 '15 at 14:07
  • The final sentence is wrong. ;-) That's going to break way before the year 3000. – Malabarba May 20 '15 at 18:08
  • @Malabarba Hahah you're absolutely right. Going to leave it there though, it's kind of amusing. – undostres May 20 '15 at 18:38

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.