Просмотр исходного кода

Fix ido-ubiquitous-debug-mode messages

All fallbacks were previously being reported as unknown errors due to
unintended redundant wrapping of all fallback signals inside another
fallback signal. Also, now the second argument to signal is always a
list, as the documentation says.

ido-cr+-debug-mode messages also got the equivalent treatment.
Ryan C. Thompson 8 лет назад
Родитель
Сommit
ce764a20fa
2 измененных файлов с 20 добавлено и 14 удалено
  1. 10 9
      ido-completing-read+.el
  2. 10 5
      ido-ubiquitous.el

+ 10 - 9
ido-completing-read+.el

@@ -143,9 +143,9 @@ https://github.com/DarwinAwardWinner/ido-ubiquitous/issues"
   (when ido-cr+-debug-mode
   (when ido-cr+-debug-mode
     (when (and (listp arg)
     (when (and (listp arg)
                (eq (car arg) 'ido-cr+-fallback))
                (eq (car arg) 'ido-cr+-fallback))
-      (setq arg (cdr arg)))
+      (setq arg (cadr arg)))
     (ido-cr+--debug-message "Falling back to `%s' because %s."
     (ido-cr+--debug-message "Falling back to `%s' because %s."
-                                   ido-cr+-fallback-function arg)))
+                            ido-cr+-fallback-function arg)))
 
 
 ;;;###autoload
 ;;;###autoload
 (defun ido-completing-read+ (prompt collection &optional predicate
 (defun ido-completing-read+ (prompt collection &optional predicate
@@ -169,22 +169,23 @@ completion for them."
           (cond
           (cond
            (inherit-input-method
            (inherit-input-method
             (signal 'ido-cr+-fallback
             (signal 'ido-cr+-fallback
-                    "ido cannot handle non-nil INHERIT-INPUT-METHOD"))
+                    '("ido cannot handle non-nil INHERIT-INPUT-METHOD")))
            ((bound-and-true-p completion-extra-properties)
            ((bound-and-true-p completion-extra-properties)
             (signal 'ido-cr+-fallback
             (signal 'ido-cr+-fallback
-                    "ido cannot handle non-nil `completion-extra-properties'"))
+                    '("ido cannot handle non-nil `completion-extra-properties'")))
            ((functionp collection)
            ((functionp collection)
             (signal 'ido-cr+-fallback
             (signal 'ido-cr+-fallback
-                    "ido cannot handle COLLECTION being a function")))
+                    '("ido cannot handle COLLECTION being a function"))))
           ;; Expand all possible completions
           ;; Expand all possible completions
           (setq collection (all-completions "" collection predicate))
           (setq collection (all-completions "" collection predicate))
           ;; Check for excessively large collection
           ;; Check for excessively large collection
           (when (and ido-cr+-max-items
           (when (and ido-cr+-max-items
                      (> (length collection) ido-cr+-max-items))
                      (> (length collection) ido-cr+-max-items))
             (signal 'ido-cr+-fallback
             (signal 'ido-cr+-fallback
-                    (format
-                     "there are more than %i items in COLLECTION (see `ido-cr+-max-items')"
-                     ido-cr+-max-items)))
+                    (list
+                     (format
+                      "there are more than %i items in COLLECTION (see `ido-cr+-max-items')"
+                      ido-cr+-max-items))))
           ;; ido doesn't natively handle DEF being a list. If DEF is a
           ;; ido doesn't natively handle DEF being a list. If DEF is a
           ;; list, prepend it to COLLECTION and set DEF to just the
           ;; list, prepend it to COLLECTION and set DEF to just the
           ;; car of the default list.
           ;; car of the default list.
@@ -219,7 +220,7 @@ completion for them."
             ;; This detects when the user triggered fallback mode
             ;; This detects when the user triggered fallback mode
             ;; manually.
             ;; manually.
             (when (eq ido-exit 'fallback)
             (when (eq ido-exit 'fallback)
-              (signal 'ido-cr+-fallback "user manually triggered fallback"))))
+              (signal 'ido-cr+-fallback '("user manually triggered fallback")))))
       ;; Handler for ido-cr+-fallback signal
       ;; Handler for ido-cr+-fallback signal
       (ido-cr+-fallback
       (ido-cr+-fallback
        (ido-cr+--explain-fallback sig)
        (ido-cr+--explain-fallback sig)

+ 10 - 5
ido-ubiquitous.el

@@ -114,7 +114,7 @@ Debug info is printed to the *Messages* buffer."
   (when ido-ubiquitous-debug-mode
   (when ido-ubiquitous-debug-mode
     (when (and (listp arg)
     (when (and (listp arg)
                (eq (car arg) 'ido-ubiquitous-fallback))
                (eq (car arg) 'ido-ubiquitous-fallback))
-      (setq arg (cdr arg)))
+      (setq arg (cadr arg)))
     (ido-ubiquitous--debug-message "Falling back to `%s' because %s."
     (ido-ubiquitous--debug-message "Falling back to `%s' because %s."
                                    ido-cr+-fallback-function arg)))
                                    ido-cr+-fallback-function arg)))
 
 
@@ -667,7 +667,7 @@ completion for them."
               ;; If ido-ubiquitous is disabled this time, fall back
               ;; If ido-ubiquitous is disabled this time, fall back
               (when (eq ido-ubiquitous-active-state 'disable)
               (when (eq ido-ubiquitous-active-state 'disable)
                 (signal 'ido-ubiquitous-fallback
                 (signal 'ido-ubiquitous-fallback
-                        "`ido-ubiquitous-active-state' is `disable'"))
+                        '("`ido-ubiquitous-active-state' is `disable'")))
               ;; Handle a collection that is a function: either expand
               ;; Handle a collection that is a function: either expand
               ;; completion list now or fall back
               ;; completion list now or fall back
               (when (functionp collection)
               (when (functionp collection)
@@ -679,15 +679,20 @@ completion for them."
                           ;; so it now becomes redundant.
                           ;; so it now becomes redundant.
                           predicate nil)
                           predicate nil)
                   (signal 'ido-ubiquitous-fallback
                   (signal 'ido-ubiquitous-fallback
-                          "COLLECTION is a function and there is no override")))
+                          '("COLLECTION is a function and there is no override"))))
               (let ((ido-ubiquitous-enable-next-call t))
               (let ((ido-ubiquitous-enable-next-call t))
                 (ido-completing-read+
                 (ido-completing-read+
                  prompt collection predicate require-match
                  prompt collection predicate require-match
                  initial-input hist def inherit-input-method)))
                  initial-input hist def inherit-input-method)))
+          ;; Pass through any known fallback signals to the outer
+          ;; `condition-case'
+          (ido-ubiquitous-fallback
+           (signal (car err) (cdr err)))
+          ;; Convert any other error into a fallback signal.
           (error
           (error
            (signal 'ido-ubiquitous-fallback
            (signal 'ido-ubiquitous-fallback
-                   (format "ido-ubiquitous encountered an unexpected error: %S"
-                           err))))
+                   (list (format "ido-ubiquitous encountered an unexpected error: %S"
+                                 err)))))
       ;; Handler for ido-ubiquitous-fallback signal
       ;; Handler for ido-ubiquitous-fallback signal
       (ido-ubiquitous-fallback
       (ido-ubiquitous-fallback
        (ido-ubiquitous--explain-fallback sig)
        (ido-ubiquitous--explain-fallback sig)