Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Commits on Sep 08, 2012
@DarwinAwardWinner Restore compatibility with Emacs 23 and earlier
The changes in 3ca7337 used a feature added in Emacs 24, making
ido-ubiquitous v1.4 incompatibile with Emacs 23 and earlier. Breaking
legacy compatibility was not intended, so this change restores proper
support for those earlier versions of emacs.

Fixes #5
d6084a3
@DarwinAwardWinner Version 1.5 dd59d88
Showing with 47 additions and 6 deletions.
  1. +2 −0  ChangeLog
  2. +45 −6 ido-ubiquitous.el
View
2  ChangeLog
@@ -1,5 +1,7 @@
2012-09-07 Ryan C. Thompson <rct@thompsonclan.org>
+ * Restore compatibility with Emacs 23 and earlier
+
* Work around an ido bug where providing both an initial input and
a default would break things
View
51 ido-ubiquitous.el
@@ -2,7 +2,7 @@
;; Author: Ryan C. Thompson
;; URL: https://github.com/DarwinAwardWinner/ido-ubiquitous
-;; Version: 1.4
+;; Version: 1.5
;; Created: 2011-09-01
;; Keywords: convenience
;; EmacsWiki: InteractivelyDoThings
@@ -57,7 +57,7 @@
(defvar ido-ubiquitous-orig-completing-read-function
- completing-read-function
+ (bound-and-true-p completing-read-function)
"The value of `completing-read-function' before ido-ubiquitous-mode was enabled.
This value will be restored when `ido-ubiquitous-mode' is
@@ -86,10 +86,24 @@ detects something that ido cannot handle.")
nil
:global t
:group 'ido-ubiquitous
- (setq completing-read-function
- (if ido-ubiquitous-mode
- 'completing-read-ido
- ido-ubiquitous-orig-completing-read-function)))
+ (when ido-ubiquitous-mode
+ (unless (bound-and-true-p ido-mode)
+ (warn "Ido-ubiquitous-mode enabled without ido mode.")))
+ (if (and (boundp 'completing-read-function)
+ ido-ubiquitous-orig-completing-read-function)
+ ;; Emacs 24 and later
+ (progn
+ ;; Ensure emacs 23 code disabled
+ (ad-disable-advice 'completing-read 'around 'ido-ubiquitous-legacy)
+ (ad-activate 'completing-read)
+ (setq completing-read-function
+ (if ido-ubiquitous-mode
+ 'completing-read-ido
+ ido-ubiquitous-orig-completing-read-function)))
+ ;; Emacs 23 and earlier
+ (funcall (if ido-ubiquitous-mode 'ad-enable-advice 'ad-disable-advice)
+ 'completing-read 'around 'ido-ubiquitous-legacy)
+ (ad-activate 'completing-read)))
;;;###autoload
(define-obsolete-variable-alias 'ido-ubiquitous
@@ -124,6 +138,31 @@ happen, so this feature may simply not work in some cases."
(defvar ido-next-call-replaces-completing-read nil)
(defvar ido-this-call-replaces-completing-read nil)
+;; Emacs 23-
+(defadvice completing-read (around ido-ubiquitous-legacy activate)
+ "Ido-based method for reading from the minibuffer with completion.
+ See `completing-read' for the meaning of the arguments."
+ (if (or inherit-input-method ; Can't handle this arg
+ (not ido-mode)
+ (not ido-ubiquitous-mode)
+ ;; Avoid infinite recursion from ido calling completing-read
+ (boundp 'ido-cur-item)
+ (memq this-command ido-ubiquitous-command-exceptions))
+ ad-do-it
+ (let ((allcomp (all-completions "" collection predicate)))
+ ;; Only use ido completion if there are actually any completions
+ ;; to offer.
+ (if allcomp
+ (let ((ido-next-call-replaces-completing-read t))
+ (setq ad-return-value
+ (ido-completing-read prompt allcomp
+ nil require-match initial-input hist def)))
+ ad-do-it))))
+
+(ad-disable-advice 'completing-read 'around 'ido-ubiquitous-legacy)
+(ad-activate 'completing-read)
+
+;; Emacs 24+
(defun completing-read-ido (prompt collection &optional predicate
require-match initial-input
hist def inherit-input-method)

No commit comments for this range

Something went wrong with that request. Please try again.