3

I'm attempting to make changes to an Emacs package. I currently have the version in use installed in ~/.emacs.d/elpa/<package> and the source checked out from git in /src/<package>.

When I navigate to, for example, fileA.el in /src/<package> and press M-. (xref-find-definitions) on an identifier in fileB.el, Emacs will jump into ~/.emacs.d/elpa/<package>/fileB.el. I would prefer if it instead jumped to /src/<package>/fileB.el.

Now, I've created a TAGS file, and that seems to work correctly if I call M-x xref-etags-mode prior to using M-.. However, I don't want to remember to do that for every buffer that I open. Is there an easier solution?

For clarity, /src/<package> is /not/ on my load-path (and I would like to keep it that way).

2 Answers 2

1

While working on its code, you can open /src/<packages>/fileA.el and call M-x eval-buffer. Do the same for the rest of the files in the said package that you might want to navigate to. That will make Emacs remember the new locations of the functions in this package.

This is a solution for the built-in elisp xref backend. Not need for xref-etags-mode for that.

2
  • This is helpful. Is it possible to do this automatically for all files within a directory from within emacs? Commented Jan 17, 2019 at 1:25
  • In a comment to the other answer you're saying you don't want your changes to be used by that emacs session. But that's exactly what my advice will do anyway.
    – Dmitry
    Commented Jan 17, 2019 at 4:06
0

Evaluating buffers proposed by Dmitry is what doesn't require any configuration.
But it may create additional mental load to remember eval-buffers.
Also it makes pristine installed package's functions inaccessible(without another eval-buffer).

A method with package system setup

Example with installed Helm package and a dev git repository. Code snippet in Emacs init.

(if (getenv "MYDEV")
    (progn
      ;; disable activation of some installed packages
      (setq package-load-list
            (append '((helm nil))
                    '((helm-core nil))
                    package-load-list))

      ;; add dev repository to `load-path'
      (add-to-list 'load-path "~/some_path_to_repo/helm")

      (package-initialize)

      ;; now load code from dev repository as its docs recommend
      (load "helm-config.el"))
  ;; else
  (package-initialize))

Then to launch in terminal an instance of Emacs that will use dev git repository:

[user@user-pc ~]$ MYDEV=on emacs

xref will jump to definitions of symbols in loaded files(git repo)

2
  • The problem here is that I need to add the package to my load-path for this to work. I don't want to have to do this. I don't want my changes to be used by the emacs session that I'm using to modify the code. Commented Jan 17, 2019 at 1:21
  • @KevinSchwarz that's exactly what this setup does. Changes of repository Elisp files are in effect only in other Emacs instance launched with environment variable prefix. Commented Jan 17, 2019 at 2:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.