all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#6017: 23.1.96; savehist-printable for hash tables
@ 2010-04-23 17:49 Drew Adams
  2010-04-23 18:15 ` Stefan Monnier
  0 siblings, 1 reply; 4+ messages in thread
From: Drew Adams @ 2010-04-23 17:49 UTC (permalink / raw)
  To: 6017

IIUC, starting with Emacs 23.2, we can prin1 and read hash tables. If
that's correct, then `savehist-printable' could presumably be updated to
add this sexp to the cond: (hash-table-p value). IOW:
 
(defun savehist-printable (value)
  "Return non-nil if VALUE is printable."
  (cond
   ((stringp value))
   ((numberp value))
   ((symbolp value))
   ((hash-table-p value))
   (t
    (with-temp-buffer
      (condition-case nil
   (let ((print-readably t) (print-level nil))
   (prin1 value (current-buffer))
   (read (point-min-marker))
   t)
 (error nil))))))

In GNU Emacs 23.1.96.1 (i386-mingw-nt5.1.2600)
 of 2010-04-20 on G41R2F1
Windowing system distributor `Microsoft Corp.', version 5.1.2600
configured using `configure --with-gcc (3.4) --no-opt --cflags -Ic:/xpm/include'
 








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

* bug#6017: 23.1.96; savehist-printable for hash tables
  2010-04-23 17:49 bug#6017: 23.1.96; savehist-printable for hash tables Drew Adams
@ 2010-04-23 18:15 ` Stefan Monnier
  2010-04-23 18:34   ` Drew Adams
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Monnier @ 2010-04-23 18:15 UTC (permalink / raw)
  To: Drew Adams; +Cc: 6017

> IIUC, starting with Emacs 23.2, we can prin1 and read hash tables. If
> that's correct, then `savehist-printable' could presumably be updated to
> add this sexp to the cond: (hash-table-p value). IOW:
 
> (defun savehist-printable (value)
>   "Return non-nil if VALUE is printable."
>   (cond
>    ((stringp value))
>    ((numberp value))
>    ((symbolp value))
>    ((hash-table-p value))
>    (t
>     (with-temp-buffer
>       (condition-case nil
>    (let ((print-readably t) (print-level nil))
>    (prin1 value (current-buffer))
>    (read (point-min-marker))
>    t)
>  (error nil))))))

That won't check whether the contents of the has-table are
themsevles printable.


        Stefan







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

* bug#6017: 23.1.96; savehist-printable for hash tables
  2010-04-23 18:15 ` Stefan Monnier
@ 2010-04-23 18:34   ` Drew Adams
  2010-04-25 18:30     ` Chong Yidong
  0 siblings, 1 reply; 4+ messages in thread
From: Drew Adams @ 2010-04-23 18:34 UTC (permalink / raw)
  To: 'Stefan Monnier'; +Cc: 6017

> That won't check whether the contents of the has-table are
> themsevles printable.

Good point. I don't know how the support for printing & reading hash tables
works. If it just ensures that the top level is readable (the hash table
itself), then yes, there is no guarantee that its content is really readable.

Is this feature of hash-table print+read support specified anywhere, so we know
what the support really is? If not, could you please document it? 

It sounds like it is similar to printing a list - no guarantees about
readability of list members etc. If so, we should at least say that somewhere.







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

* bug#6017: 23.1.96; savehist-printable for hash tables
  2010-04-23 18:34   ` Drew Adams
@ 2010-04-25 18:30     ` Chong Yidong
  0 siblings, 0 replies; 4+ messages in thread
From: Chong Yidong @ 2010-04-25 18:30 UTC (permalink / raw)
  To: Drew Adams; +Cc: 6017-done, 'Stefan Monnier'

"Drew Adams" <drew.adams@oracle.com> writes:

> Is this feature of hash-table print+read support specified anywhere,
> so we know what the support really is? If not, could you please
> document it?

See `Creating Hash Tables' in the Lisp manual.







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

end of thread, other threads:[~2010-04-25 18:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-23 17:49 bug#6017: 23.1.96; savehist-printable for hash tables Drew Adams
2010-04-23 18:15 ` Stefan Monnier
2010-04-23 18:34   ` Drew Adams
2010-04-25 18:30     ` Chong Yidong

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.