> But when I debug window-recenter-region-start-position, the height is > set to 0. The patch below seems to fix the problem. [...] > + (body-pixel-width (window-body-width window t)) > + (body-pixel-height (window-body-height window t)) You're right. I meanwhile fixed the code to calculate how many lines to step backwards by using 'window-text-pixel-size' there too. So now this should work with text scaling and varying line heights too. If you want to test it with 'recenter-region', then a rough estimate is that the number of lines shown after the first "L:" should be equal to or one less than the number of lines shown after the third "L:" in each message issued. Thanks, martin