[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
For after-the-release: enhanced partial completion
From: |
Sean O'Rourke |
Subject: |
For after-the-release: enhanced partial completion |
Date: |
Fri, 16 Feb 2007 21:39:10 -0800 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.93 (darwin) |
For quite awhile, I've been using the attached local change to
`PC-do-completion' to reduce the amount of typing required for
completing lisp symbols. Basically, if no completions are found,
`PC-do-completion' assumes that the user input is an
abbreviation. For example, say you want help on
`make-variable-buffer-local'. Currently, you have to type
"m-v-b-l<tab>". With this change, you can type "mvbl<tab>". Has
anyone else done something similar/better? Does anyone else find
this useful?
/s
Index: complete.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/complete.el,v
retrieving revision 1.59
diff -u -r1.59 complete.el
--- complete.el 21 Jan 2007 03:53:12 -0000 1.59
+++ complete.el 17 Feb 2007 05:30:17 -0000
@@ -396,6 +396,7 @@
(ambig nil)
basestr origstr
env-on
+ unexploded
regex
p offset
(poss nil)
@@ -527,17 +528,26 @@
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)
+ (setq
+ unexploded str
+ str (mapconcat #'list str "-")
+ regex (concat "\\`" (replace-regexp-in-string "-" "[^-]*-" str))
+ p 1)
+ (goto-char beg)
+ (delete-region beg end)
+ (setq end (+ beg (length str)))
+ (insert str)))
+ (when p
;; 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
@@ -546,6 +556,9 @@
table
pred)))
(setq p compl)
+ (when (and unexploded (not compl))
+ (setq str unexploded
+ p nil))
(while p
(and (string-match regex (car p))
(progn
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- For after-the-release: enhanced partial completion,
Sean O'Rourke <=