comparison lisp/wid-edit.el @ 221:6c0ae1f9357f r20-4b9

Import from CVS: tag r20-4b9
author cvs
date Mon, 13 Aug 2007 10:10:02 +0200
parents 262b8bb4a523
children 0e522484dd2a
comparison
equal deleted inserted replaced
220:04f4bca7b601 221:6c0ae1f9357f
153 (princ object (current-buffer)) 153 (princ object (current-buffer))
154 (buffer-string))) 154 (buffer-string)))
155 155
156 (defun widget-prettyprint-to-string (object) 156 (defun widget-prettyprint-to-string (object)
157 ;; Like pp-to-string, but uses `cl-prettyprint' 157 ;; Like pp-to-string, but uses `cl-prettyprint'
158 ;; #### FIX ME!!!!
159 (with-current-buffer (get-buffer-create " *widget-tmp*") 158 (with-current-buffer (get-buffer-create " *widget-tmp*")
160 (erase-buffer) 159 (erase-buffer)
161 (cl-prettyprint object) 160 (cl-prettyprint object)
161 ;; `cl-prettyprint' always surrounds the text with newlines.
162 (when (eq (char-after (point-min)) ?\n)
163 (delete-region (point-min) (1+ (point-min))))
164 (when (eq (char-before (point-max)) ?\n)
165 (delete-region (1- (point-max)) (point-max)))
162 (buffer-string))) 166 (buffer-string)))
163 167
164 (defun widget-clear-undo () 168 (defun widget-clear-undo ()
165 "Clear all undo information." 169 "Clear all undo information."
166 (buffer-disable-undo) 170 (buffer-disable-undo)
3355 (defun widget-sexp-value-to-internal (widget value) 3359 (defun widget-sexp-value-to-internal (widget value)
3356 ;; Use cl-prettyprint for printer representation. 3360 ;; Use cl-prettyprint for printer representation.
3357 (let ((pp (if (symbolp value) 3361 (let ((pp (if (symbolp value)
3358 (prin1-to-string value) 3362 (prin1-to-string value)
3359 (widget-prettyprint-to-string value)))) 3363 (widget-prettyprint-to-string value))))
3360 (while (string-match "\n\\'" pp) 3364 (if (> (length pp) 40)
3361 (setq pp (substring pp 0 -1)))
3362 (if (and (> (length pp) 40)
3363 (not (string-match "\\`\n" pp)))
3364 (concat "\n" pp) 3365 (concat "\n" pp)
3365 pp))) 3366 pp)))
3366 3367
3367 (defun widget-sexp-validate (widget) 3368 (defun widget-sexp-validate (widget)
3368 ;; Valid if we can read the string and there is no junk left after it. 3369 ;; Valid if we can read the string and there is no junk left after it.