emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

pretty-print sexps in Customize


From: Drew Adams
Subject: pretty-print sexps in Customize
Date: Sat, 8 Dec 2007 11:04:54 -0800

I don't have the time or knowledge to work on this, but if someone else
does, it could be useful: Use pretty-printing for an input-field sexp in
Customize.

For example, I see things like this, which is not very readable or conducive
to editing:

imenu-tree-window-function: Hide Value (lambda (trbuf buf)
(delete-other-windows) (let* ((w1 (selected-window)) (w2 (split-window w1
imenu-tree-window-width t))) (set-window-buffer w1 trbuf) (set-window-buffer
w2 buf) (other-window 1)))
   State: this option is unchanged from its standard setting.

It would be nice to (at least be able to) see this instead:

imenu-tree-window-function: Hide Value

(lambda (trbuf buf)
  (delete-other-windows)
  (let* ((w1 (selected-window))
         (w2 (split-window w1 imenu-tree-window-width t)))
    (set-window-buffer w1 trbuf)
    (set-window-buffer w2 buf)
    (other-window 1)))

   State: this option is unchanged from its standard setting.

This might mean a change to the widget code, not just to the customize code;
I don't know. Perhaps it would mean creating a new widget type, `pp-sexp',
which would be like `sexp' but pretty-printed? Or perhaps type `sexp' should
always be pretty-printed? Perhaps we would need a new widget :format spec,
like %v, but which pretty-prints?

Another possibility would be to let users themselves use `C-M-q' to
pretty-print a Lisp sexp field. We could perhaps provide other Emacs-Lisp
mode features (e.g. TAB indenting, highlight matching parens) as well within
a sexp editable field - it's much easier to edit Lisp when you have such
tools available.

Yes, you can always copy the value to *scratch* or some Emacs-Lisp buffer
and edit it there, then copy it back. But it would be better if you could
just edit it locally, or at least see it pretty-printed. There's not much
sense in showing a complex Lisp sexp without pretty-printing it.

Another possibility would be to show a link instead of the sexp, when the
sexp is more than, say, 30 chars long. When you followed the link, you would
access the sexp for editing in an Emacs-Lisp buffer. Some key sequence (e.g.
`C-c') in that buffer would copy the edited sexp back to the Customize
field. This might be the easiest approach - use a pop-up editing buffer when
the sexp is non-trivial.

Better: instead of adding a link, just let the `Show Value' button pop up
the Emacs-Lisp buffer for editing.

I don't know widgets, so I'm not sure what's really practicable in terms of
widget UI or what would be needed in terms of implementation, but I think
pretty-printing, at least, would improve Customize interaction considerably
for Lisp sexp fields.

Anyone have any ideas along these lines? Anyone want to work on it?







reply via email to

[Prev in Thread] Current Thread [Next in Thread]