浏览代码

Enable magic fallback on C-f and C-b

Now C-f and C-b both fall back to non-ido completion inside
ido-ubiquitous when they would otherwise do nothing. This is consistent
with how they work in "ido-find-file" and "ido-switch-buffer".

Fixes #15.
Ryan C. Thompson 10 年之前
父节点
当前提交
01e6aa1f89
共有 1 个文件被更改,包括 21 次插入1 次删除
  1. 21 1
      ido-ubiquitous.el

+ 21 - 1
ido-ubiquitous.el

@@ -457,7 +457,12 @@ this to non-nil, but this is not recommended."
   "This holds the override being applied to the current call to `completing-read'.")
 
 (defun ido-ubiquitous-completing-read (&rest args)
-  "Wrapper for `ido-completing-read' that enables ido-ubiquitous features."
+  "Wrapper for `ido-completing-read' that enables ido-ubiquitous features.
+
+Unlike `ido-completing-read', this function can return with
+`ido-exit' set to `fallback', and any function that calls this
+should check the value of `ido-exit' and handle this case
+appropriately. For example, see `completing-read-ido'."
   (let ((ido-ubiquitous-next-call-replaces-completing-read t))
     (apply 'ido-completing-read args)))
 
@@ -586,6 +591,21 @@ completion for them."
                orig-args)
       result)))
 
+;; Fallback on magic C-f and C-b
+(defadvice ido-magic-forward-char (before ido-ubiquitous-fallback activate)
+  "Allow falling back in ido-ubiquitous."
+  (when ido-ubiquitous-this-call-replaces-completing-read
+    ;; `ido-context-switch-command' is already let-bound at this
+    ;; point.
+    (setq ido-context-switch-command #'ido-fallback-command)))
+
+(defadvice ido-magic-backward-char (before ido-ubiquitous-fallback activate)
+  "Allow falling back in ido-ubiquitous."
+  (when ido-ubiquitous-this-call-replaces-completing-read
+    ;; `ido-context-switch-command' is already let-bound at this
+    ;; point.
+    (setq ido-context-switch-command #'ido-fallback-command)))
+
 ;;; Old-style default support
 
 (defvar ido-ubiquitous-initial-item nil