purcell / package-lint

A linting library for elisp package metadata
GNU General Public License v3.0
192 stars 33 forks source link

Support read-symbol-shorthands when checking prefixes #238

Open dannyob opened 1 year ago

dannyob commented 1 year ago

Thanks to shorthands, it's now possible for the prefix of a source file's definitions to not match their actual prefixes -- i.e. if you set read-symbol-shorthands to (("vlp-" . "very-long-prefix-")) in the file very-long-prefix.el, then definitions that are named "vlp-foobar" will be transformed into "very-long-prefix-foobar."

This confuses package-lint's package checker. As a hack, I was able to remove the warnings by adding, e.g, ("very-long-prefix" . ("vlp")) to package-lint--allowed-prefix-mappings. I think a better fix would have to start by adding a clause to package-lint--valid-definition-name-p but I'm too much of an emacs lisp newbie to be confident of what to do here!

fosskers commented 7 months ago

I attempted this workaround, but it didn't seem to work. I tried to set it via:

(add-to-list 'package-lint--allowed-prefix-mappings '("transducers-" . ("t-")))

But functions like package-lint-current-buffer still report all the prefixing errors.

sellout commented 7 months ago

For package-lint, you need to omit the trailing hyphen that you include in read-symbol-shorthands, so try

(add-to-list 'package-lint--allowed-prefix-mappings '("transducers" . ("t")))
fosskers commented 7 months ago

That's odd, given that the original defvar doesn't seem to follow that convention:

(defvar package-lint--allowed-prefix-mappings
  '(("ob-" . ("org-"))
    ("oc-" . ("org-"))
    ("ol-" . ("org-"))
    ("ox-" . ("org-")))
  "Alist containing mappings of package prefixes to symbol prefixes.")
fosskers commented 7 months ago

That worked though, thank you!