Index: complete.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/complete.el,v retrieving revision 1.72 diff -u -r1.72 complete.el --- complete.el 14 Apr 2007 20:23:31 -0000 1.72 +++ complete.el 4 Jun 2007 21:31:54 -0000 @@ -454,6 +454,7 @@ env-on regex p offset + abbreviated (poss nil) helpposs (case-fold-search completion-ignore-case)) @@ -590,17 +591,23 @@ pred nil)) ;; Find an initial list of possible completions - (if (not (setq p (string-match (concat PC-delim-regex - (if filename "\\|\\*" "")) - str - (+ (length dirname) offset)))) - - ;; Minibuffer contains no hyphens -- simple case! - (setq poss (all-completions (if env-on - basestr str) - table - pred)) - + (unless (setq p (string-match (concat PC-delim-regex + (if filename "\\|\\*" "")) + str + (+ (length dirname) offset))) + + ;; Minibuffer contains no hyphens -- simple case! + (setq poss (all-completions (if env-on basestr str) + table + pred)) + (unless (or filename poss) + ;; Try completion as an abbreviation, e.g. "mvb" -> "m-v-b" + ;; -> "multiple-value-bind" + (setq regex (concat "\\`" (mapconcat #'list str "[^-]*-")) + origstr str + p 1 + abbreviated t))) + (when (or p abbreviated) ;; Use all-completions to do an initial cull. This is a big win, ;; since all-completions is written in C! (let ((compl (all-completions (if env-on @@ -609,6 +616,11 @@ table pred))) (setq p compl) + (when (and compl abbreviated) + (setq basestr (mapconcat 'list str "-")) + (delete-region beg end) + (setq end (+ beg (length basestr))) + (insert basestr))) (while p (and (string-match regex (car p)) (progn @@ -657,6 +669,9 @@ (let ((PC-word-failed-flag t)) (delete-backward-char 1) (PC-do-completion 'word)) + (when abbreviated + (delete-region beg end) + (insert origstr)) (beep) (PC-temp-minibuffer-message (if ambig " [Ambiguous dir name]" @@ -857,13 +872,11 @@ Otherwise, all symbols with function definitions, values or properties are considered." (interactive) - (let* ((end (point)) - ;; To complete the word under point, rather than just the portion - ;; before point, use this: -;;; (save-excursion -;;; (with-syntax-table lisp-mode-syntax-table -;;; (forward-sexp 1) -;;; (point)))) + (let* ((end + (save-excursion + (with-syntax-table lisp-mode-syntax-table + (forward-sexp 1) + (point)))) (beg (save-excursion (with-syntax-table lisp-mode-syntax-table (backward-sexp 1)