On 2 Mar 2009, at 20:33, Stefan Monnier wrote: >> I don't know how to fix this given that there seems to be no way to >> calculate the (average) character width of text with a given face. > > That's unfortunate, indeed. > >> I haven't encountered such an issue with 22. > > The code in Emacs-22, just used a hard-coded 79. OK, perhaps we could use something like (if (assq 'default face-remapping-alist) 79 (window-width)) to cover at least the case that I've encountered. A grep over the source, looking for (window-width), reveals other suspicious uses. I haven't examined it further, but take simple.el, line-move-visual: (cond ((eq (nth 1 posn) 'right-fringe) ; overflow-newline-into- fringe (setq temporary-goal-column (- (window-width) 1))) `temporary-goal-column' refers to buffer columns; window-width does not. Or, abbrev.el: (while abbrev-list (if (> (+ first-column 40) (window-width)) (progn first-column seems to refer to the buffer, again. Or, term.el: `term-window-width' uses (window-width) and I would assume that this (`term-width') is what is used by processes running in the terminal (COLUMNS). Also, there's the longlines-mode case, but I've reported that before and we have a suitable replacement thanks to word wrapping. I think we need something like "window-buffer-width", giving the average (expected) number of columns in a window for text in the default face applicable to the buffer shown in a given window.