Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it acceptable to add new formatter for emacs-lisp, which is emacs package itself? (elisp-autofmt) #235

Open
ed9w2in6 opened this issue Aug 7, 2023 · 1 comment

Comments

@ed9w2in6
Copy link

ed9w2in6 commented Aug 7, 2023

I have added this formatter in my own config:

(define-format-all-formatter
 elisp-autofmt
 (:executable)
 (:install "M-x package-install elisp-autofmt")
 (:languages "Emacs Lisp")
 (:features region)
 (:format
  (format-all--buffer-native
   'elisp-autofmt-mode
   (if region
       (lambda () (elisp-autofmt-region (car region) (cdr region)))
     (lambda () (elisp-autofmt-region (point-min) (point-max)))))))

I have been using this for a while, which works pretty well, and IMHO much better than the default one (Emacs).

May I ask if this is acceptable for this package to add a formatter that depends on another emacs package?
And what do you expect in a pull request?

@lassik
Copy link
Owner

lassik commented Aug 8, 2023

May I ask if this is acceptable for this package to add a formatter that depends on another emacs package?

Yes, absolutely. The following already supported formatters are Emacs-native:

  • auctex
  • emacs-bibtex
  • emacs-bibtex-sort
  • ledger-mode

Of these, at least ledger-mode is a third-party package that does not ship with Emacs.

For native formatters, the main thing is to use (funcall 'elisp-autofmt-region ...) instead of (elisp-autofmt-region ...). The later form assumes that the function is defined, which it won't be if the package is not installed.

We don't currently have a standard way to check whether or not a native package has been installed. I can add that at some point. For now, your code above is fine. Just do the funcall thing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants