3

When I open a Python file I keep seeing Fill column set to 80 (was 80) message in the echo area. I know I have set it this limit , but I don't want to be keep reminded about it.

Is it possible to suppress this message?

my setup:

(add-hook 'python-mode-hook
  (lambda ()
    (setq indent-tabs-mode nil)
    (setq python-indent 4)
    (set-fill-column 80)
    (setq tab-width 4)))

2 Answers 2

8

@NickD answered the question well. But you can also do this, just to inhibit showing messages for set-fill-column:

(add-hook 'python-mode-hook
          (lambda ()
            (setq indent-tabs-mode  nil
                  python-indent     4
                  tab-width         4)
            (let ((inhibit-message  t))
              (set-fill-column 80))))

Or this:

(defun my-set-fill-column (arg)
  (let ((inhibit-message  t))
    (set-fill-column arg)))

(add-hook 'python-mode-hook
          (lambda ()
            (setq indent-tabs-mode  nil
                  python-indent     4
                  tab-width         4)
            (my-set-fill-column 80)))
6
  • Thanks for the inhibit-message reminder!
    – NickD
    Commented Mar 10, 2021 at 17:27
  • I keep having following debug error not sure what is wrong on my end: gist.github.com/avatar-lavventura/… . I can add this to my question if its required. Should I combine it with @NickD's function ?
    – alper
    Commented Mar 11, 2021 at 9:25
  • I think there was a typo in the my-set-fill-column function which I fixed. Can you try now?
    – NickD
    Commented Mar 11, 2021 at 13:59
  • @NickD I have also changed set-fill-column to my-set-fill-column; the error is fixed, thank you.
    – alper
    Commented Mar 11, 2021 at 17:00
  • Code examples 1 and 3 seem to be the same and should probably only reference set-fill-column not my-set-fill-column Commented Mar 12, 2021 at 15:58
3

Regarding the specific example case...

set-fill-column is a command which is only intended to be used interactively.

To set the fill column programmatically, just do this:

(setq fill-column 80)

Which is exactly what set-fill-column would do, after validating that 80 was a valid argument and displaying the message -- but you don't need anything to validate 80 as a fill column, and you don't want the message.

4
  • Could I also do (setq-default fill-column 80)
    – alper
    Commented Sep 28, 2021 at 10:21
  • You can; or alternatively use M-x customize-option which will likewise set the default.
    – phils
    Commented Sep 28, 2021 at 23:19
  • To be safe I did the both :-)
    – alper
    Commented Sep 29, 2021 at 0:12
  • If you do both then you'll probably forget that later if you ever try to change it, and potentially wind up confused that things aren't working. Just use one approach or the other.
    – phils
    Commented Sep 29, 2021 at 0:43

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.