Simplify Lisp -> Texinfo printing

* dev/examples-to-info.el (dash--print-lisp-as-texi): Use
print-escape-control-characters instead of emulating it.
* dash.texi: Regenerate.
master
Basil L. Contovounesios 5 years ago
parent 56db327365
commit 9727f7c38c
No known key found for this signature in database
GPG Key ID: 205AB54A5D5D8CFF
  1. 2
      dash.texi
  2. 27
      dev/examples-to-info.el

@ -4345,7 +4345,7 @@ See @var{srfi-26} for detailed description.
@end group @end group
@group @group
(-map (-cut <> 1 2 3) '(list vector string)) (-map (-cut <> 1 2 3) '(list vector string))
@result{} '((1 2 3) [1 2 3] "\^A\^B\^C") @result{} '((1 2 3) [1 2 3] "\1\2\3")
@end group @end group
@end example @end example
@end defmac @end defmac

@ -30,25 +30,16 @@
(defun dash--print-lisp-as-texi (obj) (defun dash--print-lisp-as-texi (obj)
"Print Lisp OBJ suitably for Texinfo." "Print Lisp OBJ suitably for Texinfo."
(save-excursion (let ((print-quoted t)) (prin1 obj))) (let ((print-quoted t)
(while (re-search-forward (rx (| (group "\\?") (print-escape-control-characters t))
(group (in "{}")) (save-excursion (prin1 obj)))
(group ?\' symbol-start "nil" symbol-end) (while (re-search-forward (rx (| (group ?\' symbol-start "nil" symbol-end)
(not (in ?\n print)))) (group "\\?") (in "{}")))
nil 'move) nil 'move)
(cond ((match-beginning 1) (replace-match (cond ((match-beginning 1) "'()") ; 'nil -> '().
;; Unescape `-any\?' -> `-any?'. ((match-beginning 2) "?") ; `-any\?' -> `-any?'.
(delete-region (- (point) 2) (1- (point)))) ("@\\&")) ; { -> @{.
((match-beginning 2) t)))
;; Escape braces with @.
(backward-char)
(insert ?@)
(forward-char))
;; Don't let '() be printed as 'nil.
((match-beginning 3) (replace-match "'()" t t))
;; Translate unprintable characters such as ?\^A.
((let ((desc (text-char-description (preceding-char))))
(replace-match (concat "\\" desc) t t))))))
(defun example-to-string (example) (defun example-to-string (example)
(pcase-let* ((`(,actual ,err ,expected) example) (pcase-let* ((`(,actual ,err ,expected) example)

Loading…
Cancel
Save