Created
March 7, 2013 19:58
-
-
Save jorgenschaefer/5111244 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (defun minibuffer-complete () | |
| "Complete the minibuffer contents as far as possible. | |
| Return nil if there is no valid completion, else t. | |
| If no characters can be completed, display a list of possible completions. | |
| If you repeat this command after it displayed such a list, | |
| scroll the window of possible completions." | |
| (interactive) | |
| ;; If the previous command was not this, | |
| ;; mark the completion buffer obsolete. | |
| (setq this-command 'completion-at-point) | |
| (unless (eq 'completion-at-point last-command) | |
| (completion--flush-all-sorted-completions) | |
| (setq minibuffer-scroll-window nil)) | |
| (cond | |
| ;; If there's a fresh completion window with a live buffer, | |
| ;; and this command is repeated, scroll that window. | |
| ((window-live-p minibuffer-scroll-window) | |
| (let ((window minibuffer-scroll-window)) | |
| (with-current-buffer (window-buffer window) | |
| (if (pos-visible-in-window-p (point-max) window) | |
| ;; If end is in view, scroll up to the beginning. | |
| (set-window-start window (point-min) nil) | |
| ;; Else scroll down one screen. | |
| (with-selected-window window | |
| (scroll-up))) | |
| nil))) | |
| ;; If we're cycling, keep on cycling. | |
| ((and completion-cycling completion-all-sorted-completions) | |
| (minibuffer-force-complete) | |
| t) | |
| (t (pcase (completion--do-completion) | |
| (#b000 nil) | |
| (_ t))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment