diff --git a/lisp/man.el b/lisp/man.el index 1a6eda13b7..fcf9085d20 100644 --- a/lisp/man.el +++ b/lisp/man.el @@ -179,6 +179,7 @@ Man-width The value also can be a positive integer for a fixed width." :type '(choice (const :tag "Window width" nil) (const :tag "Frame width" t) + (cons :tag "Maximum width" (const :value max) (integer :value 80)) (integer :tag "Fixed width" :value 65)) :group 'man) @@ -1045,16 +1046,20 @@ Man-start-calling (cond ((and (integerp Man-width) (> Man-width 0)) Man-width) - (Man-width + ((eq Man-width t) (if (window-live-p (get-buffer-window (current-buffer) t)) (with-selected-window (get-buffer-window (current-buffer) t) (frame-width)) (frame-width))) (t - (if (window-live-p (get-buffer-window (current-buffer) t)) - (with-selected-window (get-buffer-window (current-buffer) t) - (window-width)) - (window-width))))))) + (let ((width + (if (window-live-p (get-buffer-window (current-buffer) t)) + (with-selected-window (get-buffer-window (current-buffer) t) + (window-width)) + (window-width)))) + (if (eq (car-safe Man-width) 'max) + (min width (cdr Man-width)) + width))))))) ;; Since man-db 2.4.3-1, man writes plain text with no escape ;; sequences when stdout is not a tty. In 2.5.0, the following ;; env-var was added to allow control of this (see Debian Bug#340673).