1

When developing a package which is also installed via an online repository, there is a practical problem.

  • /source/my-emacs-package

    git repository where I have my code.

  • ~/.config/emacs/elpa/my-emacs-package-20200127.1052

    The location the package is installed.

Currently I'm manually removing & symlinking files between these directories, however this is quite cumbersome since you need to remember to remove the *.elc files and the path name changes after each update.


How should I switch to my local git repository temporarily while developing my package?

Using a single switch for example, at the beginning of my init.el.

;; Set to t to load local packages.
(defconst use-my-local-packages nil)
  • 1
    I would use a second emacs instance tailored to load (and reload) the development version. If something goes wrong, you kill the second instance, restart it and you are back in business. If you use your primary emacs for testing the development version, you'd be toast in such a scenario. – NickD Feb 13 at 2:37
  • I turn off .el and .elc files by just changing the names, e.g., foo.el.off and foo.elc.off. If you have lots of them, then wdired/grep and multiple-cursors can do them all in one fell swoop. When your done developing or when you break Emacs so bad its unusable, disable the developmental and re-enable the tried/true working version. The tried/true versions can shadow/supersede the path to the developmental versions, but when the tried/true is off, the developmental is first in time. The entire directory on the load-path can be turned off/on; or change the load-path ... – lawlist Feb 13 at 3:06
  • Changing names whenever you want to develop a package isn't practical since it's too easy to forget to rename back (if you have many packages). – ideasman42 Feb 13 at 3:17
  • Uninstall the package or shadow the installed package via load-path, for example, with (use-package foo :ensure t :load-path "~/src/foo"), Emacs will prefer ~/src/foo. – xuchunyang Feb 13 at 3:24
  • Is it possible to optionally pass in :load-path "~/src/foo" ? otherwise I need to edit use-package use every time. – ideasman42 Feb 13 at 3:32
0

consider passing in a command line argument that alters the load-path perhaps? eg here I have a "-chat" switch.

(add-to-list 'command-switch-alist '("chat" . rgr/load-chats))
(defun rgr/load-chats(switch) 
  (require  'rgr-chat))

Modify this to modify the load-path right at the start of your init.el or whatever your startup is.

| improve this answer | |
  • I won't delete my answer yet, but now I think about it you'd need to ensure these are processed prior to the loading of your package of course – RichieHH Feb 13 at 15:40

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.