Function: ps-line-lengths-internal
ps-line-lengths-internal is a byte-compiled function defined in
ps-print.el.gz.
Signature
(ps-line-lengths-internal)
Documentation
Display the correspondence between a line length and a font size.
Done using the current ps-print setup.
Try: pr -t file | awk '{printf "%3d %s
", length($0), $0}' | sort -r | head
Source Code
;; Defined in /usr/src/emacs/lisp/ps-print.el.gz
(defun ps-line-lengths-internal ()
"Display the correspondence between a line length and a font size.
Done using the current ps-print setup.
Try: pr -t file | awk \\='{printf \"%3d %s\n\", length($0), $0}\\=' | sort -r | head"
(let* ((ps-font-size-internal
(or ps-font-size-internal
(ps-get-font-size 'ps-font-size)))
(ps-header-font-size-internal
(or ps-header-font-size-internal
(ps-get-font-size 'ps-header-font-size)))
(ps-footer-font-size-internal
(or ps-footer-font-size-internal
(ps-get-font-size 'ps-footer-font-size)))
(ps-header-title-font-size-internal
(or ps-header-title-font-size-internal
(ps-get-font-size 'ps-header-title-font-size)))
(buf (get-buffer-create "*Line-lengths*"))
(ifs ps-font-size-internal) ; initial font size
(print-width (progn (ps-get-page-dimensions)
ps-print-width))
(icw (ps-avg-char-width 'ps-font-for-text)) ; initial character width
(ps-setup (ps-setup)) ; setup for the current buffer
(fs-min 5) ; minimum font size
cw-min ; minimum character width
nb-cpl-max ; maximum nb of characters per line
(fs-max 14) ; maximum font size
cw-max ; maximum character width
nb-cpl-min ; minimum nb of characters per line
fs ; current font size
cw ; current character width
nb-cpl ; current nb of characters per line
)
(setq cw-min (/ (* icw fs-min) ifs)
nb-cpl-max (floor (/ print-width cw-min))
cw-max (/ (* icw fs-max) ifs)
nb-cpl-min (floor (/ print-width cw-max))
nb-cpl nb-cpl-min)
(set-buffer buf)
(goto-char (point-max))
(or (bobp) (insert "\n" (make-string 75 ?\;) "\n"))
(insert ps-setup
"\nnb char per line / font size\n")
(while (<= nb-cpl nb-cpl-max)
(setq cw (/ print-width (float nb-cpl))
fs (/ (* ifs cw) icw))
(insert (format "%16d %s\n" nb-cpl fs))
(setq nb-cpl (1+ nb-cpl)))
(insert "\n")
(display-buffer buf 'not-this-window)))