I need to check numbers in a buffer each on a line against an external paper sheet

To make this easier I would like to make the window very narrow to see only one (or max. two) lines. However shrink-window stops at three lines.

Any way to overcome this limitation of shrink-window?

3 Answers 3


The following shows one line of content and the modeline for me:

(setq window-safe-min-height 0)
(setq window-min-height 0)

I would love to have a way to make the content completely collapse for an acme editor style. Sadly I haven't found the way.

  • 1
    How cool is this! I didn't know about window-safe-min-height. Just read the doco though. It says: "The absolute minimum number of lines of any window. Anything less might crash Emacs.", so with (setq window-safe-min-height 0) I might live on the edge... 😉
    – halloleo
    Commented Sep 14, 2021 at 2:41
  • Yeah, (setq window-safe-min-height -1) kind of does what I want, but sometimes the modelines merges into eachother :) Commented Sep 14, 2021 at 6:29
  • You kinda did know about window-safe-min-height because it was mentioned in the earlier answer, and you commented on it ;) I wonder if the behaviour around minimum values has changed since then.
    – phils
    Commented Sep 14, 2021 at 23:32

C-hv window-min-height

The minimum total height, in lines, of any window. The value has to accommodate one text line, a mode and header line, a horizontal scroll bar and a bottom divider, if present. A value less than ‘window-safe-min-height’ is ignored. The value of this variable is honored when windows are resized or split.

I found this with M-x apropos-variable RET height RET

  • With this variable I was able to shrink the window to two lines, but not to one line.
    – halloleo
    Commented Jul 5, 2020 at 13:39
  • This is true, even if I set window-min-height to 1 (and window-safe-min-height is 1 as well).
    – halloleo
    Commented Jul 5, 2020 at 13:51
  • The minimum is one editing line plus whatever additional lines are needed to display those other items. If you have none of the other items (including disabling the mode line!) then you can have a window which is just that one single editing line. (I just tested this in Emacs 26.3 in a terminal.)
    – phils
    Commented Jul 5, 2020 at 15:06
  • You are correct: without mode line I do get the window down to 1 content line. However, with mode line this doesn't seem to be possible: I always end up with two content lines. Very strange!
    – halloleo
    Commented Jul 10, 2020 at 6:29

Would it suit your purpose if you had a command which searched for the next line in the buffer which has a number in it and then showed you just that line?

(defun go-to-next-line-with-number ()
  (unless (bobp)
  (when (search-forward-regexp "[0-9]" nil 0)
      (narrow-to-region (progn (beginning-of-line) (point))
                        (progn (end-of-line) (point))))))

Assign this command to a key, then go to the beginning of the buffer. Calling this command will go to the first line with a number and show you only this line. When you have done whatever editing you need to do to this line, call it again to go to the next line with a number and so on until you reach the end of the buffer.

If this is close but not precisely what you need, tell me more exactly what would help.

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.