]> code.delx.au - gnu-emacs/blobdiff - lisp/tmm.el
(ps-mule-begin-job): Redo this change "if
[gnu-emacs] / lisp / tmm.el
index c532ec18f1f0433112663f33311c2924433c004b..7243818639118c4e23e292131e14efc51f8105d0 100644 (file)
@@ -176,6 +176,8 @@ Its value should be an event that has a binding in MENU."
        ;; This way we only ask the user one question,
        ;; for which element of that pane.
        (setq choice (cdr (car tmm-km-list)))
+      (unless tmm-km-list
+       (error "Empty menu reached"))
       (and tmm-km-list
           (let ((index-of-default 0))
             (if tmm-mid-prompt
@@ -220,7 +222,7 @@ Its value should be an event that has a binding in MENU."
           (string= (substring out 0 (length tmm-c-prompt)) tmm-c-prompt)
           (setq out (substring out (length tmm-c-prompt))
                 choice (cdr (assoc out tmm-km-list))))
-      (and (null choice)
+      (and (null choice) out
           (setq out (try-completion out tmm-km-list)
                 choice (cdr (assoc  out tmm-km-list)))))
     ;; CHOICE is now (STRING . MEANING).  Separate the two parts.
@@ -397,49 +399,60 @@ element of keymap, an `x-popup-menu' argument, or an element of
 `x-popup-menu' argument (when IN-X-MENU is not-nil).
 This function adds the element only if it is not already present.
 It uses the free variable `tmm-table-undef' to keep undefined keys."
-  (let (km str cache (event (car elt)))
+  (let (km str cache plist filter (event (car elt)))
     (setq elt (cdr elt))
     (if (eq elt 'undefined)
        (setq tmm-table-undef (cons (cons event nil) tmm-table-undef))
-      (or
-       (assoc event tmm-table-undef)
-       (and (if (listp elt)
-               (or (keymapp elt) (eq (car elt) 'lambda))
-             (fboundp elt))
-           (setq km elt))
-       (and (if (listp (cdr-safe elt))
-               (or (keymapp (cdr-safe elt))
-                   (eq (car (cdr-safe elt)) 'lambda))
-             (fboundp (cdr-safe elt)))
-           (setq km (cdr elt))
-           (and (stringp (car elt)) (setq str (car elt))))
-       (and (if (listp (cdr-safe (cdr-safe elt)))
-               (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)))
-           (and (stringp (car elt)) (setq str (car elt)))
-           (or (and str
-                    (stringp (cdr (car (cdr elt)))) ; keyseq cache
-                    (setq cache (cdr (car (cdr elt))))
-                    cache (setq str (concat str cache))) str))
-       (and (if (listp (cdr-safe (cdr-safe (cdr-safe elt))))
-               (or (keymapp (cdr-safe (cdr-safe (cdr-safe elt))))
-                   (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))))
-           (and (stringp (car elt)) (setq str (car elt)))
-           (or (and str
-                    (stringp (cdr (car (cdr (cdr elt))))) ; keyseq cache
-                    (setq cache (cdr (car (cdr (cdr elt)))))
-                    cache (setq str (concat str cache)))
-               str))
-           (and (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))
-                  )))
+      (unless (assoc event tmm-table-undef)
+       (cond ((if (listp elt)
+                  (or (keymapp elt) (eq (car elt) 'lambda))
+                (fboundp elt))
+              (setq km elt))
+             ((if (listp (cdr-safe elt))
+                  (or (keymapp (cdr-safe elt))
+                      (eq (car (cdr-safe elt)) 'lambda))
+                (fboundp (cdr-safe elt)))
+              (setq km (cdr elt))
+              (and (stringp (car elt)) (setq str (car elt))))
+             ((if (listp (cdr-safe (cdr-safe elt)))
+                  (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)))
+              (and (stringp (car elt)) (setq str (car elt)))
+              (and str
+                   (stringp (cdr (car (cdr elt)))) ; keyseq cache
+                   (setq cache (cdr (car (cdr elt))))
+                   cache (setq str (concat str cache))))
+             ((eq (car-safe elt) 'menu-item)
+              (setq plist (cdr-safe (cdr-safe (cdr-safe elt))))
+              (setq km (nth 2 elt))
+              (setq str (nth 1 elt))
+              (setq filter (plist-get plist :filter))
+              (if filter
+                  (setq km (funcall filter km)))
+              (and str
+                   (consp (nth 3 elt))
+                   (stringp (cdr (nth 3 elt))) ; keyseq cache
+                   (setq cache (cdr (nth 3 elt)))
+                   cache
+                   (setq str (concat str cache))))
+             ((if (listp (cdr-safe (cdr-safe (cdr-safe elt))))
+                  (or (keymapp (cdr-safe (cdr-safe (cdr-safe elt))))
+                      (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))))
+              (and (stringp (car elt)) (setq str (car elt)))
+              (and str
+                   (stringp (cdr (car (cdr (cdr 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))
+                ))))
       (and km (stringp km) (setq str km))
       ;; Verify that the command is enabled;
       ;; if not, don't mention it.