3

I am using diminish for minor modes. But I was not able to apply it for apheleia-mode.

(apheleia-global-mode +1)
(with-eval-after-load 'apheleia
  (setf (alist-get 'isort apheleia-formatters)
        '("isort" "--stdout" "-"))
  (setf (alist-get 'python-mode apheleia-mode-alist)
        '(isort black))
  )
(diminish 'apheleia-mode)
(diminish 'apheleia-global-mode)

I keep see following Apheleia at bottom line:

Driver.py ~/program/user Git:dev (home) [Py] Top (15, 0) Apheleia------------

How can I suppress Apheleia word at the bottom line?

6
  • Your mode line looks strange to me, but not calling diminish within the with-eval-after-load is probably your problem (although I'd also expect an error). (Edit: Or not... assuming apheleia-global-mode is autoloaded, given that you called that first, the library should be loaded.)
    – phils
    Feb 3, 2022 at 11:23
  • Simplest test is C-h v minor-mode-alist. If the apheleia-mode entry has associated lighter text then diminish has failed to affect it. If it doesn't, it's done what you asked it to do, and what's in the mode line is something different (at which point you might start from C-h v mode-line-format and drill down into the component vars).
    – phils
    Feb 3, 2022 at 11:30
  • I believe apheleia-mode loaded after a save operation takes (due to Run code formatters on after-save-hook, rather than before-save-hook, and do so asynchronously. ) place in the buffer which cause to run after diminish loaded
    – alper
    Feb 3, 2022 at 13:16
  • 1
    I removed following line github.com/raxod502/apheleia/blob/… , which seems like solved it. Like you said it was lighter text
    – alper
    Feb 3, 2022 at 18:47
  • The question was cross-posted here: github.com/raxod502/apheleia/issues/79
    – phils
    Feb 4, 2022 at 0:53

1 Answer 1

5

Instead of this:

(apheleia-global-mode +1)
(with-eval-after-load 'apheleia
  ...
  )
(diminish 'apheleia-mode)

Do this:

(diminish 'apheleia-mode)
(apheleia-global-mode +1)
(with-eval-after-load 'apheleia
  (diminish 'apheleia-mode)
  ...
  )

Which is weird...

In general if you're using diminish you should always use it in conjunction with with-eval-after-load, because diminish.el doesn't provide for that itself; it trusts that you are only ever using it after loading the library in question.

That said, apheleia.el has done something very unexpected here. Rather than declaring its modes as autoloaded, it has put the full mode definitions into the autoloads file!

This means:

  1. apheleia-mode and its lighter text are already defined as soon as your package manager loads the autoloads file, so you need to diminish that immediately, outside of the with-eval-after-load form.

  2. Your call to apheleia-global-mode is not loading apheleia.el as you might expect. Instead it arranges (via other autoloads) that the library will be loaded when after-save-hook fires.

  3. When the after-save-hook fires and actually loads the library, apheleia-mode is re-defined and your diminished lighter text is clobbered, so you need to diminish it again.

4
  • Thanks as always well explained great answer
    – alper
    Feb 4, 2022 at 8:53
  • Should I (diminish 'apheleia-global-mode) as well? or (diminish 'apheleia-mode) covers it?
    – alper
    Feb 4, 2022 at 8:56
  • 2
    I think apheleia-global-mode has no lighter text of its own. It's a globalized minor mode controlling apheleia-mode, so it doesn't really need to advertise itself like that. I'm pretty sure apheleia-mode is all you care about.
    – phils
    Feb 4, 2022 at 10:10
  • 1
    As update developer added the following option (apheleia-mode-lighter nil)
    – alper
    Apr 12, 2023 at 17:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.