;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING. If not, write to
-;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+;; along with GNU Emacs; see the file COPYING. If not, write to the
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
;;; Commentary:
(and (symbolp type)
(memq 'down (event-modifiers type))
(read-event)))
- (let ((defn (key-binding key)))
- (if (or (null defn) (integerp defn))
- (message "%s is undefined" (key-description key))
- (message "%s runs the command %s"
- (key-description key)
- (if (symbolp defn) defn (prin1-to-string defn))))))
+ (save-excursion
+ (let ((modifiers (event-modifiers (aref key 0)))
+ window position)
+ ;; For a mouse button event, go to the button it applies to
+ ;; to get the right key bindings. And go to the right place
+ ;; in case the keymap depends on where you clicked.
+ (if (or (memq 'click modifiers) (memq 'down modifiers)
+ (memq 'drag modifiers))
+ (setq window (posn-window (event-start (aref key 0)))
+ position (posn-point (event-start (aref key 0)))))
+ (if (windowp window)
+ (progn
+ (set-buffer (window-buffer window))
+ (goto-char position)))
+ ;; Ok, now look up the key and name the command.
+ (let ((defn (key-binding key)))
+ (if (or (null defn) (integerp defn))
+ (message "%s is undefined" (key-description key))
+ (message (if (windowp window)
+ "%s at that spot runs the command %s"
+ "%s runs the command %s")
+ (key-description key)
+ (if (symbolp defn) defn (prin1-to-string defn))))))))
(defun print-help-return-message (&optional function)
"Display or return message saying how to restore windows after help command.
(and (symbolp type)
(memq 'down (event-modifiers type))
(read-event)))
- (let ((defn (key-binding key)))
- (if (or (null defn) (integerp defn))
- (message "%s is undefined" (key-description key))
- (with-output-to-temp-buffer "*Help*"
- (prin1 defn)
- (princ ":\n")
- (if (documentation defn)
- (princ (documentation defn))
- (princ "not documented"))
- (save-excursion
- (set-buffer standard-output)
- (help-mode))
- (print-help-return-message)))))
+ (save-excursion
+ (let ((modifiers (event-modifiers (aref key 0)))
+ window position)
+ ;; For a mouse button event, go to the button it applies to
+ ;; to get the right key bindings. And go to the right place
+ ;; in case the keymap depends on where you clicked.
+ (if (or (memq 'click modifiers) (memq 'down modifiers)
+ (memq 'drag modifiers))
+ (setq window (posn-window (event-start (aref key 0)))
+ position (posn-point (event-start (aref key 0)))))
+ (if (windowp window)
+ (progn
+ (set-buffer (window-buffer window))
+ (goto-char position)))
+ (let ((defn (key-binding key)))
+ (if (or (null defn) (integerp defn))
+ (message "%s is undefined" (key-description key))
+ (with-output-to-temp-buffer "*Help*"
+ (princ (key-description key))
+ (if (windowp window)
+ (princ " at that spot"))
+ (princ " runs the command ")
+ (prin1 defn)
+ (princ ":\n")
+ (let ((doc (documentation defn)))
+ (if doc
+ (progn (terpri)
+ (princ doc))
+ (princ "not documented")))
+ (save-excursion
+ (set-buffer standard-output)
+ (help-mode))
+ (print-help-return-message)))))))
(defun describe-mode ()
"Display documentation of current major mode and minor modes.
0 (match-beginning 0)))))
(while (and indicator (symbolp indicator))
(setq indicator (symbol-value indicator)))
- (princ (format "%s minor mode (indicator%s):\n"
- pretty-minor-mode indicator))
+ (princ (format "%s minor mode (%s):\n"
+ pretty-minor-mode
+ (if indicator
+ (format "indicator%s" indicator)
+ "no indicator")))
(princ (documentation minor-mode))
(princ "\n\n"))))
(setq minor-modes (cdr minor-modes))))
(and (symbolp obj) (fboundp obj) obj))))
(error nil))
(condition-case ()
- (save-excursion
- (and (or (eq (char-syntax (preceding-char)) ?_)
- (eq (char-syntax (preceding-char)) ?w))
- (forward-sexp -1))
- (skip-chars-forward "'")
- (let ((obj (read (current-buffer))))
- (and (symbolp obj) (fboundp obj) obj)))
+ (let ((stab (syntax-table)))
+ (unwind-protect
+ (save-excursion
+ (set-syntax-table emacs-lisp-mode-syntax-table)
+ (or (not (zerop (skip-syntax-backward "_w")))
+ (eq (char-syntax (following-char)) ?w)
+ (eq (char-syntax (following-char)) ?_)
+ (forward-sexp -1))
+ (skip-chars-forward "'")
+ (let ((obj (read (current-buffer))))
+ (and (symbolp obj) (fboundp obj) obj)))
+ (set-syntax-table stab)))
(error nil))))
(defun describe-function-find-file (function)
(intern (upcase (symbol-name arg)))))
arglist)))
(terpri))))
- (if (documentation function)
- (progn (terpri)
- (princ (documentation function)))
- (princ "not documented"))
- )
+ (let ((doc (documentation function)))
+ (if doc
+ (progn (terpri)
+ (princ doc))
+ (princ "not documented"))))
(print-help-return-message)
(save-excursion
(set-buffer standard-output)
(defun variable-at-point ()
(condition-case ()
- (save-excursion
- (and (or (eq (char-syntax (preceding-char)) ?_)
- (eq (char-syntax (preceding-char)) ?w))
- (forward-sexp -1))
- (skip-chars-forward "'")
- (let ((obj (read (current-buffer))))
- (and (symbolp obj) (boundp obj) obj)))
+ (let ((stab (syntax-table)))
+ (unwind-protect
+ (save-excursion
+ (set-syntax-table emacs-lisp-mode-syntax-table)
+ (or (not (zerop (skip-syntax-backward "_w")))
+ (eq (char-syntax (following-char)) ?w)
+ (eq (char-syntax (following-char)) ?_)
+ (forward-sexp -1))
+ (skip-chars-forward "'")
+ (let ((obj (read (current-buffer))))
+ (and (symbolp obj) (boundp obj) obj)))
+ (set-syntax-table stab)))
(error nil)))
(defun describe-variable (variable)
(princ "Documentation:")
(terpri)
(let ((doc (documentation-property variable 'variable-documentation)))
- (if doc
- (princ (substitute-command-keys doc))
- (princ "not documented as a variable.")))
+ (princ (or doc "not documented as a variable.")))
(print-help-return-message)
(save-excursion
(set-buffer standard-output)