comparison lisp/help.el @ 16557:4ff6a0f0f5c7

(describe-variable): Pretty-print the values. Put doc string first, if the value is long.
author Richard M. Stallman <rms@gnu.org>
date Sun, 10 Nov 1996 18:52:18 +0000
parents 0c61b1f40de2
children c19089a334b2
comparison
equal deleted inserted replaced
16556:3a1df67c6677 16557:4ff6a0f0f5c7
590 "Describe variable: ") 590 "Describe variable: ")
591 obarray 'boundp t)) 591 obarray 'boundp t))
592 (list (if (equal val "") 592 (list (if (equal val "")
593 v (intern val))))) 593 v (intern val)))))
594 (if (symbolp variable) 594 (if (symbolp variable)
595 (with-output-to-temp-buffer "*Help*" 595 (let (valvoid)
596 (prin1 variable) 596 (with-output-to-temp-buffer "*Help*"
597 (if (not (boundp variable)) 597 (prin1 variable)
598 (princ " is void") 598 (if (not (boundp variable))
599 (princ "'s value is ") 599 (progn
600 (prin1 (symbol-value variable))) 600 (princ " is void")
601 (terpri) 601 (terpri)
602 (if (local-variable-p variable) 602 (setq valvoid t))
603 (progn 603 (princ "'s value is ")
604 (princ (format "Local in buffer %s; " (buffer-name))) 604 (terpri)
605 (if (not (default-boundp variable)) 605 (pp (symbol-value variable))
606 (princ "globally void") 606 (terpri))
607 (princ "global value is ") 607 (if (local-variable-p variable)
608 (prin1 (default-value variable))) 608 (progn
609 (terpri))) 609 (princ (format "Local in buffer %s; " (buffer-name)))
610 (terpri) 610 (if (not (default-boundp variable))
611 (princ "Documentation:") 611 (princ "globally void")
612 (terpri) 612 (princ "global value is ")
613 (let ((doc (documentation-property variable 'variable-documentation))) 613 (terpri)
614 (princ (or doc "not documented as a variable."))) 614 (pp (default-value variable)))
615 (print-help-return-message) 615 (terpri)))
616 (save-excursion 616 (terpri)
617 (set-buffer standard-output) 617 (save-current-buffer
618 (help-mode) 618 (set-buffer standard-output)
619 ;; Return the text we displayed. 619 (if (> (count-lines (point-min) (point-max)) 10)
620 (buffer-string))) 620 (progn
621 (goto-char (point-min))
622 (if valvoid
623 (forward-line 1)
624 (forward-sexp 1)
625 (delete-region (point) (progn (end-of-line) (point)))
626 (insert "'s value is shown below.\n\n")
627 (save-excursion
628 (insert "\n\nValue:"))))))
629 (princ "Documentation:")
630 (terpri)
631 (let ((doc (documentation-property variable 'variable-documentation)))
632 (princ (or doc "not documented as a variable.")))
633 (print-help-return-message)
634 (save-excursion
635 (set-buffer standard-output)
636 (help-mode)
637 ;; Return the text we displayed.
638 (buffer-string))))
621 (message "You did not specify a variable"))) 639 (message "You did not specify a variable")))
622 640
623 (defun where-is (definition) 641 (defun where-is (definition)
624 "Print message listing key sequences that invoke specified command. 642 "Print message listing key sequences that invoke specified command.
625 Argument is a command definition, usually a symbol with a function definition." 643 Argument is a command definition, usually a symbol with a function definition."