浏览代码

Add debug messages for overrides

Now whenever a function or command override is triggered, it emits a
debug message.
Ryan C. Thompson 10 年之前
父节点
当前提交
38008e77d9
共有 1 个文件被更改,包括 16 次插入7 次删除
  1. 16 7
      ido-ubiquitous.el

+ 16 - 7
ido-ubiquitous.el

@@ -394,9 +394,14 @@ See `ido-ubiquitous-command-overrides' for valid override types."
       (eval
       (eval
        `(defadvice ,func (around ido-ubiquitous-override activate)
        `(defadvice ,func (around ido-ubiquitous-override activate)
           ,docstring
           ,docstring
-          (ido-ubiquitous-with-override
-           (get ',func 'ido-ubiquitous-override)
-           ad-do-it))))))
+          (let* ((func ',func)
+                 (override (get func 'ido-ubiquitous-override)))
+            (when override
+              (ido-ubiquitous--debug-message
+               "Using override `%s' for function `%s'"
+               override func))
+            (ido-ubiquitous-with-override override
+              ad-do-it)))))))
 
 
 (defun ido-ubiquitous-set-function-overrides (sym newval)
 (defun ido-ubiquitous-set-function-overrides (sym newval)
   "Custom setter function for `ido-ubiquitous-function-overrides'.
   "Custom setter function for `ido-ubiquitous-function-overrides'.
@@ -844,9 +849,13 @@ See the C source for the logic behind this function."
 
 
 (defadvice call-interactively (around ido-ubiquitous activate)
 (defadvice call-interactively (around ido-ubiquitous activate)
   "Implements the behavior specified in `ido-ubiquitous-command-overrides'."
   "Implements the behavior specified in `ido-ubiquitous-command-overrides'."
-  (ido-ubiquitous-with-override
-   (ido-ubiquitous-get-command-override (ad-get-arg 0))
-   ad-do-it))
+  (let* ((cmd (ad-get-arg 0))
+         (override (ido-ubiquitous-get-command-override cmd)))
+    (when override
+      (ido-ubiquitous--debug-message "Using override `%s' for command `%s'"
+                                     override cmd))
+    (ido-ubiquitous-with-override override
+        ad-do-it)))
 
 
 ;; Work around `called-interactively-p' in Emacs 24.3 and earlier,
 ;; Work around `called-interactively-p' in Emacs 24.3 and earlier,
 ;; which always returns nil when `call-interactively' is advised.
 ;; which always returns nil when `call-interactively' is advised.
@@ -901,7 +910,7 @@ Debug info is printed to the *Messages* buffer."
     (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 (cdr 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)))
 
 
 ;;; Other
 ;;; Other