comparison lisp/help.el @ 90296:d57ee9eab157

Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-15 Merge from emacs--devo--0 Patches applied: * emacs--devo--0 (patch 66-84) - Update from CVS - rcirc: Add flexible response formatting; Add nick abbrevs - Merge from gnus--rel--5.10 - Update from CVS: man/dired.texi (Tumme): More tumme documentation. - Merge from erc--emacs--0 - Make ERC comply with the new copyright year guidelines. - (rcirc-format-response-string): Fix small bugs - Fix compiler error in erc-dcc.el. * gnus--rel--5.10 (patch 29) - Add sendmail.el and smptmail.el from Emacs tree to contrib/
author Miles Bader <miles@gnu.org>
date Tue, 14 Feb 2006 05:54:12 +0000
parents c5406394f567 284c53bcc6bf
children 9e490faa9f6b
comparison
equal deleted inserted replaced
90295:4b3d39451150 90296:d57ee9eab157
554 (let ((otherstring (key-description untranslated))) 554 (let ((otherstring (key-description untranslated)))
555 (if (equal string otherstring) 555 (if (equal string otherstring)
556 string 556 string
557 (format "%s (translated from %s)" string otherstring)))))) 557 (format "%s (translated from %s)" string otherstring))))))
558 558
559 (defun describe-key-briefly (key &optional insert untranslated) 559 (defun describe-key-briefly (&optional key insert untranslated)
560 "Print the name of the function KEY invokes. KEY is a string. 560 "Print the name of the function KEY invokes. KEY is a string.
561 If INSERT (the prefix arg) is non-nil, insert the message in the buffer. 561 If INSERT (the prefix arg) is non-nil, insert the message in the buffer.
562 If non-nil UNTRANSLATED is a vector of the untranslated events. 562 If non-nil, UNTRANSLATED is a vector of the untranslated events.
563 It can also be a number in which case the untranslated events from 563 It can also be a number in which case the untranslated events from
564 the last key hit are used." 564 the last key hit are used.
565 (interactive "kDescribe key briefly: \nP\np") 565
566 If KEY is a menu item or a tool-bar button that is disabled, this command
567 temporarily enables it to allow getting help on disabled items and buttons."
568 (interactive
569 (let ((enable-disabled-menus-and-buttons t)
570 (cursor-in-echo-area t)
571 saved-yank-menu)
572 (unwind-protect
573 (let (key)
574 ;; If yank-menu is empty, populate it temporarily, so that
575 ;; "Select and Paste" menu can generate a complete event.
576 (when (null (cdr yank-menu))
577 (setq saved-yank-menu (copy-sequence yank-menu))
578 (menu-bar-update-yank-menu "(any string)" nil))
579 (setq key (read-key-sequence "Describe key (or click or menu item): "))
580 (list
581 key
582 (prefix-numeric-value current-prefix-arg)
583 ;; If KEY is a down-event, read the corresponding up-event
584 ;; and use it as the third argument.
585 (if (and (consp key) (symbolp (car key))
586 (memq 'down (cdr (get (car key) 'event-symbol-elements))))
587 (read-event))))
588 ;; Put yank-menu back as it was, if we changed it.
589 (when saved-yank-menu
590 (setq yank-menu (copy-sequence saved-yank-menu))
591 (fset 'yank-menu (cons 'keymap yank-menu))))))
566 (if (numberp untranslated) 592 (if (numberp untranslated)
567 (setq untranslated (this-single-command-raw-keys))) 593 (setq untranslated (this-single-command-raw-keys)))
568 (save-excursion 594 (save-excursion
569 (let ((modifiers (event-modifiers (aref key 0))) 595 (let ((modifiers (event-modifiers (aref key 0)))
570 (standard-output (if insert (current-buffer) t)) 596 (standard-output (if insert (current-buffer) t))
582 (goto-char position))) 608 (goto-char position)))
583 ;; Ok, now look up the key and name the command. 609 ;; Ok, now look up the key and name the command.
584 (let ((defn (or (string-key-binding key) 610 (let ((defn (or (string-key-binding key)
585 (key-binding key t))) 611 (key-binding key t)))
586 key-desc) 612 key-desc)
613 ;; Handle the case where we faked an entry in "Select and Paste" menu.
614 (if (and (eq defn nil)
615 (stringp (aref key (1- (length key))))
616 (eq (key-binding (substring key 0 -1)) 'yank-menu))
617 (setq defn 'menu-bar-select-yank))
587 ;; Don't bother user with strings from (e.g.) the select-paste menu. 618 ;; Don't bother user with strings from (e.g.) the select-paste menu.
588 (if (stringp (aref key (1- (length key)))) 619 (if (stringp (aref key (1- (length key))))
589 (aset key (1- (length key)) "(any string)")) 620 (aset key (1- (length key)) "(any string)"))
590 (if (and (> (length untranslated) 0) 621 (if (and (> (length untranslated) 0)
591 (stringp (aref untranslated (1- (length untranslated))))) 622 (stringp (aref untranslated (1- (length untranslated)))))
599 "%s at that spot runs the command %s" 630 "%s at that spot runs the command %s"
600 "%s runs the command %s") 631 "%s runs the command %s")
601 key-desc 632 key-desc
602 (if (symbolp defn) defn (prin1-to-string defn))))))))) 633 (if (symbolp defn) defn (prin1-to-string defn)))))))))
603 634
604 (defun describe-key (key &optional untranslated up-event) 635 (defun describe-key (&optional key untranslated up-event)
605 "Display documentation of the function invoked by KEY. 636 "Display documentation of the function invoked by KEY.
606 KEY can be any kind of a key sequence; it can include keyboard events, 637 KEY can be any kind of a key sequence; it can include keyboard events,
607 mouse events, and/or menu events. When calling from a program, 638 mouse events, and/or menu events. When calling from a program,
608 pass KEY as a string or a vector. 639 pass KEY as a string or a vector.
609 640
610 If non-nil, UNTRANSLATED is a vector of the corresponding untranslated events. 641 If non-nil, UNTRANSLATED is a vector of the corresponding untranslated events.
611 It can also be a number, in which case the untranslated events from 642 It can also be a number, in which case the untranslated events from
612 the last key sequence entered are used." 643 the last key sequence entered are used.
613 ;; UP-EVENT is the up-event that was discarded by reading KEY, or nil. 644 UP-EVENT is the up-event that was discarded by reading KEY, or nil.
614 (interactive "kDescribe key (or click or menu item): \np\nU") 645
646 If KEY is a menu item or a tool-bar button that is disabled, this command
647 temporarily enables it to allow getting help on disabled items and buttons."
648 (interactive
649 (let ((enable-disabled-menus-and-buttons t)
650 (cursor-in-echo-area t)
651 saved-yank-menu)
652 (unwind-protect
653 (let (key)
654 ;; If yank-menu is empty, populate it temporarily, so that
655 ;; "Select and Paste" menu can generate a complete event.
656 (when (null (cdr yank-menu))
657 (setq saved-yank-menu (copy-sequence yank-menu))
658 (menu-bar-update-yank-menu "(any string)" nil))
659 (setq key (read-key-sequence "Describe key (or click or menu item): "))
660 (list
661 key
662 (prefix-numeric-value current-prefix-arg)
663 ;; If KEY is a down-event, read the corresponding up-event
664 ;; and use it as the third argument.
665 (if (and (consp key) (symbolp (car key))
666 (memq 'down (cdr (get (car key) 'event-symbol-elements))))
667 (read-event))))
668 ;; Put yank-menu back as it was, if we changed it.
669 (when saved-yank-menu
670 (setq yank-menu (copy-sequence saved-yank-menu))
671 (fset 'yank-menu (cons 'keymap yank-menu))))))
615 (if (numberp untranslated) 672 (if (numberp untranslated)
616 (setq untranslated (this-single-command-raw-keys))) 673 (setq untranslated (this-single-command-raw-keys)))
617 (save-excursion 674 (save-excursion
618 (let ((modifiers (event-modifiers (aref key 0))) 675 (let ((modifiers (event-modifiers (aref key 0)))
619 window position) 676 window position)
626 position (posn-point (event-start (aref key 0))))) 683 position (posn-point (event-start (aref key 0)))))
627 (when (windowp window) 684 (when (windowp window)
628 (set-buffer (window-buffer window)) 685 (set-buffer (window-buffer window))
629 (goto-char position)) 686 (goto-char position))
630 (let ((defn (or (string-key-binding key) (key-binding key t)))) 687 (let ((defn (or (string-key-binding key) (key-binding key t))))
688 ;; Handle the case where we faked an entry in "Select and Paste" menu.
689 (if (and (eq defn nil)
690 (stringp (aref key (1- (length key))))
691 (eq (key-binding (substring key 0 -1)) 'yank-menu))
692 (setq defn 'menu-bar-select-yank))
631 (if (or (null defn) (integerp defn) (equal defn 'undefined)) 693 (if (or (null defn) (integerp defn) (equal defn 'undefined))
632 (message "%s is undefined" (help-key-description key untranslated)) 694 (message "%s is undefined" (help-key-description key untranslated))
633 (help-setup-xref (list #'describe-function defn) (interactive-p)) 695 (help-setup-xref (list #'describe-function defn) (interactive-p))
634 ;; Don't bother user with strings from (e.g.) the select-paste menu. 696 ;; Don't bother user with strings from (e.g.) the select-paste menu.
635 (if (stringp (aref key (1- (length key)))) 697 (if (stringp (aref key (1- (length key))))