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

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

bug#14754: 24.3.50; `C-h v' needs to fill wide `pp' lines (493 chars wid


From: Drew Adams
Subject: bug#14754: 24.3.50; `C-h v' needs to fill wide `pp' lines (493 chars wide?!)
Date: Sun, 30 Jun 2013 00:10:19 -0700 (PDT)

The lines in the *Help* buffer should respect `fill-column' as much as
possible, other things being equal.

emacs -Q

C-h v imagemagick-enabled-types

You see the value printed on a single line that is 493 chars wide!
That's ridiculous, and it does not play well with code that fits the
*Help* frame or window to its buffer text etc.

The problem is this part of `describe-variable':

(let ((from (point))
      (line-beg (line-beginning-position))
      (print-rep
       (let ((print-quoted t))
         (prin1-to-string val))))
  (if (< (+ (length print-rep) (point) (- line-beg)) 68)
      (insert print-rep)
    (terpri)
    (pp val)
    (if (< (point) (+ 68 (line-beginning-position 0)))
        (delete-region from (1+ from))
      (delete-region (1- from) from)))
  (let* ((sv (get variable 'standard-value))
         (origval (and (consp sv)
                       (condition-case nil
                           (eval (car sv))
                         (error :help-eval-error)))))
    (when (and (consp sv)
               (not (equal origval val))
               (not (equal origval :help-eval-error)))
      (princ "\nOriginal value was \n")
      (setq from (point))
      (pp origval)
      (if (< (point) (+ from 20))
          (delete-region (1- from) from)))))

Better would be something like the following.  It fills the
pretty-printed value, and it adds a newline before it if the
value to be printed is not a number, a symbol, a character,
or a string with no newlines.  That's a simple heuristic,
but it's not too bad.

(let ((from (point))
      (line-beg (line-beginning-position))
      (print-rep
       (let ((print-quoted t))
         (prin1-to-string val))))
  (if (< (+ (length print-rep) (point) (- line-beg)) 68)
      (insert print-rep)
    (terpri)
    (unless (or (numberp val) (symbolp val) (characterp val)
                (and (stringp val) (string-match-p "[n]" val)))
      (terpri))
    (let ((beg  (point)))
      (pp val)
      (fill-region beg (point)))
    (if (< (point) (+ 68 (line-beginning-position 0)))
        (delete-region from (1+ from))
      (delete-region (1- from) from)))
  (let* ((sv (get variable 'standard-value))
         (origval (and (consp sv)
                       (condition-case nil
                           (eval (car sv))
                         (error :help-eval-error)))))
    (when (and (consp sv)
               (not (equal origval val))
               (not (equal origval :help-eval-error)))
      (princ "\nOriginal value was \n")
      (setq from (point))
      (unless (or (numberp origval) (symbolp origval) (characterp origval)
                  (and (stringp origval) (string-match-p "[n]" origval)))
        (terpri))
      (let ((beg  (point)))
        (pp origval)
        (fill-region beg (point)))
      (if (< (point) (+ from 20))
          (delete-region (1- from) from)))))

In GNU Emacs 24.3.50.1 (i686-pc-mingw32)
 of 2013-06-27 on ODIEONE
Bzr revision: 113205 dgutov@yandex.ru-20130627095155-f1lv1c7xf99g1sss
Windowing system distributor `Microsoft Corp.', version 6.1.7601
Configured using:
 `configure --prefix=/c/Devel/emacs/binary --enable-checking=yes,glyphs
 CFLAGS=-O0 -g3 LDFLAGS=-Lc:/Devel/emacs/lib
 CPPFLAGS=-Ic:/Devel/emacs/include'





reply via email to

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