emacs-devel
[Top][All Lists]
Advanced

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

Re: man.el


From: Juri Linkov
Subject: Re: man.el
Date: Sat, 21 Feb 2004 03:04:12 +0200
User-agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux)

Richard Stallman <address@hidden> writes:
> Regarding the change below, why is the current window's width more
> likely to be correct than the frame's width?  (Neither one is
> guaranteed to be right.)

The window's width is more correct than the frame's width when the
frame is split horizontally, the method of notification is not `bully'
or `newframe', and user don't change the window configuration after
invoking man in the background.  Since man formats pages
asyncronically, it should know the number of columns before its
invocation.  But for the moment when man page is ready the user can
change the window configuration (split window, or delete other
windows, or change frame's or window's widths).  This means that
neither window's width nor frame's width is correct, and restoring
the original window configuration before displaying the man page
may be not desirable for the user.

So instead of arguing which of the incorrect methods is more correct,
it could be left completely to user's discretion.  A new defcustom
variable Man-width can have an integer value for explicit number of
columns, or a special value for either frame-width or window-width.
Along with the Man-notify-method option the user can use the Man-width
to specify preferences for displaying man pages.

Index: emacs/lisp/man.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/man.el,v
retrieving revision 1.132
diff -c -r1.132 man.el
*** emacs/lisp/man.el   16 Feb 2004 18:20:31 -0000      1.132
--- emacs/lisp/man.el   21 Feb 2004 01:57:20 -0000
***************
*** 175,180 ****
--- 175,191 ----
                (const polite) (const quiet) (const meek))
    :group 'man)
  
+ (defcustom Man-width nil
+   "*Number of columns for which manual pages should be formatted.
+ If nil, the width of the frame selected at the moment of man
+ invocation is used.  If non-nil, the width of the window selected
+ at the moment of man invocation is used.  The value also can be a
+ positive integer."
+   :type '(choice (const :tag "Frame width" nil)
+                  (const :tag "Window width" t)
+                  (integer :tag "Specific width" :value 65))
+   :group 'man)
+ 
  (defcustom Man-frame-parameters nil
    "*Frame parameter list for creating a new frame for a manual page."
    :type 'sexp
***************
*** 679,685 ****
              ;; This isn't strictly correct, since we don't know how
              ;; the page will actually be displayed, but it seems
              ;; reasonable.
!             (setenv "COLUMNS" (number-to-string (frame-width)))))
        (setenv "GROFF_NO_SGR" "1")
        (if (fboundp 'start-process)
            (set-process-sentinel
--- 690,701 ----
              ;; This isn't strictly correct, since we don't know how
              ;; the page will actually be displayed, but it seems
              ;; reasonable.
!             (setenv "COLUMNS" (number-to-string
!                                (cond
!                                 ((and (integerp Man-width) (> Man-width 0))
!                                  Man-width)
!                                 (Man-width (window-width))
!                                 ((frame-width)))))))
        (setenv "GROFF_NO_SGR" "1")
        (if (fboundp 'start-process)
            (set-process-sentinel
***************
*** 757,763 ****
    "Convert overstriking and underlining to the correct fonts.
  Same for the ANSI bold and normal escape sequences."
    (interactive)
!   (message "Please wait: making up the %s man page..." Man-arguments)
    (goto-char (point-min))
    (while (search-forward "\e[1m" nil t)
      (delete-backward-char 4)
--- 773,779 ----
    "Convert overstriking and underlining to the correct fonts.
  Same for the ANSI bold and normal escape sequences."
    (interactive)
!   (message "Please wait: formatting the %s man page..." Man-arguments)
    (goto-char (point-min))
    (while (search-forward "\e[1m" nil t)
      (delete-backward-char 4)
***************
*** 976,981 ****
--- 992,1000 ----
    (auto-fill-mode -1)
    (use-local-map Man-mode-map)
    (set-syntax-table man-mode-syntax-table)
+   (setq imenu-generic-expression (list (list nil Man-heading-regexp 0)))
+   (set (make-local-variable 'outline-regexp) Man-heading-regexp)
+   (set (make-local-variable 'outline-level) (lambda () 1))
    (Man-build-page-list)
    (Man-strip-page-headers)
    (Man-unindent)

The patch for woman.el follows below.  Note that in the woman.el for
the analogous purpose the frame-window can be changed to window-width
unconditionally because woman displays man pages in the same window
where it was invoked.

Index: emacs/lisp/woman.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/woman.el,v
retrieving revision 1.18
diff -c -r1.18 woman.el
*** emacs/lisp/woman.el 22 Sep 2003 15:15:26 -0000      1.18
--- emacs/lisp/woman.el 21 Feb 2004 01:57:23 -0000
***************
*** 807,813 ****
  
  (defcustom woman-fill-frame nil
    ;; Based loosely on a suggestion by Theodore Jump:
!   "*If non-nil then most of the frame width is used."
    :type 'boolean
    :group 'woman-formatting)
  
--- 807,813 ----
  
  (defcustom woman-fill-frame nil
    ;; Based loosely on a suggestion by Theodore Jump:
!   "*If non-nil then most of the window width is used."
    :type 'boolean
    :group 'woman-formatting)
  
***************
*** 2204,2210 ****
      ;; Based loosely on a suggestion by Theodore Jump:
      (if (or woman-fill-frame
            (not (and (integerp woman-fill-column) (> woman-fill-column 0))))
!       (setq woman-fill-column (- (frame-width) woman-default-indent)))
  
      ;; Check for preprocessor requests:
      (goto-char from)
--- 2204,2210 ----
      ;; Based loosely on a suggestion by Theodore Jump:
      (if (or woman-fill-frame
            (not (and (integerp woman-fill-column) (> woman-fill-column 0))))
!       (setq woman-fill-column (- (window-width) woman-default-indent)))
  
      ;; Check for preprocessor requests:
      (goto-char from)

-- 
http://www.jurta.org/emacs/





reply via email to

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