;; stuff to make completions display themselves as you type. - always (require 'cl) (require 'completion) (defvar *old-self-insert-command* (symbol-function 'self-insert-command)) (defvar *completep* t) (defun maybe-display-next-completion () (when *completep* (let ((string (and *completep* (symbol-before-point-for-complete)))) (if string (progn (completion-search-reset string) (let ((it (completion-search-next 0))) (if (and (consp it) (zerop (or (minibuffer-depth) 0))) (message "%s" (car it)) ))))))) ;; patch the old one. This doesn't always work (defun self-insert-command (howmany) (interactive "p") (call-interactively *old-self-insert-command* howmany) (maybe-display-next-completion)) ;; it doesn't work for most of the characters, so make a new function, and ;; globally-bind it to all the alphabetic keys. (defun self-insert-command-1 (number) (interactive "p") (funcall *old-self-insert-command* number) (maybe-display-next-completion)) (defvar all-completing-keys "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ*!@#$%^&*()_-1234567890<>?") (dotimes (i (length all-completing-keys)) (global-set-key (format "%c" (aref all-completing-keys i)) 'self-insert-command-1)) ;(advise tmc-previous-line :after (maybe-display-next-completion)) ;(advise tmc-next-line :after (maybe-display-next-completion)) (if (search "XEmacs" emacs-version) (global-set-key '(control tab) 'complete) (global-set-key [C-tab] 'complete)) (global-set-key" " 'complete) (defadvice cmpl-forward-sexp (after arg) (maybe-display-next-completion)) (defadvice cmpl-backward-sexp (after arg) (maybe-display-next-completion)) (defadvice cmpl-forward-char (after arg) (maybe-display-next-completion)) (defadvice cmpl-backward-char (after arg) (maybe-display-next-completion)) (defun forward-word-1 (number) (interactive "p") (prog1 (forward-word number) (maybe-display-next-completion))) (defun backward-word-1 (number) (interactive "p") (prog1 (backward-word number) (maybe-display-next-completion))) (defun backward-char-1 (number) (interactive "p") (prog1 (backward-char number) (maybe-display-next-completion))) (defun forward-char-1 (number) (interactive "p") (prog1 (forward-char number) (maybe-display-next-completion))) (defun rebind-function-key-callers (old-function new-function) (mapcar '(lambda(key) (global-set-key key new-function)) (where-is-internal old-function))) (rebind-function-key-callers 'forward-word 'forward-word-1) (rebind-function-key-callers 'backward-word 'backward-word-1) (rebind-function-key-callers 'forward-char 'forward-char-1) (rebind-function-key-callers 'backward-char 'backward-char-1) (rebind-function-key-callers 'forward-word-command 'forward-word-1) (rebind-function-key-callers 'backward-word-command 'backward-word-1) (rebind-function-key-callers 'forward-char-command 'forward-char-1) (rebind-function-key-callers 'backward-char-command 'backward-char-1)