aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman2005-09-12 15:35:22 +0000
committerRichard M. Stallman2005-09-12 15:35:22 +0000
commit136b8cbeaa65660e2ee83337e822f7d37088441d (patch)
treecf496fbf063374967100237e1058fe4ca9cd486d
parent5629e04f32fb4aa48ae61f788828025b3b46106b (diff)
downloademacs-136b8cbeaa65660e2ee83337e822f7d37088441d.tar.gz
emacs-136b8cbeaa65660e2ee83337e822f7d37088441d.zip
(describe-variable): Rearrange to put source link in a predictable place.
-rw-r--r--lisp/help-fns.el134
1 files changed, 69 insertions, 65 deletions
diff --git a/lisp/help-fns.el b/lisp/help-fns.el
index ae7a60cf55e..2974e65bf88 100644
--- a/lisp/help-fns.el
+++ b/lisp/help-fns.el
@@ -522,16 +522,57 @@ it is displayed along with the global value."
522 (let* ((valvoid (not (with-current-buffer buffer (boundp variable)))) 522 (let* ((valvoid (not (with-current-buffer buffer (boundp variable))))
523 ;; Extract the value before setting up the output buffer, 523 ;; Extract the value before setting up the output buffer,
524 ;; in case `buffer' *is* the output buffer. 524 ;; in case `buffer' *is* the output buffer.
525 (val (unless valvoid (buffer-local-value variable buffer)))) 525 (val (unless valvoid (buffer-local-value variable buffer)))
526 val-start-pos)
526 (help-setup-xref (list #'describe-variable variable buffer) 527 (help-setup-xref (list #'describe-variable variable buffer)
527 (interactive-p)) 528 (interactive-p))
528 (with-output-to-temp-buffer (help-buffer) 529 (with-output-to-temp-buffer (help-buffer)
529 (with-current-buffer buffer 530 (with-current-buffer buffer
530 (prin1 variable) 531 (prin1 variable)
532 ;; Make a hyperlink to the library if appropriate. (Don't
533 ;; change the format of the buffer's initial line in case
534 ;; anything expects the current format.)
535 (let ((file-name (symbol-file variable 'defvar)))
536 (when (equal file-name "loaddefs.el")
537 ;; Find the real def site of the preloaded variable.
538 (let ((location
539 (condition-case nil
540 (find-variable-noselect variable file-name)
541 (error nil))))
542 (when location
543 (with-current-buffer (car location)
544 (goto-char (cdr location))
545 (when (re-search-backward
546 "^;;; Generated autoloads from \\(.*\\)" nil t)
547 (setq file-name (match-string 1)))))))
548 (when (and (null file-name)
549 (integerp (get variable 'variable-documentation)))
550 ;; It's a variable not defined in Elisp but in C.
551 (setq file-name
552 (if (get-buffer " *DOC*")
553 (help-C-file-name variable 'var)
554 'C-source)))
555 (if file-name
556 (progn
557 (princ " is a variable defined in `")
558 (princ (if (eq file-name 'C-source) "C source code" file-name))
559 (princ "'.\n")
560 (with-current-buffer standard-output
561 (save-excursion
562 (re-search-backward "`\\([^`']+\\)'" nil t)
563 (help-xref-button 1 'help-variable-def
564 variable file-name)))
565 (if valvoid
566 (princ "It is void as a variable.\n")
567 (princ "Its ")))
568 (if valvoid
569 (princ " is void as a variable.\n")
570 (princ "'s "))))
531 (if valvoid 571 (if valvoid
532 (princ " is void") 572 nil
533 (with-current-buffer standard-output 573 (with-current-buffer standard-output
534 (princ "'s value is ") 574 (setq val-start-pos (point))
575 (princ "value is ")
535 (terpri) 576 (terpri)
536 (let ((from (point))) 577 (let ((from (point)))
537 (pp val) 578 (pp val)
@@ -541,6 +582,7 @@ it is displayed along with the global value."
541 (if (< (point) (+ from 20)) 582 (if (< (point) (+ from 20))
542 (delete-region (1- from) from))))) 583 (delete-region (1- from) from)))))
543 (terpri) 584 (terpri)
585
544 (when (local-variable-p variable) 586 (when (local-variable-p variable)
545 (princ (format "%socal in buffer %s; " 587 (princ (format "%socal in buffer %s; "
546 (if (get variable 'permanent-local) 588 (if (get variable 'permanent-local)
@@ -561,38 +603,35 @@ it is displayed along with the global value."
561 ;; See previous comment for this function. 603 ;; See previous comment for this function.
562 ;; (help-xref-on-pp from (point)) 604 ;; (help-xref-on-pp from (point))
563 (if (< (point) (+ from 20)) 605 (if (< (point) (+ from 20))
564 (delete-region (1- from) from)))))) 606 (delete-region (1- from) from)))))))
565 (terpri)) 607 ;; Add a note for variables that have been make-var-buffer-local.
608 (when (and (local-variable-if-set-p variable)
609 (or (not (local-variable-p variable))
610 (with-temp-buffer
611 (local-variable-if-set-p variable))))
612 (princ "\nAutomatically becomes buffer-local when set in any fashion.\n"))
566 (terpri) 613 (terpri)
614
615 ;; If the value is large, move it to the end.
567 (with-current-buffer standard-output 616 (with-current-buffer standard-output
568 (when (> (count-lines (point-min) (point-max)) 10) 617 (when (> (count-lines (point-min) (point-max)) 10)
569 ;; Note that setting the syntax table like below 618 ;; Note that setting the syntax table like below
570 ;; makes forward-sexp move over a `'s' at the end 619 ;; makes forward-sexp move over a `'s' at the end
571 ;; of a symbol. 620 ;; of a symbol.
572 (set-syntax-table emacs-lisp-mode-syntax-table) 621 (set-syntax-table emacs-lisp-mode-syntax-table)
573 (goto-char (point-min)) 622 (goto-char val-start-pos)
574 (if valvoid 623 (delete-region (point) (progn (end-of-line) (point)))
575 (forward-line 1)
576 (forward-sexp 1)
577 (delete-region (point) (progn (end-of-line) (point)))
578 (save-excursion
579 (insert "\n\nValue:")
580 (set (make-local-variable 'help-button-cache)
581 (point-marker)))
582 (insert " value is shown ")
583 (insert-button "below"
584 'action help-button-cache
585 'follow-link t
586 'help-echo "mouse-2, RET: show value")
587 (insert ".\n\n")))
588 ;; Add a note for variables that have been make-var-buffer-local.
589 (when (and (local-variable-if-set-p variable)
590 (or (not (local-variable-p variable))
591 (with-temp-buffer
592 (local-variable-if-set-p variable))))
593 (save-excursion 624 (save-excursion
594 (forward-line -1) 625 (insert "\n\nValue:")
595 (insert "Automatically becomes buffer-local when set in any fashion.\n")))) 626 (set (make-local-variable 'help-button-cache)
627 (point-marker)))
628 (insert "value is shown ")
629 (insert-button "below"
630 'action help-button-cache
631 'follow-link t
632 'help-echo "mouse-2, RET: show value")
633 (insert ".\n\n")))
634
596 ;; Mention if it's an alias 635 ;; Mention if it's an alias
597 (let* ((alias (condition-case nil 636 (let* ((alias (condition-case nil
598 (indirect-variable variable) 637 (indirect-variable variable)
@@ -601,17 +640,15 @@ it is displayed along with the global value."
601 (doc (or (documentation-property variable 'variable-documentation) 640 (doc (or (documentation-property variable 'variable-documentation)
602 (documentation-property alias 'variable-documentation)))) 641 (documentation-property alias 'variable-documentation))))
603 (unless (eq alias variable) 642 (unless (eq alias variable)
604 (princ (format "This variable is an alias for `%s'." alias)) 643 (princ (format "\nThis variable is an alias for `%s'.\n" alias)))
605 (terpri)
606 (terpri))
607 (when obsolete 644 (when obsolete
608 (princ "This variable is obsolete") 645 (princ "\nThis variable is obsolete")
609 (if (cdr obsolete) (princ (format " since %s" (cdr obsolete)))) 646 (if (cdr obsolete) (princ (format " since %s" (cdr obsolete))))
610 (princ ";") (terpri) 647 (princ ";") (terpri)
611 (princ (if (stringp (car obsolete)) (car obsolete) 648 (princ (if (stringp (car obsolete)) (car obsolete)
612 (format "use `%s' instead." (car obsolete)))) 649 (format "use `%s' instead." (car obsolete))))
613 (terpri)
614 (terpri)) 650 (terpri))
651 (princ "Documentation:\n")
615 (princ (or doc "Not documented as a variable."))) 652 (princ (or doc "Not documented as a variable.")))
616 ;; Make a link to customize if this variable can be customized. 653 ;; Make a link to customize if this variable can be customized.
617 (if (custom-variable-p variable) 654 (if (custom-variable-p variable)
@@ -624,39 +661,6 @@ it is displayed along with the global value."
624 (re-search-backward 661 (re-search-backward
625 (concat "\\(" customize-label "\\)") nil t) 662 (concat "\\(" customize-label "\\)") nil t)
626 (help-xref-button 1 'help-customize-variable variable))))) 663 (help-xref-button 1 'help-customize-variable variable)))))
627 ;; Make a hyperlink to the library if appropriate. (Don't
628 ;; change the format of the buffer's initial line in case
629 ;; anything expects the current format.)
630 (let ((file-name (symbol-file variable 'defvar)))
631 (when (equal file-name "loaddefs.el")
632 ;; Find the real def site of the preloaded variable.
633 (let ((location
634 (condition-case nil
635 (find-variable-noselect variable file-name)
636 (error nil))))
637 (when location
638 (with-current-buffer (car location)
639 (goto-char (cdr location))
640 (when (re-search-backward
641 "^;;; Generated autoloads from \\(.*\\)" nil t)
642 (setq file-name (match-string 1)))))))
643 (when (and (null file-name)
644 (integerp (get variable 'variable-documentation)))
645 ;; It's a variable not defined in Elisp but in C.
646 (setq file-name
647 (if (get-buffer " *DOC*")
648 (help-C-file-name variable 'var)
649 'C-source)))
650 (when file-name
651 (princ "\n\nDefined in `")
652 (princ (if (eq file-name 'C-source) "C source code" file-name))
653 (princ "'.")
654 (with-current-buffer standard-output
655 (save-excursion
656 (re-search-backward "`\\([^`']+\\)'" nil t)
657 (help-xref-button 1 'help-variable-def
658 variable file-name)))))
659
660 (print-help-return-message) 664 (print-help-return-message)
661 (save-excursion 665 (save-excursion
662 (set-buffer standard-output) 666 (set-buffer standard-output)