Skip to content

Commit

Permalink
Make apheleia-mode lighter customizable (#143)
Browse files Browse the repository at this point in the history
<!--

To expedite the pull request process, please see the contributor guide
for my projects:

  <https://github.com/raxod502/contributor-guide>

-->

Co-authored-by: Radon Rosborough <radon@intuitiveexplanations.com>
  • Loading branch information
xFA25E and raxod502 authored Nov 12, 2022
1 parent b4aa52d commit d721687
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
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

0 comments on commit d721687

Please sign in to comment.