aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1996-10-13 13:59:51 +0000
committerRichard M. Stallman1996-10-13 13:59:51 +0000
commit00d3de8eaeb0b6cad96f56bd8f1a460fa21f2b4b (patch)
treea2d90b5bf1386d990919a1b0de750341f418b632
parent6fbe22d8650655d3c758b26c77d449345726d5b6 (diff)
downloademacs-00d3de8eaeb0b6cad96f56bd8f1a460fa21f2b4b.tar.gz
emacs-00d3de8eaeb0b6cad96f56bd8f1a460fa21f2b4b.zip
(describe-function): If no fn specified, say so.
(variable-at-point): Return 0 if no variable there. (describe-variable): If no variable specified, say so. Don't use nil as the variable.
-rw-r--r--lisp/help.el194
1 files changed, 100 insertions, 94 deletions
diff --git a/lisp/help.el b/lisp/help.el
index ba8664fc14b..e775139ddb8 100644
--- a/lisp/help.el
+++ b/lisp/help.el
@@ -493,71 +493,74 @@ C-w print information on absence of warranty for GNU Emacs."
493 obarray 'fboundp t)) 493 obarray 'fboundp t))
494 (list (if (equal val "") 494 (list (if (equal val "")
495 fn (intern val))))) 495 fn (intern val)))))
496 (with-output-to-temp-buffer "*Help*" 496 (if function
497 (prin1 function) 497 (with-output-to-temp-buffer "*Help*"
498 (princ ": ") 498 (prin1 function)
499 (let* ((def (symbol-function function)) 499 (princ ": ")
500 file-name 500 (let* ((def (symbol-function function))
501 (beg (if (commandp def) "an interactive " "a "))) 501 file-name
502 (princ (cond ((or (stringp def) 502 (beg (if (commandp def) "an interactive " "a ")))
503 (vectorp def)) 503 (princ (cond ((or (stringp def)
504 "a keyboard macro") 504 (vectorp def))
505 ((subrp def) 505 "a keyboard macro")
506 (concat beg "built-in function")) 506 ((subrp def)
507 ((byte-code-function-p def) 507 (concat beg "built-in function"))
508 (concat beg "compiled Lisp function")) 508 ((byte-code-function-p def)
509 ((symbolp def) 509 (concat beg "compiled Lisp function"))
510 (format "alias for `%s'" def)) 510 ((symbolp def)
511 ((eq (car-safe def) 'lambda) 511 (format "alias for `%s'" def))
512 (concat beg "Lisp function")) 512 ((eq (car-safe def) 'lambda)
513 ((eq (car-safe def) 'macro) 513 (concat beg "Lisp function"))
514 "a Lisp macro") 514 ((eq (car-safe def) 'macro)
515 ((eq (car-safe def) 'mocklisp) 515 "a Lisp macro")
516 "a mocklisp function") 516 ((eq (car-safe def) 'mocklisp)
517 ((eq (car-safe def) 'autoload) 517 "a mocklisp function")
518 (setq file-name (nth 1 def)) 518 ((eq (car-safe def) 'autoload)
519 (format "%s autoloaded Lisp %s" 519 (setq file-name (nth 1 def))
520 (if (commandp def) "an interactive" "an") 520 (format "%s autoloaded Lisp %s"
521 (if (nth 4 def) "macro" "function") 521 (if (commandp def) "an interactive" "an")
522 )) 522 (if (nth 4 def) "macro" "function")
523 (t ""))) 523 ))
524 (or file-name 524 (t "")))
525 (setq file-name (describe-function-find-file function))) 525 (or file-name
526 (if file-name 526 (setq file-name (describe-function-find-file function)))
527 (progn 527 (if file-name
528 (princ " in `") 528 (progn
529 ;; We used to add .el to the file name, 529 (princ " in `")
530 ;; but that's completely wrong when the user used load-file. 530 ;; We used to add .el to the file name,
531 (princ file-name) 531 ;; but that's completely wrong when the user used load-file.
532 (princ "'"))) 532 (princ file-name)
533 (princ ".") 533 (princ "'")))
534 (terpri) 534 (princ ".")
535 (let ((arglist (cond ((byte-code-function-p def) 535 (terpri)
536 (car (append def nil))) 536 (let ((arglist (cond ((byte-code-function-p def)
537 ((eq (car-safe def) 'lambda) 537 (car (append def nil)))
538 (nth 1 def)) 538 ((eq (car-safe def) 'lambda)
539 (t t)))) 539 (nth 1 def))
540 (if (listp arglist) 540 (t t))))
541 (progn 541 (if (listp arglist)
542 (princ (cons function 542 (progn
543 (mapcar (lambda (arg) 543 (princ (cons function
544 (if (memq arg '(&optional &rest)) 544 (mapcar (lambda (arg)
545 arg 545 (if (memq arg '(&optional &rest))
546 (intern (upcase (symbol-name arg))))) 546 arg
547 arglist))) 547 (intern (upcase (symbol-name arg)))))
548 (terpri)))) 548 arglist)))
549 (let ((doc (documentation function))) 549 (terpri))))
550 (if doc 550 (let ((doc (documentation function)))
551 (progn (terpri) 551 (if doc
552 (princ doc)) 552 (progn (terpri)
553 (princ "not documented")))) 553 (princ doc))
554 (print-help-return-message) 554 (princ "not documented"))))
555 (save-excursion 555 (print-help-return-message)
556 (set-buffer standard-output) 556 (save-excursion
557 (help-mode) 557 (set-buffer standard-output)
558 ;; Return the text we displayed. 558 (help-mode)
559 (buffer-string)))) 559 ;; Return the text we displayed.
560 560 (buffer-string)))
561 (message "You didn't specify a function")))
562
563;; We return 0 if we can't find a variable to return.
561(defun variable-at-point () 564(defun variable-at-point ()
562 (condition-case () 565 (condition-case ()
563 (let ((stab (syntax-table))) 566 (let ((stab (syntax-table)))
@@ -570,9 +573,10 @@ C-w print information on absence of warranty for GNU Emacs."
570 (forward-sexp -1)) 573 (forward-sexp -1))
571 (skip-chars-forward "'") 574 (skip-chars-forward "'")
572 (let ((obj (read (current-buffer)))) 575 (let ((obj (read (current-buffer))))
573 (and (symbolp obj) (boundp obj) obj))) 576 (or (and (symbolp obj) (boundp obj) obj)
577 0)))
574 (set-syntax-table stab))) 578 (set-syntax-table stab)))
575 (error nil))) 579 (error 0)))
576 580
577(defun describe-variable (variable) 581(defun describe-variable (variable)
578 "Display the full documentation of VARIABLE (a symbol). 582 "Display the full documentation of VARIABLE (a symbol).
@@ -581,38 +585,40 @@ Returns the documentation as a string, also."
581 (let ((v (variable-at-point)) 585 (let ((v (variable-at-point))
582 (enable-recursive-minibuffers t) 586 (enable-recursive-minibuffers t)
583 val) 587 val)
584 (setq val (completing-read (if v 588 (setq val (completing-read (if (symbolp v)
585 (format "Describe variable (default %s): " v) 589 (format "Describe variable (default %s): " v)
586 "Describe variable: ") 590 "Describe variable: ")
587 obarray 'boundp t)) 591 obarray 'boundp t))
588 (list (if (equal val "") 592 (list (if (equal val "")
589 v (intern val))))) 593 v (intern val)))))
590 (with-output-to-temp-buffer "*Help*" 594 (if (symbolp variable)
591 (prin1 variable) 595 (with-output-to-temp-buffer "*Help*"
592 (if (not (boundp variable)) 596 (prin1 variable)
593 (princ " is void") 597 (if (not (boundp variable))
594 (princ "'s value is ") 598 (princ " is void")
595 (prin1 (symbol-value variable))) 599 (princ "'s value is ")
596 (terpri) 600 (prin1 (symbol-value variable)))
597 (if (local-variable-p variable) 601 (terpri)
598 (progn 602 (if (local-variable-p variable)
599 (princ (format "Local in buffer %s; " (buffer-name))) 603 (progn
600 (if (not (default-boundp variable)) 604 (princ (format "Local in buffer %s; " (buffer-name)))
601 (princ "globally void") 605 (if (not (default-boundp variable))
602 (princ "global value is ") 606 (princ "globally void")
603 (prin1 (default-value variable))) 607 (princ "global value is ")
604 (terpri))) 608 (prin1 (default-value variable)))
605 (terpri) 609 (terpri)))
606 (princ "Documentation:") 610 (terpri)
607 (terpri) 611 (princ "Documentation:")
608 (let ((doc (documentation-property variable 'variable-documentation))) 612 (terpri)
609 (princ (or doc "not documented as a variable."))) 613 (let ((doc (documentation-property variable 'variable-documentation)))
610 (print-help-return-message) 614 (princ (or doc "not documented as a variable.")))
611 (save-excursion 615 (print-help-return-message)
612 (set-buffer standard-output) 616 (save-excursion
613 (help-mode) 617 (set-buffer standard-output)
614 ;; Return the text we displayed. 618 (help-mode)
615 (buffer-string)))) 619 ;; Return the text we displayed.
620 (buffer-string)))
621 (message "You did not specify a variable")))
616 622
617(defun where-is (definition) 623(defun where-is (definition)
618 "Print message listing key sequences that invoke specified command. 624 "Print message listing key sequences that invoke specified command.