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

Add support for bibtex-mode #294

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions apheleia-formatters.el
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
(apheleia-formatters-indent
"--tab" "--indent-size" 'sh-basic-offset)
"-"))
(bibtex-format . apheleia-reformat-bibtex-buffer)
(black . ("black"
(when (apheleia-formatters-extension-p "pyi") "--pyi")
(apheleia-formatters-fill-column "--line-length")
Expand Down Expand Up @@ -290,6 +291,7 @@ rather than using this system."
(bash-ts-mode . shfmt)
(bazel-mode . buildifier)
(beancount-mode . bean-format)
(bibtex-mode . bibtex-format)
(c++-ts-mode . clang-format)
(caddyfile-mode . caddyfmt)
(cc-mode . clang-format)
Expand Down Expand Up @@ -1123,6 +1125,19 @@ For more implementation detail, see
(indent-region (point-min) (point-max)))
(funcall callback)))

(cl-defun apheleia-reformat-bibtex-buffer
(&key buffer scratch callback &allow-other-keys)
"Format a Bibtex BUFFER.
Use SCRATCH as a temporary buffer and CALLBACK to apply the
transformation.

For more implementation detail, see
`apheleia--run-formatter-function'."
(with-current-buffer scratch
(funcall (with-current-buffer buffer major-mode))
(bibtex-reformat)
(funcall callback)))

(defun apheleia--run-formatters
(formatters buffer remote callback &optional stdin)
"Run one or more code formatters on the current buffer.
Expand Down
Loading