Subject: bug#22891:

From: Anders Lindgren <[email-masked]>
Date: Sun, 24 Apr 2016 21:07:08 +0200

Hi!

Here comes a new patch with both changes. Unless anybody complains, I will
push it to "master".

Just a little concern: I just took a look at the Emacs lisp directory. I
estimate is that a majority (but no all) of calls to `window-width',
`window-text-width', and `window-body-width' really should be to
`window-max-chars-per-line'.

    -- Anders

On Sun, Apr 24, 2016 at 10:40 AM, martin rudalics <[email-masked]> wrote:

> > I think that I already have solved this, but awaiting confirmation I
> > haven't committed the change.
>
> Please either post a patch or install your changes.  From my experience,
> Constantine very reliably confirms whether it will work or not.
>
> martin
>
diff --git a/lisp/term.el b/lisp/term.el
index 2d5d3e9..28be8c8 100644
--- a/lisp/term.el
+++ b/lisp/term.el
@@ -919,19 +919,6 @@ is buffer-local."
 
 (term-set-escape-char (or term-escape-char ?\C-c))
 
-(defvar overflow-newline-into-fringe)
-
-(defun term-window-width ()
-  (if (and (not (featurep 'xemacs))
-	   (display-graphic-p)
-	   overflow-newline-into-fringe
-	   ;; Subtract 1 from the width when any fringe has zero width,
-	   ;; not just the right fringe.  Bug#18601.
-	   (/= (frame-parameter nil 'left-fringe) 0)
-	   (/= (frame-parameter nil 'right-fringe) 0))
-      (window-body-width)
-    (1- (window-body-width))))
-
 
 (put 'term-mode 'mode-class 'special)
 
@@ -1018,7 +1005,7 @@ Entry to this mode runs the hooks on `term-mode-hook'."
   (setq buffer-display-table term-display-table)
   (set (make-local-variable 'term-home-marker) (copy-marker 0))
   (set (make-local-variable 'term-height) (1- (window-height)))
-  (set (make-local-variable 'term-width) (term-window-width))
+  (set (make-local-variable 'term-width) (window-max-chars-per-line))
   (set (make-local-variable 'term-last-input-start) (make-marker))
   (set (make-local-variable 'term-last-input-end) (make-marker))
   (set (make-local-variable 'term-last-input-match) "")
diff --git a/lisp/window.el b/lisp/window.el
index e086efb..9f63e86 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -8560,10 +8560,10 @@ WINDOWS is a list of windows associated with PROCESS.  REDUCER is
 a two-argument function used to combine the widths and heights of
 the given windows."
   (when windows
-    (let ((width (window-body-width (car windows)))
+    (let ((width (window-max-chars-per-line (car windows)))
           (height (window-body-height (car windows))))
       (dolist (window (cdr windows))
-        (setf width (funcall reducer width (window-body-width window)))
+        (setf width (funcall reducer width (window-max-chars-per-line window)))
         (setf height (funcall reducer height (window-body-height window))))
       (cons width height))))