justify-kp
justify-kp copied to clipboard
Filling fails on empty tokens when used on empty lines
Debugger entered--Lisp error: (args-out-of-range "" 0)
elt("" 0)
(memq (elt token 0) pj--whitespace-class)
(let* ((len (length token)) (--dash-source-3-- (-split-at len line-data)) (cur (car-safe (prog1 --dash-source-3-- (setq --dash-source-3-- (cdr --dash-source-3--))))) (rest (car --dash-source-3--)) (widths (mapcar (function (lambda (it) (plist-get it :width))) cur)) (is-whitespace (memq (elt token 0) pj--whitespace-class)) (width (if is-whitespace (car widths) (-sum widths))) (shrink (if is-whitespace (ceiling (* width pj-shrink-ratio)) 0)) (stretch (if is-whitespace (ceiling (* width pj-stretch-ratio)) 0))) (prog1 (list :type (cond (is-whitespace (quote white)) ((memq (elt token 0) pj--splitpoint-class) (quote split)) (t (quote box))) :value token :index (prog1 index (setq index (1+ index))) :width width :total-width (setq total-width (+ total-width width)) :shrink shrink :total-shrink (setq total-shrink (+ total-shrink shrink)) :stretch stretch :total-stretch (setq total-stretch (+ total-stretch stretch)) :widths widths) (setq line-data rest)))
(lambda (token) (let* ((len (length token)) (--dash-source-3-- (-split-at len line-data)) (cur (car-safe (prog1 --dash-source-3-- (setq --dash-source-3-- (cdr --dash-source-3--))))) (rest (car --dash-source-3--)) (widths (mapcar (function (lambda (it) (plist-get it :width))) cur)) (is-whitespace (memq (elt token 0) pj--whitespace-class)) (width (if is-whitespace (car widths) (-sum widths))) (shrink (if is-whitespace (ceiling (* width pj-shrink-ratio)) 0)) (stretch (if is-whitespace (ceiling (* width pj-stretch-ratio)) 0))) (prog1 (list :type (cond (is-whitespace (quote white)) ((memq (elt token 0) pj--splitpoint-class) (quote split)) (t (quote box))) :value token :index (prog1 index (setq index (1+ index))) :width width :total-width (setq total-width (+ total-width width)) :shrink shrink :total-shrink (setq total-shrink (+ total-shrink shrink)) :stretch stretch :total-stretch (setq total-stretch (+ total-stretch stretch)) :widths widths) (setq line-data rest))))("")
mapcar((lambda (token) (let* ((len (length token)) (--dash-source-3-- (-split-at len line-data)) (cur (car-safe (prog1 --dash-source-3-- (setq --dash-source-3-- (cdr --dash-source-3--))))) (rest (car --dash-source-3--)) (widths (mapcar (function (lambda (it) (plist-get it :width))) cur)) (is-whitespace (memq (elt token 0) pj--whitespace-class)) (width (if is-whitespace (car widths) (-sum widths))) (shrink (if is-whitespace (ceiling (* width pj-shrink-ratio)) 0)) (stretch (if is-whitespace (ceiling (* width pj-stretch-ratio)) 0))) (prog1 (list :type (cond (is-whitespace (quote white)) ((memq (elt token 0) pj--splitpoint-class) (quote split)) (t (quote box))) :value token :index (prog1 index (setq index (1+ index))) :width width :total-width (setq total-width (+ total-width width)) :shrink shrink :total-shrink (setq total-shrink (+ total-shrink shrink)) :stretch stretch :total-stretch (setq total-stretch (+ total-stretch stretch)) :widths widths) (setq line-data rest)))) ("" "-" "UUU:**" "-" "-" "F3" " " "*scratch*" " " "All" " " "L4" " " "(Lisp" " " "Interaction)" " " "-" "-"))
-map((lambda (token) (let* ((len (length token)) (--dash-source-3-- (-split-at len line-data)) (cur (car-safe (prog1 --dash-source-3-- (setq --dash-source-3-- (cdr --dash-source-3--))))) (rest (car --dash-source-3--)) (widths (mapcar (function (lambda (it) (plist-get it :width))) cur)) (is-whitespace (memq (elt token 0) pj--whitespace-class)) (width (if is-whitespace (car widths) (-sum widths))) (shrink (if is-whitespace (ceiling (* width pj-shrink-ratio)) 0)) (stretch (if is-whitespace (ceiling (* width pj-stretch-ratio)) 0))) (prog1 (list :type (cond (is-whitespace (quote white)) ((memq (elt token 0) pj--splitpoint-class) (quote split)) (t (quote box))) :value token :index (prog1 index (setq index (1+ index))) :width width :total-width (setq total-width (+ total-width width)) :shrink shrink :total-shrink (setq total-shrink (+ total-shrink shrink)) :stretch stretch :total-stretch (setq total-stretch (+ total-stretch stretch)) :widths widths) (setq line-data rest)))) ("" "-" "UUU:**" "-" "-" "F3" " " "*scratch*" " " "All" " " "L4" " " "(Lisp" " " "Interaction)" " " "-" "-"))
(list :length length :tokens (-map (function (lambda (token) (let* ((len (length token)) (--dash-source-3-- (-split-at len line-data)) (cur (car-safe ...)) (rest (car --dash-source-3--)) (widths (mapcar ... cur)) (is-whitespace (memq ... pj--whitespace-class)) (width (if is-whitespace ... ...)) (shrink (if is-whitespace ... 0)) (stretch (if is-whitespace ... 0))) (prog1 (list :type (cond ... ... ...) :value token :index (prog1 index ...) :width width :total-width (setq total-width ...) :shrink shrink :total-shrink (setq total-shrink ...) :stretch stretch :total-stretch (setq total-stretch ...) :widths widths) (setq line-data rest))))) tokens))
(let* ((--dash-source-2-- (pj--get-string-tokens)) (length (plist-get --dash-source-2-- :length)) (tokens (plist-get --dash-source-2-- :tokens)) (line-data (save-excursion (pj--get-line-data))) (total-width 0) (total-shrink 0) (total-stretch 0) (index 0)) (list :length length :tokens (-map (function (lambda (token) (let* ((len ...) (--dash-source-3-- ...) (cur ...) (rest ...) (widths ...) (is-whitespace ...) (width ...) (shrink ...) (stretch ...)) (prog1 (list :type ... :value token :index ... :width width :total-width ... :shrink shrink :total-shrink ... :stretch stretch :total-stretch ... :widths widths) (setq line-data rest))))) tokens)))
pj--get-tokens()
(let* ((line (pj--get-tokens)) (active-nodes (pj--justify line)) (line (plist-get line :tokens)) (raw-break-points (pj--get-best-active-node active-nodes)) (break-points (let ((re (list raw-break-points))) (while (setq raw-break-points (plist-get raw-break-points :parent)) (setq re (cons raw-break-points re))) (cdr re))) (lbp (plist-get (car break-points) :parent))) (-each break-points (function (lambda (bp) (let* ((--dash-source-10-- (let ... ... ...)) (cur-line (car-safe ...)) (rest (car --dash-source-10--)) (last-token (if ... bp ...)) (lt-value (plist-get last-token :value)) (lt-widths (plist-get last-token :widths)) (last-char (-last-item ...)) (last-char-width (-last-item lt-widths)) (last-token (let ... ...)) (width (pj--get-token-diff-width lbp last-token)) (stretch (pj--get-token-diff-stretch lbp last-token)) (shrink (pj--get-token-diff-shrink lbp last-token)) (adjustment (- ... width)) (adj-ratio (cond ... ...)) (overflow 0.0)) (-each cur-line (function (lambda ... ...))) (setq lbp (car rest)) (let ((type ...) (len ...)) (forward-char len) (cond (... ...) (... ...))) (setq rest (cdr rest)) (setq line rest))))))
(save-excursion (let* ((line (pj--get-tokens)) (active-nodes (pj--justify line)) (line (plist-get line :tokens)) (raw-break-points (pj--get-best-active-node active-nodes)) (break-points (let ((re (list raw-break-points))) (while (setq raw-break-points (plist-get raw-break-points :parent)) (setq re (cons raw-break-points re))) (cdr re))) (lbp (plist-get (car break-points) :parent))) (-each break-points (function (lambda (bp) (let* ((--dash-source-10-- ...) (cur-line ...) (rest ...) (last-token ...) (lt-value ...) (lt-widths ...) (last-char ...) (last-char-width ...) (last-token ...) (width ...) (stretch ...) (shrink ...) (adjustment ...) (adj-ratio ...) (overflow 0.0)) (-each cur-line (function ...)) (setq lbp (car rest)) (let (... ...) (forward-char len) (cond ... ...)) (setq rest (cdr rest)) (setq line rest)))))))
pj-justify()
(progn (goto-char (line-beginning-position)) (pj-justify))
(if (> (shr-pixel-column) max-width) (progn (goto-char (line-beginning-position)) (pj-justify)))
(progn (goto-char (line-end-position)) (if (> (shr-pixel-column) max-width) (progn (goto-char (line-beginning-position)) (pj-justify))))
(if (not (looking-at "^[[:space:]]*$")) (progn (goto-char (line-end-position)) (if (> (shr-pixel-column) max-width) (progn (goto-char (line-beginning-position)) (pj-justify)))))
(while (not (eobp)) (if (not (looking-at "^[[:space:]]*$")) (progn (goto-char (line-end-position)) (if (> (shr-pixel-column) max-width) (progn (goto-char (line-beginning-position)) (pj-justify))))) (forward-line 1))
(save-excursion (goto-char (point-min)) (while (not (eobp)) (if (not (looking-at "^[[:space:]]*$")) (progn (goto-char (line-end-position)) (if (> (shr-pixel-column) max-width) (progn (goto-char (line-beginning-position)) (pj-justify))))) (forward-line 1)))
(let ((max-width (pj-line-width)) buffer-read-only) (save-excursion (goto-char (point-min)) (while (not (eobp)) (if (not (looking-at "^[[:space:]]*$")) (progn (goto-char (line-end-position)) (if (> (shr-pixel-column) max-width) (progn (goto-char ...) (pj-justify))))) (forward-line 1))))
(if (get-buffer-window) (let ((max-width (pj-line-width)) buffer-read-only) (save-excursion (goto-char (point-min)) (while (not (eobp)) (if (not (looking-at "^[[:space:]]*$")) (progn (goto-char (line-end-position)) (if (> ... max-width) (progn ... ...)))) (forward-line 1)))) (add-hook (quote window-configuration-change-hook) (quote my-nov-window-configuration-change-hook) nil t))
my-nov-post-html-render-hook()
run-hooks(nov-post-html-render-hook)
nov-render-html()
funcall(nov-render-html)
(progn (funcall nov-render-html-function))
(if (not imagep) (progn (funcall nov-render-html-function)))
(let* ((document (aref nov-documents nov-documents-index)) (id (car document)) (path (cdr document)) (imagep (let (needle) (let ((list image-type-file-name-regexps) (continue t) (it-index 0)) (while (and list continue) (let (...) (if ... ... ...)) (setq it-index (1+ it-index)) (setq list (cdr list)))) needle)) (default-directory (file-name-directory path)) buffer-read-only) (erase-buffer) (cond (imagep (nov-insert-image path)) ((and (version< nov-epub-version "3.0") (eq id nov-toc-id)) (insert (nov-ncx-to-html path))) (t (insert (nov-slurp path)))) (if (not imagep) (progn (funcall nov-render-html-function))) (goto-char (point-min)))
nov-render-document()
funcall-interactively(nov-render-document)
call-interactively(nov-render-document nil nil)
command-execute(nov-render-document)