unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* `unreadablep'
@ 2021-12-15  7:49 Lars Ingebrigtsen
  2021-12-15  8:19 ` `unreadablep' Po Lu
                   ` (5 more replies)
  0 siblings, 6 replies; 37+ messages in thread
From: Lars Ingebrigtsen @ 2021-12-15  7:49 UTC (permalink / raw)
  To: emacs-devel

Do we have any primitive that can be used to check whether an object is
printable or not?  Code like this (from savehist.el) makes me believe
"not":

		;; Print elements of VALUE one by one, carefully.
		(dolist (elt value)
		  (let ((start (point)))
		    (insert " ")
		    ;; Try to print and then to read an element.
		    (condition-case nil
			(progn
			  (prin1 elt (current-buffer))
			  (save-excursion
			    (goto-char start)
			    (read (current-buffer))))
		      (error
		       ;; If writing or reading gave an error, comment it out.
		       (goto-char start)
		       (insert "\n")
		       (while (not (eobp))
			 (insert ";;; ")
			 (forward-line 1))
		       (insert "\n")))
		    (goto-char (point-max))))

It would be nice to have such a function (i.e., that says whether it can
be read back after printing it).  The problem is, of course, complex
structures that require recursing (and then checking for loops), etc, so
you basically have to implement it the way printing is done if you want
it to be fast, I think?

Does anybody have any thoughts on this issue?

I wonder whether this could be efficiently implemented by, say, having
some kind of special value for PRINTCHARFUN for prin1, but I haven't
looked at the code yet.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




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

end of thread, other threads:[~2021-12-17  7:19 UTC | newest]

Thread overview: 37+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-12-15  7:49 `unreadablep' Lars Ingebrigtsen
2021-12-15  8:19 ` `unreadablep' Po Lu
2021-12-15  8:35   ` `unreadablep' Lars Ingebrigtsen
2021-12-15  9:42     ` `unreadablep' Po Lu
2021-12-15 11:16       ` `unreadablep' Lars Ingebrigtsen
2021-12-15 11:25         ` `unreadablep' Po Lu
2021-12-15 12:19           ` `unreadablep' Lars Ingebrigtsen
2021-12-15 12:22             ` `unreadablep' Po Lu
2021-12-15 12:35               ` `unreadablep' Lars Ingebrigtsen
2021-12-15 12:42                 ` `unreadablep' Po Lu
2021-12-15 12:44                   ` `unreadablep' Lars Ingebrigtsen
2021-12-15 12:46                     ` `unreadablep' Po Lu
2021-12-15 12:51                       ` `unreadablep' Po Lu
2021-12-15 12:58                       ` `unreadablep' Lars Ingebrigtsen
2021-12-15 12:36               ` `unreadablep' Ihor Radchenko
2021-12-15 12:37                 ` `unreadablep' Po Lu
2021-12-15 17:00     ` [External] : `unreadablep' Drew Adams
2021-12-15  8:35 ` `unreadablep' Ihor Radchenko
2021-12-15  9:51   ` `unreadablep' Po Lu
2021-12-15 10:20     ` `unreadablep' Ihor Radchenko
2021-12-15 10:21       ` `unreadablep' Ihor Radchenko
2021-12-15 10:21       ` `unreadablep' Po Lu
2021-12-15 10:36         ` `unreadablep' Ihor Radchenko
2021-12-15 10:44           ` `unreadablep' Po Lu
2021-12-15 11:12             ` `unreadablep' Ihor Radchenko
2021-12-15 11:16               ` `unreadablep' Po Lu
2021-12-15 11:39                 ` `unreadablep' Ihor Radchenko
2021-12-15 14:12 ` `unreadablep' Stefan Monnier
2021-12-16  5:48   ` `unreadablep' Lars Ingebrigtsen
2021-12-16  8:03     ` `unreadablep' Eli Zaretskii
2021-12-17  7:18       ` `unreadablep' Lars Ingebrigtsen
2021-12-16 15:35     ` `unreadablep' Qiantan Hong
2021-12-17  7:19       ` `unreadablep' Lars Ingebrigtsen
2021-12-15 15:32 ` `unreadablep' Steingold
2021-12-15 16:04   ` `unreadablep' Qiantan Hong
2021-12-15 16:09 ` `unreadablep' Steingold
2021-12-15 20:21 ` `unreadablep' Philipp Stephani

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).