0

Is it possible to determine whether global-display-fill-column-indicator-mode or display-fill-column-indicator-mode was enabled?

I am running Emacs 27.2.

1
  • I'm guessing this question is a duplicate...
    – Drew
    Aug 29, 2022 at 21:42

2 Answers 2

1

All minor modes have an associated variable that's the same name as the function to toggle the mode. When a mode is local and has a global variant, the global variant has its own variable.

So, for example, to check whether Display-Fill-Column-Indicator mode is enabled in the current buffer, check the value of the variable display-fill-column-indicator-mode. You don't need to worry whether it was turned on via the local or global function: display-fill-column-indicator-mode reflects whether the mode is active in the buffer regardless of how it was activated.

2
  • Right. But when global-display-fill-column-indicator-mode was enabled by the user and I want to disable on all buffers, then I also can do (if global-display-fill-column-indicator-mode?
    – Dilna
    Aug 29, 2022 at 16:54
  • @Randy The mode can be disabled in some buffers even if it's enabled globally, and can be enabled in some buffers even if it's disabled globally. (global-display-fill-column-indicator-mode 0) disables the mode in all buffers. You can check the variable global-display-fill-column-indicator-mode to see if the global mode is enabled. Aug 29, 2022 at 17:23
-1

Evaluate (memq 'display-fill-column-indicator-mode local-minor-modes).

7
  • Not sure about this one. Does local-minor-modes actually exist?
    – Dilna
    Aug 29, 2022 at 14:16
  • Did you do C-h v local-minor-modes?
    – NickD
    Aug 29, 2022 at 14:30
  • Did you try it? Did it not work? If not, what was the problem? Just adding a comment without actually testing anything is useless: either test it and say what exactly went wrong or accept the answer. FWIW, I tested it and it seems to work as advertised.
    – NickD
    Aug 29, 2022 at 14:32
  • Not in Emacs 27.2
    – Dilna
    Aug 29, 2022 at 14:56
  • That would be the thing to say in your first comment - version differences are also why it is important to always specify the version of your emacs (plus any other relevant packages) in your question. In this instance, the variable was called minor-modes and it was renamed to local-minor-modes at some point, but I'm not sure in which release: try the earlier name minor-modes instead.
    – NickD
    Aug 29, 2022 at 15:40

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.