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)))
Tyler
  • 21,719
  • 1
  • 52
  • 92
alper
  • 1,238
  • 11
  • 30

2 Answers2

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)))
Drew
  • 75,699
  • 9
  • 109
  • 225
  • Thanks for the `inhibit-message` reminder! – NickD Mar 10 '21 at 17:27
  • I keep having following debug error not sure what is wrong on my end: https://gist.github.com/avatar-lavventura/c18994af8640daa68943c0e7d5c59ae0 . I can add this to my question if its required. Should I combine it with @NickD's function ? – alper Mar 11 '21 at 09:25
  • I think there was a typo in the `my-set-fill-column` function which I fixed. Can you try now? – NickD Mar 11 '21 at 13:59
  • @NickD I have also changed `set-fill-column ` to `my-set-fill-column`; the error is fixed, thank you. – alper Mar 11 '21 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` – Andrew Swann Mar 12 '21 at 15:58
  • Corrected typos etc. The point is just to `inhibit-message` around a call to `set-fill-column`. – Drew Mar 12 '21 at 16:41
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.

phils
  • 48,657
  • 3
  • 76
  • 115