0

I tried to use column-enforce-mode but I don't want it on web-mode I tried to disable it but without success.

(global-column-enforce-mode t)
(remove-hook 'web-mode 'column-enforce-mode nil)

The code above doesn't work. What is the proper way on doing it?

  • @Drew it is a minor mode to check code width, here is the repo github.com/jordonbiondo/column-enforce-mode – zer09 Sep 5 '18 at 23:32
  • sorry, I cant understand what you mean on "recipe"? I am still learning about emacs and I am not that fluent in emacs lisp. btw what I want is to enable column-enforce-mode but not in web-mode especially on html files. Then I tried that code above but the column-enforce-mode is still active on html , I thought the remove-hook will disable it if I am on web-mode – zer09 Sep 5 '18 at 23:47
1

The doc of define-globalized-minor-mode says:

When a major mode is initialized, MODE is actually turned on just after running the major mode’s hook. However, MODE is not turned on if the hook has explicitly disabled it.

That means you should explicitly disable column-enforce-mode in web-mode-hook. I.e.:

(defun my-web-mode-hook-fun ()
  "Disable `column-enforce-mode' in `web-mode'."
  (column-enforce-mode -1))

(add-hook 'web-mode-hook #'my-web-mode-hook-fun)

This is the general approach for globalized minor modes. It is not tested for your special case of column-enforce-mode since I don't use it. Please test the code and report whether it works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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