]> code.delx.au - gnu-emacs/blobdiff - lisp/tmm.el
* emacs-lisp/lisp-mode.el: Give `deftype' a doc-string-elt
[gnu-emacs] / lisp / tmm.el
index e8d98388afc32e2f9b15ffe0503140c59a08c417..7058f54ef8e70d8eb32a4ad7879a34d1e033d6a1 100644 (file)
@@ -1,7 +1,7 @@
 ;;; tmm.el --- text mode access to menu-bar
 
 ;; Copyright (C) 1994, 1995, 1996, 2000, 2001, 2002, 2003,
-;;   2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+;;   2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
 
 ;; Author: Ilya Zakharevich <ilya@math.mps.ohio-state.edu>
 ;; Maintainer: FSF
@@ -9,10 +9,10 @@
 
 ;; This file is part of GNU Emacs.
 
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 3, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -20,9 +20,7 @@
 ;; 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, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
 
@@ -345,8 +343,8 @@ Stores a list of all the shortcuts in the free variable `tmm-short-cuts'."
 
 (defun tmm-completion-delete-prompt ()
   (set-buffer standard-output)
-  (goto-char 1)
-  (delete-region 1 (search-forward "Possible completions are:\n")))
+  (goto-char (point-min))
+  (delete-region (point) (search-forward "Possible completions are:\n")))
 
 (defun tmm-remove-inactive-mouse-face ()
   "Remove the mouse-face property from inactive menu items."
@@ -378,9 +376,10 @@ Stores a list of all the shortcuts in the free variable `tmm-short-cuts'."
         (or tmm-completion-prompt
             (add-hook 'completion-setup-hook
                       'tmm-completion-delete-prompt 'append))
-       (with-output-to-temp-buffer "*Completions*"
-         (display-completion-list completions))
-        (remove-hook 'completion-setup-hook 'tmm-completion-delete-prompt))
+        (unwind-protect
+            (with-output-to-temp-buffer "*Completions*"
+              (display-completion-list completions))
+          (remove-hook 'completion-setup-hook 'tmm-completion-delete-prompt)))
       (set-buffer "*Completions*")
       (tmm-remove-inactive-mouse-face)
       (when tmm-completion-prompt
@@ -403,7 +402,7 @@ Stores a list of all the shortcuts in the free variable `tmm-short-cuts'."
 (defun tmm-shortcut ()
   "Choose the shortcut that the user typed."
   (interactive)
-  (let ((c last-command-char) s)
+  (let ((c last-command-event) s)
     (if (symbolp tmm-shortcut-style)
         (setq c (funcall tmm-shortcut-style c)))
     (if (memq c tmm-short-cuts)
@@ -463,11 +462,11 @@ It uses the free variable `tmm-table-undef' to keep undefined keys."
                   (or (keymapp (cdr-safe (cdr-safe elt)))
                       (eq (car (cdr-safe (cdr-safe elt))) 'lambda))
                 (fboundp (cdr-safe (cdr-safe elt))))
-              (setq km (cdr (cdr elt)))
+              (setq km (cddr elt))
               (and (stringp (car elt)) (setq str (car elt)))
               (and str
-                   (stringp (cdr (car (cdr elt)))) ; keyseq cache
-                   (setq cache (cdr (car (cdr elt))))
+                   (stringp (cdr-safe (cadr elt))) ; keyseq cache
+                   (setq cache (cdr (cadr elt)))
                    cache (setq str (concat str cache))))
 
              ((eq (car-safe elt) 'menu-item)
@@ -498,18 +497,17 @@ It uses the free variable `tmm-table-undef' to keep undefined keys."
                       (eq (car (cdr-safe (cdr-safe (cdr-safe elt)))) 'lambda))
                 (fboundp (cdr-safe (cdr-safe (cdr-safe elt)))))
                                         ; New style of easy-menu
-              (setq km (cdr (cdr (cdr elt))))
+              (setq km (cdr (cddr elt)))
               (and (stringp (car elt)) (setq str (car elt)))
               (and str
-                   (stringp (cdr (car (cdr (cdr elt))))) ; keyseq cache
+                   (stringp (cdr-safe (car (cddr elt)))) ; keyseq cache
                    (setq cache (cdr (car (cdr (cdr elt)))))
                    cache (setq str (concat str cache))))
 
              ((stringp event)          ; x-popup or x-popup element
               (if (or in-x-menu (stringp (car-safe elt)))
                   (setq str event event nil km elt)
-                (setq str event event nil km (cons 'keymap elt))
-                ))))
+                (setq str event event nil km (cons 'keymap elt))))))
       (and km (stringp km) (setq str km))
       ;; Verify that the command is enabled;
       ;; if not, don't mention it.