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

Make apheleia-mode lighter customizable #143

Merged
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog].

## Unreleased
### Features
* `apheleia-mode` lighter is now customizable ([#143]).

### Enhancements
* shfmt uses 4 spaces instead of tabs by default.
* Formatters using `'filepath` (OCamlFormat and Prettier) are no
Expand Down Expand Up @@ -71,6 +74,7 @@ The format is based on [Keep a Changelog].
[#128]: https://github.com/radian-software/apheleia/pull/128
[#132]: https://github.com/radian-software/apheleia/pull/132
[#137]: https://github.com/radian-software/apheleia/pull/137
[#143]: https://github.com/radian-software/apheleia/pull/143

## 3.0 (released 2022-06-01)
### Breaking changes
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@ The following user options are also available:
programming algorithm for point alignment. This cannot be too big or
Emacs will hang noticeably on large reformatting operations, since
the DP algorithm is quadratic-time.
* `apheleia-mode-lighter`: `apheleia-mode` lighter displayed in the
mode-line. If you don't want to display it, use nil. Otherwise, its
value must be a string.

Apheleia exposes some hooks for advanced customization:

Expand Down
8 changes: 7 additions & 1 deletion apheleia.el
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ compatible with this option and formatters relying on them will crash."
(const :tag "Run the formatter on the remote machine" remote)
(const :tag "Disable formatting for remote buffers" cancel)))

(defcustom apheleia-mode-lighter " Apheleia"
"Lighter for `apheleia-mode'."
:type '(choice :tag "Lighter" (const :tag "No lighter" nil) string)
:risky t
:group 'apheleia)

(cl-defun apheleia--edit-distance-table (s1 s2)
"Align strings S1 and S2 for minimum edit distance.
Return the dynamic programming table as has table which maps cons
Expand Down Expand Up @@ -1356,7 +1362,7 @@ operating, to prevent an infinite loop.")
"Minor mode for reformatting code on save without moving point.
It is customized by means of the variables `apheleia-mode-alist'
and `apheleia-formatters'."
:lighter " Apheleia"
:lighter apheleia-mode-lighter
(if apheleia-mode
(add-hook 'after-save-hook #'apheleia--format-after-save nil 'local)
(remove-hook 'after-save-hook #'apheleia--format-after-save 'local)))
Expand Down