Automatically fix common code style issues in Elisp.
Name | Version |
---|---|
Emacs | 27.1 |
package-lint | 0.17 |
(use-package autofix
:straight (autofix
:repo "KarimAziev/autofix"
:type git
:host github)
:bind ((:map autofix-multi-completion-map
("C-<return>" . autofix-throw-done)
("C-M-j" . autofix-throw-done)))
:commands (autofix
autofix-footer
autofix-remove-unused-declarations
autofix-header
autofix-autoloads
autofix-commentary
autofix-code-comment
autofix-header-first-line
autofix-sharpquotes
autofix-scan-extract-all-docs
autofix-annotate-buffer
autofix-url
autofix-copyright
autofix-license
autofix-add-fbound
autofix-keywords
autofix-header-body-comment
autofix-package-requires
autofix-version
autofix-update-version
autofix-author))
Download the source code and put it wherever you like, e.g. into ~/.emacs.d/autofix/
git clone https://github.com/KarimAziev/autofix.git ~/.emacs.d/autofix/
Add the downloaded directory to the load path:
(add-to-list 'load-path "~/.emacs.d/autofix/")
(require 'autofix)
Runs autofix
on file save when this mode is turned on.
Apply all functions from autofix-functions
. Default code fixes includes auto adding auto load comments before all interactive commands and removing unused (declare-function …) forms. Default comments fixes includes fixes for file headers, package headers, footer etc. File headers fixes can be customized via autofix-header-functions
.
Add of fix file footer e.g. in the file myfile.el
it will add or replace:
(provide 'myfile)
;;; myfile.el ends here
Check usage and remove unused declarations:
(declare-function unused-function)
Apply fixes for header comments.
You can add or remove commands by customizing the variable autofix-header-functions
.
Command | Description |
---|---|
autofix-header-first-line | Fix or create the first comment line in the header |
autofix-copyright | Prompt and fix or make new copyright |
autofix-author | Add or fix author |
autofix-url | Add of fix URL |
autofix-version | Add or fix package version |
autofix-keywords | Add or fix package keywords |
autofix-package-requires | Add or fix package requires section |
autofix-header-body-comment | Add comment body (M-x autofix-comment-section-body ) |
autofix-commentary | Add Commentary section in current buffer if none |
autofix-code-comment | Add Code comment to the end of header block |
autofix-license | Add SPDX short-form identifier (M-x customize-variable autofix-spdx-license ) |
Add autoload comments before commands in buffer, that doesn’t look like private.
Add a sharpquote (=#’=) when quoting function names. For example, such code:
(mapcar 'car '(a b c d))
Transforms to:
(mapcar #'car '(a b c d))
You can customize rules by customing a variable autofix-sharpquote-symbols-spec
.
Return string with all docs in all buffer. If called interactively also copies it.
Add annotations in header comment section, e.g.:
;;; Commands
;; M-x `autofix'
;; Apply all functions from `autofix-functions'.
;; Default code fixes includes auto adding auto load comments before all
;; interactive commands and removing unused (declare-function ...) forms.
;; Default comments fixes includes fixes for file headers,
;; package headers, footer etc.
;; File headers fixes can be customized via `autofix-header-functions'.
;; M-x `autofix-footer'
;; Add of fix file footer (provide ='filename) with comment ends here.
Wrap undefined function call in fbound.
List of file name bases to ignore.
User email to add in header section.
User email to add in header section. Can be string, variable or function. Function will be called without args and should return string.
List of functions to apply with command autofix
.
Default spdx
short-form identifier.
Alist of symbols and required sharpquote positions. Each element is a cons which car is either symbol or list of symbols, which cdr is a position of children element, that should be sharquoted.
Static text for adding in header comment section. It doesn’t includes dynamic variables such author, year etc.