* pp-to-string, defun and "()"
@ 2007-11-04 9:22 yzhh
2007-11-04 10:03 ` Thien-Thi Nguyen
2007-11-04 10:40 ` Andreas Schwab
0 siblings, 2 replies; 3+ messages in thread
From: yzhh @ 2007-11-04 9:22 UTC (permalink / raw)
To: emacs-devel
The following code is intended for produce the string of a defun,
(pp-to-string
`(defun recorded-commands ()
"Commands recorded during the last 'recording commands' cycle."
(interactive)
,@(reclisp-post-process reclisp-recorded-commands)))
It produces
(defun recorded-commands nil "Commands recorded during the last 'recording
commands' cycle."
(interactive)
...
The "()" is translated to "nil" which does not look good, and the doc string
is put in the same line place. Any suggesting?
--
regards,
yzhh
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: pp-to-string, defun and "()"
2007-11-04 9:22 pp-to-string, defun and "()" yzhh
@ 2007-11-04 10:03 ` Thien-Thi Nguyen
2007-11-04 10:40 ` Andreas Schwab
1 sibling, 0 replies; 3+ messages in thread
From: Thien-Thi Nguyen @ 2007-11-04 10:03 UTC (permalink / raw)
To: yzhh; +Cc: emacs-devel
() yzhh <yezonghui@gmail.com>
() Sun, 04 Nov 2007 17:22:09 +0800
The "()" is translated to "nil" which does not look good, and
the doc string is put in the same line place. Any suggesting?
extend pp-buffer to special-case defun (and defun-like) forms.
see sketch below.
thi
___________________________________________________________
--- pp.el 3 Aug 2007 03:13:44 -0000 1.35
+++ pp.el 4 Nov 2007 10:03:34 -0000
@@ -86,6 +86,19 @@
(insert ?\n))
(t (goto-char (point-max)))))
(goto-char (point-min))
+ ;; Special-case (def... () "DOCSTRING").
+ (condition-case err-var
+ (when (looking-at "(def[^ ]+ [^\"]+\"")
+ (goto-char (1- (match-end 0)))
+ (insert "\n")
+ (forward-sexp 1)
+ (unless (eolp)
+ (insert "\n"))
+ (forward-sexp -2)
+ (when (looking-at "nil")
+ (replace-match "()")))
+ (error nil))
+ (goto-char (point-min))
(indent-sexp))
;;;###autoload
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: pp-to-string, defun and "()"
2007-11-04 9:22 pp-to-string, defun and "()" yzhh
2007-11-04 10:03 ` Thien-Thi Nguyen
@ 2007-11-04 10:40 ` Andreas Schwab
1 sibling, 0 replies; 3+ messages in thread
From: Andreas Schwab @ 2007-11-04 10:40 UTC (permalink / raw)
To: yzhh; +Cc: emacs-devel
yzhh <yezonghui@gmail.com> writes:
> The following code is intended for produce the string of a defun,
> (pp-to-string
> `(defun recorded-commands ()
> "Commands recorded during the last 'recording commands' cycle."
> (interactive)
> ,@(reclisp-post-process reclisp-recorded-commands)))
>
> It produces
> (defun recorded-commands nil "Commands recorded during the last 'recording
> commands' cycle."
> (interactive)
> ...
>
> The "()" is translated to "nil" which does not look good, and the doc string
> is put in the same line place. Any suggesting?
The pretty printer is very simple. It treats this list like every other
list and does not try to infer any meaning on it.
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-11-04 10:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-04 9:22 pp-to-string, defun and "()" yzhh
2007-11-04 10:03 ` Thien-Thi Nguyen
2007-11-04 10:40 ` Andreas Schwab
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).