In the spacemacs documentation for writing layers, it says that "[o]nly one layer may own a package". This has the consequence, that if you write a layer that requires a package, you have to know whether you can claim ownership of it by writing a <layer>/init-<package> function, or if you have to use the post-init function for the package to avoid seizing "ownership of a package that was owned by a previously enabled layer".

Is there a function in spacemacs, that takes a package name and tells you if it is owned by any standard spacemacs layer? I know that you technically only need to know if the package is owned by a previously enabled layer, but such a function would also help prevent writing unnecessary code.

In case it's of interest, in my particular case, I'm interested in polymode.

1 Answer 1


There is no such function available. You can get this information in two ways.


You can retrieve the current owner of a package with this function (it requires helm layer to be used, it can be easily transposed to ivy layer for ivy users).

(defun get-package-owner (pkg-symbol)
  "Return the layer owner of the package with name PKG-SYMBOL.
Assumes that the `helm' layer is used (develop branch or version 0.200+ of Spacemacs)"
  (require 'helm-spacemacs-help)
  (let ((pkg (object-assoc pkg-symbol :name helm-spacemacs-help-all-packages)))
    (when pkg (oref pkg :owner))))

(get-package-owner 'flycheck) ; => syntax-checking


To get this information non programmatically there is Spacemacs help available on SPC h SPC or more specifically here SPC h p for just the packages source (it requires either the helm or ivy layer to be used).

  • 1
    (get-package-owner 'flycheck) ; => nil, (get-package-owner 'magit) ; => git. I'm guessing you have the syntax-checking layer enabled, while I don't. Is there away to do this for all known ("standard"?) layers, regardless of whether they are loaded?
    – flooose
    May 16, 2016 at 9:00
  • 2
    Yes it can be done, I'll edit the answer later today. In the meantime you can use SPC h SPC to get the answer you are looking for. Tell me if Spacemacs help is enough and I'll edit the answer accordingly.
    – syl20bnr
    May 16, 2016 at 11:21
  • Ah, I thought SPC h SPC was only for getting the README for a layer, but I see now that entering a package name lists it and in parenthesis its corresponding layer name. Entering for instance flycheck results in flycheck (syntax-checking layer), entering polymode on the other had doesn't show any results, so it's safe to add (and claim ownership) of it in one of my own layers. Very nice! I'd still appreciate seeing the code to do this, but I'm going to mark this as answered because it's actually exactly what I was looking for to begin with.
    – flooose
    May 16, 2016 at 12:44
  • Wait, actually your answer should reflect the information you just gave me. Once you do that, I'll mark your answer as the one that solved the problem :)
    – flooose
    May 16, 2016 at 12:50
  • 1
    Very nice! One more thing though SPC h p doesn't work when I use the latest version of spacemacs from git: git clone https://github.com/syl20bnr/spacemacs ~/.emacs.d. Could you be using a development version of spacemacs?
    – flooose
    May 16, 2016 at 15:59

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.