unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#14754: 24.3.50; `C-h v' needs to fill wide `pp' lines (493 chars wide?!)
@ 2013-06-30  7:10 Drew Adams
  2013-07-01 17:07 ` Drew Adams
  2014-02-08  6:38 ` Lars Ingebrigtsen
  0 siblings, 2 replies; 5+ messages in thread
From: Drew Adams @ 2013-06-30  7:10 UTC (permalink / raw)
  To: 14754

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'





^ permalink raw reply	[flat|nested] 5+ messages in thread
* bug#14754: 24.3.50; `C-h v' needs to fill wide `pp' lines (493 chars wide?!)
@ 2022-06-09 16:36 Drew Adams
  0 siblings, 0 replies; 5+ messages in thread
From: Drew Adams @ 2022-06-09 16:36 UTC (permalink / raw)
  To: 'Drew Adams', Lars Ingebrigtsen; +Cc: 14754@debbugs.gnu.org

[-- Attachment #1: Type: text/plain, Size: 964 bytes --]

This was closed as fixed in 29.1.  I don't have
that release, so I can't check this.

I hope this problem is fixed.  I was wrong about
the solution being to just fill.  That would be
catastrophic for some variable values, such as
for `directory-listing-before-filename-regexp',
where SPC chars are significant etc.  (For that
var the result of filling ended up, in effect,
replacing the SPC before the + at the end of the
regexp with just a newline.)

Some enhancement of pretty-printing, to control
(or at least to try to control) the width is
needed.  Maybe that's what's been implemented as
part of the fix.  If so, great.

The problem, in general, is this:

* We need to be able to print (e.g. pretty-print)
  any Lisp value.

* Buffer `*Help*' should not have lines longer
  than what the style convention calls for.

Trying to finesse those two different rules is
the difficulty.  If you've come up with a good
solution, bravo.


[-- Attachment #2: winmail.dat --]
[-- Type: application/ms-tnef, Size: 14413 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-06-09 16:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-30  7:10 bug#14754: 24.3.50; `C-h v' needs to fill wide `pp' lines (493 chars wide?!) Drew Adams
2013-07-01 17:07 ` Drew Adams
2014-02-08  6:38 ` Lars Ingebrigtsen
2014-02-10  3:56   ` Drew Adams
  -- strict thread matches above, loose matches on Subject: below --
2022-06-09 16:36 Drew Adams

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).