help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Accessibility: fill-column for man pages and docstring help


From: Andreas Politz
Subject: Re: Accessibility: fill-column for man pages and docstring help
Date: Thu, 25 Dec 2008 05:34:22 +0100
User-agent: Mozilla-Thunderbird 2.0.0.17 (X11/20081018)

Samuel Wales wrote:
I use very large fonts.  This causes many things in emacs to be
unreadable.  The biggest ones are:

  1.  C-h f, C-h v, etc.: in order to read, I have to manually adjust
fill-column and reformat paragraphs.  Difficult.

Some time ago, I wanted something similar such that the help text
is always kept untruncated despite windowsize. I wrote some elisp
to do that. I don't know if that's working for you or if there is
a simpler way. It's attached to this mail.

It's basically using fill-region, so you might just want to use
that.


  2.  Man pages.  I don't know how to adjust the fill column.

That's fairly easy. If you use woman, you can customize
woman-fill-column and maybe use woman-reformat-last-file
afterwards.
man-mode respects the MANWIDTH environment variable, so something
like (setenv "MANWIDTH" "40") should work. Maybe even put it in
your shells initfile.

-ap

Is there a fix for both of these?

Notes:

     Note that readability also improves when fill-column is
     short.  This is why magazines and newspapers and some
     science papers have short columns.

     Also note that some people are likely to start using
     org-mode on small devices.

     Is it possible to use a shorter fill-column, say 60, in
     docstrings?

     I realize that this might be difficult, if the code
     itself uses a long fill-column, unless there is a way
     to make fill-paragraph work differently on docstrings.
     I also realize that it might be hard to automate the
     fixing of existing docstrings.

Note that some docstrings use lines that should not be folded.

Reducing font size is not an option.  This is an accessibility issue.

Thanks.


(defvar refill-help-buffer-max-fill-column 68)

(defun refill-help-buffer (&optional frame)
  (interactive)
  (walk-windows
   #'(lambda (win)
       (with-selected-window win
         (save-excursion
           (when (and (eq major-mode 'help-mode)
                      (or (< fill-column refill-help-buffer-max-fill-column)
                          (window-truncated-p))
                      (progn
                        (goto-char (point-min))
                        (forward-sentence)
                        (re-search-backward 
"variable\\|function\\|command\\|face\\|form\\|macro" nil t)))
             (let (buffer-read-only)
               (setq fill-column (min refill-help-buffer-max-fill-column
                                      (- (window-width) 1)))
               (fill-region (point-min) (point-max)))))))
   'no-minibuffer frame))

(defun window-truncated-p (&optional window)
  "Return non-nil if current window (or the argument) has some
truncated lines."
  (with-selected-window (or window (selected-window))
    (save-excursion
      (goto-char (point-min))
      (re-search-forward
       (format "^..\\{%d\\}" (window-width)) nil t))))

(defun refill-help-buffer-reset-fill-column-and-refill nil
  (setq fill-column 0)
  (refill-help-buffer))

(define-minor-mode refill-help-buffer-mode
  "Automatically fill help buffer to
 \(min `refill-help-buffer-max-fill-column' \(window-width\)\)
 on displaying and resizing."
  nil nil nil
  :global t
  (if refill-help-buffer-mode
      (progn
        (add-hook 'window-size-change-functions 'refill-help-buffer)
        (add-hook 'temp-buffer-show-hook 
'refill-help-buffer-reset-fill-column-and-refill))
    (remove-hook 'window-size-change-functions 'refill-help-buffer)
    (remove-hook 'temp-buffer-show-hook 
'refill-help-buffer-reset-fill-column-and-refill)))

(provide 'refill-help-buffer)

reply via email to

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