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?


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 Jul 5 '20 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 Jul 5 '20 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 Jul 5 '20 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 Jul 10 '20 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, privacy policy and cookie policy

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