[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#32536: displayed width of man pages

From: Juri Linkov
Subject: bug#32536: displayed width of man pages
Date: Fri, 31 Aug 2018 02:35:45 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu)

> As a feature request:
> How about changing the effect of Man-width, or an additional setting:
> Emacs could usefully format manual pages to fit the window when the
> window is narrower than the default width of manual pages (unless the
> window is ridiculously narrow, in which case it could fall back to the
> default width for manual pages) and format them no wider than the
> default width of manual pages for windows that are wider.

Thanks for the feature request.

As proposed in https://debbugs.gnu.org/cgi/bugreport.cgi?bug=9385
this patch implements a new option "Maximum width" as a hard limit
that prevents the width to grow over this value:

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 
                  (integer :tag "Fixed width" :value 65))
   :group 'man)
@@ -1045,16 +1046,20 @@ Man-start-calling
                          ((and (integerp Man-width) (> Man-width 0))
-                         (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)
-                          (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).

reply via email to

[Prev in Thread] Current Thread [Next in Thread]