* For after-the-release: enhanced partial completion @ 2007-02-17 5:39 Sean O'Rourke 2007-06-04 15:26 ` Leo 2007-06-04 16:09 ` Leo 0 siblings, 2 replies; 19+ messages in thread From: Sean O'Rourke @ 2007-02-17 5:39 UTC (permalink / raw) To: emacs-devel 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 ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: For after-the-release: enhanced partial completion 2007-02-17 5:39 For after-the-release: enhanced partial completion Sean O'Rourke @ 2007-06-04 15:26 ` Leo 2007-06-04 16:09 ` Leo 1 sibling, 0 replies; 19+ messages in thread From: Leo @ 2007-06-04 15:26 UTC (permalink / raw) To: emacs-devel ----- Sean O'Rourke (2007-02-17) wrote:----- > 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? The feature is definitely useful. -- Leo <sdl.web AT gmail.com> (GPG Key: 9283AA3F) ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: For after-the-release: enhanced partial completion 2007-02-17 5:39 For after-the-release: enhanced partial completion Sean O'Rourke 2007-06-04 15:26 ` Leo @ 2007-06-04 16:09 ` Leo 2007-06-04 16:19 ` Sean O'Rourke 1 sibling, 1 reply; 19+ messages in thread From: Leo @ 2007-06-04 16:09 UTC (permalink / raw) To: Sean O'Rourke; +Cc: emacs-devel Dear Sean, ----- Sean O'Rourke (2007-02-17) wrote:----- > 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 [...] I have applied this patch. I try an example to expand to "emacs-lisp-mode" by: M-x e l m TAB The minibuffer shows "M-x e-l-m (no matches)" while the *completions* is showing: Click <mouse-2> on a completion to select it. In this buffer, type RET to select the completion near point. Possible completions are: emacs-lisp-mode emms-lyrics-mode erc-log-mode ess-listing-minor-mode Do you think this is a bug? regards, -- Leo <sdl.web AT gmail.com> (GPG Key: 9283AA3F) ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: For after-the-release: enhanced partial completion 2007-06-04 16:09 ` Leo @ 2007-06-04 16:19 ` Sean O'Rourke 2007-06-04 17:02 ` Leo 2007-06-04 19:27 ` For after-the-release: enhanced partial completion Eli Zaretskii 0 siblings, 2 replies; 19+ messages in thread From: Sean O'Rourke @ 2007-06-04 16:19 UTC (permalink / raw) To: Leo; +Cc: emacs-devel [-- Attachment #1: Type: text/plain, Size: 1173 bytes --] Leo <sdl.web@gmail.com> writes: > I have applied this patch. Wow, I'm impressed someone revisited this almost 4 months later! > I try an example to expand to "emacs-lisp-mode" by: > > M-x e l m TAB > > The minibuffer shows "M-x e-l-m (no matches)" while the *completions* is > showing: > > Click <mouse-2> on a completion to select it. > In this buffer, type RET to select the completion near point. > > Possible completions are: > emacs-lisp-mode emms-lyrics-mode > erc-log-mode ess-listing-minor-mode > > Do you think this is a bug? It sounds like one, but I don't see it currently with emacs -Q in CVS-HEAD Emacs. Specifically, *Completions* contains: ------------------------------------------------------------ Click <mouse-2> on a completion to select it. In this buffer, type RET to select the completion near point. Possible completions are: emacs-lisp-mode erc-log-mode ------------------------------------------------------------ and there's no '(no matches)' message in *Messages*. I've attached my current diff of complete.el, in case I changed something since my last message. /s [-- Attachment #2: Type: text/plain, Size: 2242 bytes --] 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 16:14:39 -0000 @@ -590,17 +590,32 @@ 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 "\\`" + (mapconcat #'list str + (if filename "[^/.]*[/.]" "[^-]*-")) + ;; (replace-regexp-in-string + ;; "-" "[^-]*-" + ;; (mapconcat #'list 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 @@ -609,6 +624,9 @@ table pred))) (setq p compl) + (when (and str (not compl)) + (setq ;; str unexploded + p nil)) (while p (and (string-match regex (car p)) (progn [-- Attachment #3: Type: text/plain, Size: 142 bytes --] _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: For after-the-release: enhanced partial completion 2007-06-04 16:19 ` Sean O'Rourke @ 2007-06-04 17:02 ` Leo 2007-06-04 21:33 ` Sean O'Rourke 2007-06-04 19:27 ` For after-the-release: enhanced partial completion Eli Zaretskii 1 sibling, 1 reply; 19+ messages in thread From: Leo @ 2007-06-04 17:02 UTC (permalink / raw) To: Sean O'Rourke; +Cc: emacs-devel Dear Sean, ----- Sean O'Rourke (2007-06-04) wrote:----- > Leo <sdl.web@gmail.com> writes: >> I have applied this patch. > > Wow, I'm impressed someone revisited this almost 4 months later! > >> I try an example to expand to "emacs-lisp-mode" by: >> >> M-x e l m TAB >> >> The minibuffer shows "M-x e-l-m (no matches)" while the *completions* is >> showing: >> >> Click <mouse-2> on a completion to select it. >> In this buffer, type RET to select the completion near point. >> >> Possible completions are: >> emacs-lisp-mode emms-lyrics-mode >> erc-log-mode ess-listing-minor-mode >> >> Do you think this is a bug? > > It sounds like one, but I don't see it currently with emacs -Q in > CVS-HEAD Emacs. Specifically, *Completions* contains: > ------------------------------------------------------------ > Click <mouse-2> on a completion to select it. > In this buffer, type RET to select the completion near point. > > Possible completions are: > emacs-lisp-mode erc-log-mode > ------------------------------------------------------------ > and there's no '(no matches)' message in *Messages*. > > I've attached my current diff of complete.el, in case I changed > something since my last message. > > /s Tried your new patch. It doesn't work for me. For example, when I typed 'M-x e l m TAB', it didn't expand to "e-l-m". Is this intended? Now I come back to your original patch. In 'Emacs -Q' indeed there is no "no matches" message. But the cursor stops at the end of "e-l-m" (i.e. after letter 'm') when I type "M-x e l m TAB". Could you improve it to stop after letter 'e' just like the unpatched PC-do-completion does? regards, -- Leo <sdl.web AT gmail.com> (GPG Key: 9283AA3F) ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: For after-the-release: enhanced partial completion 2007-06-04 17:02 ` Leo @ 2007-06-04 21:33 ` Sean O'Rourke [not found] ` <m2wsyjbd7a.fsf@sl392.st-edmunds.cam.ac.uk> 0 siblings, 1 reply; 19+ messages in thread From: Sean O'Rourke @ 2007-06-04 21:33 UTC (permalink / raw) To: Leo; +Cc: emacs-devel [-- Attachment #1: Type: text/plain, Size: 1028 bytes --] Leo <sdl.web@gmail.com> writes: > Tried your new patch. It doesn't work for me. For example, when I typed > 'M-x e l m TAB', it didn't expand to "e-l-m". Is this > intended? Yes, it was. My feeling was that this kind of completion is sort of a guess, so moving the point and inserting "-" would more likely be annoying rather than helpful. Having used it more, though, I think doing the expansion might be best. Does the attached patch do the right thing? I think it has the desired behavior: if "xyz" has multiple completions, it behaves just like "x-y-z", but if it has none, both point and "xyz" are left intact. However PC-do-completions, at 392 lines, is somewhat frightening, so I may have done something wrong. As unrelated issue, I noticed that PC-lisp-complete-symbol could stand to be improved. Try this: (insert "(mvb") (PC-lisp-complete-symbol) (insert "u") (PC-lisp-complete-symbol) There's already a commented-out version of the fix in complete.el, which should probably be enabled. /s [-- Attachment #2: Type: text/plain, Size: 3191 bytes --] 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) [-- Attachment #3: Type: text/plain, Size: 142 bytes --] _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel ^ permalink raw reply [flat|nested] 19+ messages in thread
[parent not found: <m2wsyjbd7a.fsf@sl392.st-edmunds.cam.ac.uk>]
* Re: For after-the-release: enhanced partial completion [not found] ` <m2wsyjbd7a.fsf@sl392.st-edmunds.cam.ac.uk> @ 2007-06-04 22:10 ` Sean O'Rourke 2007-06-04 22:20 ` Sean O'Rourke 1 sibling, 0 replies; 19+ messages in thread From: Sean O'Rourke @ 2007-06-04 22:10 UTC (permalink / raw) To: emacs-devel [-- Attachment #1: Type: text/plain, Size: 267 bytes --] Leo <sdl.web@gmail.com> writes: > After applying the patch, I can not load complete.el Sorry -- diff is suboptimal for viewing changes to Lisp code... Please see the attached patch, which is huge from the reindentation caused by inserting a missing parenthesis. /s [-- Attachment #2: Type: text/plain, Size: 32573 bytes --] 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 22:09:54 -0000 @@ -454,6 +454,7 @@ env-on regex p offset + abbreviated (poss nil) helpposs (case-fold-search completion-ignore-case)) @@ -468,346 +469,361 @@ (setq str (PC-try-completion str table pred)) (delete-region beg end) (insert str)) - 'complete) + 'complete) - ;; Do substitutions in directory names - (and filename - (setq basestr (or (file-name-directory str) "")) - (setq dirlength (length basestr)) - ;; Do substitutions in directory names - (setq p (substitute-in-file-name basestr)) - (not (string-equal basestr p)) - (setq str (concat p (file-name-nondirectory str))) - (progn - (delete-region beg end) - (insert str) - (setq end (+ beg (length str))))) - - ;; Prepare various delimiter strings - (or (equal PC-word-delimiters PC-delims) - (setq PC-delims PC-word-delimiters - PC-delim-regex (concat "[" PC-delims "]") - PC-ndelims-regex (concat "[^" PC-delims "]*") - PC-delims-list (append PC-delims nil))) - - ;; Add wildcards if necessary - (and filename - (let ((dir (file-name-directory str)) - (file (file-name-nondirectory str)) - ;; The base dir for file-completion is passed in `predicate'. - (default-directory (expand-file-name pred))) - (while (and (stringp dir) (not (file-directory-p dir))) - (setq dir (directory-file-name dir)) - (setq file (concat (replace-regexp-in-string - PC-delim-regex "*\\&" - (file-name-nondirectory dir)) - "*/" file)) - (setq dir (file-name-directory dir))) - (setq origstr str str (concat dir file)))) - - ;; Look for wildcard expansions in directory name - (and filename - (string-match "\\*.*/" str) - (let ((pat str) - ;; The base dir for file-completion is passed in `predicate'. - (default-directory (expand-file-name pred)) - files) - (setq p (1+ (string-match "/[^/]*\\'" pat))) - (while (setq p (string-match PC-delim-regex pat p)) - (setq pat (concat (substring pat 0 p) - "*" - (substring pat p)) - p (+ p 2))) - (setq files (PC-expand-many-files (concat pat "*"))) - (if files - (let ((dir (file-name-directory (car files))) - (p files)) - (while (and (setq p (cdr p)) - (equal dir (file-name-directory (car p))))) - (if p - (setq filename nil table nil pred nil - ambig t) - (delete-region beg end) - (setq str (concat dir (file-name-nondirectory str))) - (insert str) - (setq end (+ beg (length str))))) - (if origstr - ;; If the wildcards were introduced by us, it's possible - ;; that read-file-name-internal (especially our - ;; PC-include-file advice) can still find matches for the - ;; original string even if we couldn't, so remove the - ;; added wildcards. - (setq str origstr) - (setq filename nil table nil pred nil))))) - - ;; Strip directory name if appropriate - (if filename - (if incname - (setq basestr (substring str incname) - dirname (substring str 0 incname)) - (setq basestr (file-name-nondirectory str) - dirname (file-name-directory str)) - ;; Make sure str is consistent with its directory and basename - ;; parts. This is important on DOZe'NT systems when str only - ;; includes a drive letter, like in "d:". - (setq str (concat dirname basestr))) - (setq basestr str)) - - ;; Convert search pattern to a standard regular expression - (setq regex (regexp-quote basestr) - offset (if (and (> (length regex) 0) - (not (eq (aref basestr 0) ?\*)) - (or (eq PC-first-char t) - (and PC-first-char filename))) 1 0) - p offset) - (while (setq p (string-match PC-delim-regex regex p)) - (if (eq (aref regex p) ? ) - (setq regex (concat (substring regex 0 p) - PC-ndelims-regex - PC-delim-regex - (substring regex (1+ p))) - p (+ p (length PC-ndelims-regex) (length PC-delim-regex))) - (let ((bump (if (memq (aref regex p) - '(?$ ?^ ?\. ?* ?+ ?? ?[ ?] ?\\)) - -1 0))) - (setq regex (concat (substring regex 0 (+ p bump)) - PC-ndelims-regex - (substring regex (+ p bump))) - p (+ p (length PC-ndelims-regex) 1))))) - (setq p 0) - (if filename - (while (setq p (string-match "\\\\\\*" regex p)) - (setq regex (concat (substring regex 0 p) - "[^/]*" - (substring regex (+ p 2)))))) - ;;(setq the-regex regex) - (setq regex (concat "\\`" regex)) - - (and (> (length basestr) 0) - (= (aref basestr 0) ?$) - (setq env-on t - table PC-env-vars-alist - 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)) - - ;; 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 - (file-name-nondirectory (substring str 0 p)) - (substring str 0 p)) + ;; Do substitutions in directory names + (and filename + (setq basestr (or (file-name-directory str) "")) + (setq dirlength (length basestr)) + ;; Do substitutions in directory names + (setq p (substitute-in-file-name basestr)) + (not (string-equal basestr p)) + (setq str (concat p (file-name-nondirectory str))) + (progn + (delete-region beg end) + (insert str) + (setq end (+ beg (length str))))) + + ;; Prepare various delimiter strings + (or (equal PC-word-delimiters PC-delims) + (setq PC-delims PC-word-delimiters + PC-delim-regex (concat "[" PC-delims "]") + PC-ndelims-regex (concat "[^" PC-delims "]*") + PC-delims-list (append PC-delims nil))) + + ;; Add wildcards if necessary + (and filename + (let ((dir (file-name-directory str)) + (file (file-name-nondirectory str)) + ;; The base dir for file-completion is passed in `predicate'. + (default-directory (expand-file-name pred))) + (while (and (stringp dir) (not (file-directory-p dir))) + (setq dir (directory-file-name dir)) + (setq file (concat (replace-regexp-in-string + PC-delim-regex "*\\&" + (file-name-nondirectory dir)) + "*/" file)) + (setq dir (file-name-directory dir))) + (setq origstr str str (concat dir file)))) + + ;; Look for wildcard expansions in directory name + (and filename + (string-match "\\*.*/" str) + (let ((pat str) + ;; The base dir for file-completion is passed in `predicate'. + (default-directory (expand-file-name pred)) + files) + (setq p (1+ (string-match "/[^/]*\\'" pat))) + (while (setq p (string-match PC-delim-regex pat p)) + (setq pat (concat (substring pat 0 p) + "*" + (substring pat p)) + p (+ p 2))) + (setq files (PC-expand-many-files (concat pat "*"))) + (if files + (let ((dir (file-name-directory (car files))) + (p files)) + (while (and (setq p (cdr p)) + (equal dir (file-name-directory (car p))))) + (if p + (setq filename nil table nil pred nil + ambig t) + (delete-region beg end) + (setq str (concat dir (file-name-nondirectory str))) + (insert str) + (setq end (+ beg (length str))))) + (if origstr + ;; If the wildcards were introduced by us, it's possible + ;; that read-file-name-internal (especially our + ;; PC-include-file advice) can still find matches for the + ;; original string even if we couldn't, so remove the + ;; added wildcards. + (setq str origstr) + (setq filename nil table nil pred nil))))) + + ;; Strip directory name if appropriate + (if filename + (if incname + (setq basestr (substring str incname) + dirname (substring str 0 incname)) + (setq basestr (file-name-nondirectory str) + dirname (file-name-directory str)) + ;; Make sure str is consistent with its directory and basename + ;; parts. This is important on DOZe'NT systems when str only + ;; includes a drive letter, like in "d:". + (setq str (concat dirname basestr))) + (setq basestr str)) + + ;; Convert search pattern to a standard regular expression + (setq regex (regexp-quote basestr) + offset (if (and (> (length regex) 0) + (not (eq (aref basestr 0) ?\*)) + (or (eq PC-first-char t) + (and PC-first-char filename))) 1 0) + p offset) + (while (setq p (string-match PC-delim-regex regex p)) + (if (eq (aref regex p) ? ) + (setq regex (concat (substring regex 0 p) + PC-ndelims-regex + PC-delim-regex + (substring regex (1+ p))) + p (+ p (length PC-ndelims-regex) (length PC-delim-regex))) + (let ((bump (if (memq (aref regex p) + '(?$ ?^ ?\. ?* ?+ ?? ?[ ?] ?\\)) + -1 0))) + (setq regex (concat (substring regex 0 (+ p bump)) + PC-ndelims-regex + (substring regex (+ p bump))) + p (+ p (length PC-ndelims-regex) 1))))) + (setq p 0) + (if filename + (while (setq p (string-match "\\\\\\*" regex p)) + (setq regex (concat (substring regex 0 p) + "[^/]*" + (substring regex (+ p 2)))))) + ;;(setq the-regex regex) + (setq regex (concat "\\`" regex)) + + (and (> (length basestr) 0) + (= (aref basestr 0) ?$) + (setq env-on t + table PC-env-vars-alist + pred nil)) + + ;; Find an initial list of possible completions + (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))) - (setq p compl) - (while p - (and (string-match regex (car p)) - (progn - (set-text-properties 0 (length (car p)) '() (car p)) - (setq poss (cons (car p) poss)))) - (setq p (cdr p))))) - - ;; If table had duplicates, they can be here. - (delete-dups poss) - - ;; Handle completion-ignored-extensions - (and filename - (not (eq mode 'help)) - (let ((p2 poss)) - - ;; Build a regular expression representing the extensions list - (or (equal completion-ignored-extensions PC-ignored-extensions) - (setq PC-ignored-regexp - (concat "\\(" - (mapconcat - 'regexp-quote - (setq PC-ignored-extensions - completion-ignored-extensions) - "\\|") - "\\)\\'"))) - - ;; Check if there are any without an ignored extension. - ;; Also ignore `.' and `..'. - (setq p nil) - (while p2 - (or (string-match PC-ignored-regexp (car p2)) - (string-match "\\(\\`\\|/\\)[.][.]?/?\\'" (car p2)) - (setq p (cons (car p2) p))) - (setq p2 (cdr p2))) - - ;; If there are "good" names, use them - (and p (setq poss p)))) - - ;; Now we have a list of possible completions - (cond - - ;; No valid completions found - ((null poss) - (if (and (eq mode 'word) - (not PC-word-failed-flag)) - (let ((PC-word-failed-flag t)) - (delete-backward-char 1) - (PC-do-completion 'word)) - (beep) - (PC-temp-minibuffer-message (if ambig - " [Ambiguous dir name]" - (if (eq mode 'help) - " [No completions]" - " [No match]"))) - nil)) - - ;; More than one valid completion found - ((or (cdr (setq helpposs poss)) - (memq mode '(help word))) - - ;; Is the actual string one of the possible completions? - (setq p (and (not (eq mode 'help)) poss)) - (while (and p - (not (string-equal (car p) basestr))) - (setq p (cdr p))) - (and p (null mode) - (PC-temp-minibuffer-message " [Complete, but not unique]")) - (if (and p - (not (and (null mode) - (eq this-command last-command)))) - t - - ;; If ambiguous, try for a partial completion - (let ((improved nil) - prefix - (pt nil) - (skip "\\`")) - - ;; Check if next few letters are the same in all cases - (if (and (not (eq mode 'help)) - (setq prefix (PC-try-completion - (PC-chunk-after basestr skip) poss))) - (let ((first t) i) - ;; Retain capitalization of user input even if - ;; completion-ignore-case is set. - (if (eq mode 'word) - (setq prefix (PC-chop-word prefix basestr))) - (goto-char (+ beg (length dirname))) - (while (and (progn - (setq i 0) ; index into prefix string - (while (< i (length prefix)) - (if (and (< (point) end) - (eq (downcase (aref prefix i)) - (downcase (following-char)))) - ;; same char (modulo case); no action - (forward-char 1) - (if (and (< (point) end) - (and (looking-at " ") - (memq (aref prefix i) - PC-delims-list))) - ;; replace " " by the actual delimiter - (progn - (delete-char 1) - (insert (substring prefix i (1+ i)))) - ;; insert a new character - (progn - (and filename (looking-at "\\*") - (progn - (delete-char 1) - (setq end (1- end)))) - (setq improved t) - (insert (substring prefix i (1+ i))) - (setq end (1+ end))))) - (setq i (1+ i))) - (or pt (setq pt (point))) - (looking-at PC-delim-regex)) - (setq skip (concat skip - (regexp-quote prefix) - PC-ndelims-regex) - prefix (PC-try-completion - (PC-chunk-after - ;; not basestr, because that does - ;; not reflect insertions - (buffer-substring - (+ beg (length dirname)) end) - skip) - (mapcar - (lambda (x) - (when (string-match skip x) - (substring x (match-end 0)))) - poss))) - (or (> i 0) (> (length prefix) 0)) - (or (not (eq mode 'word)) - (and first (> (length prefix) 0) - (setq first nil - prefix (substring prefix 0 1)))))) - (goto-char (if (eq mode 'word) end - (or pt beg))))) - - (if (and (eq mode 'word) - (not PC-word-failed-flag)) - - (if improved - - ;; We changed it... would it be complete without the space? - (if (test-completion (buffer-substring 1 (1- end)) - table pred) - (delete-region (1- end) end))) - - (if improved - - ;; We changed it... enough to be complete? - (and (eq mode 'exit) - (test-completion-ignore-case (field-string) table pred)) - - ;; If totally ambiguous, display a list of completions - (if (or (eq completion-auto-help t) - (and completion-auto-help - (eq last-command this-command)) - (eq mode 'help)) - (let ((prompt-end (minibuffer-prompt-end))) - (with-output-to-temp-buffer "*Completions*" - (display-completion-list (sort helpposs 'string-lessp)) - (setq PC-do-completion-end end - PC-goto-end goto-end) - (with-current-buffer standard-output - ;; Record which part of the buffer we are completing - ;; so that choosing a completion from the list - ;; knows how much old text to replace. - ;; This was briefly nil in the non-dirname case. - ;; However, if one calls PC-lisp-complete-symbol - ;; on "(ne-f" with point on the hyphen, PC offers - ;; all completions starting with "(ne", some of - ;; which do not match the "-f" part (maybe it - ;; should not, but it does). In such cases, - ;; completion gets confused trying to figure out - ;; how much to replace, so we tell it explicitly - ;; (ie, the number of chars in the buffer before beg). - ;; - ;; Note that choose-completion-string-functions - ;; plays around with point. - (setq completion-base-size (if dirname - dirlength - (- beg prompt-end)))))) - (PC-temp-minibuffer-message " [Next char not unique]")) - nil))))) - - ;; Only one possible completion - (t - (if (and (equal basestr (car poss)) - (not (and env-on filename))) - (if (null mode) - (PC-temp-minibuffer-message " [Sole completion]")) - (delete-region beg end) - (insert (format "%s" - (if filename - (substitute-in-file-name (concat dirname (car poss))) - (car poss))))) - t))))) + 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 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 + (file-name-nondirectory (substring str 0 p)) + (substring str 0 p)) + 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 + (set-text-properties 0 (length (car p)) '() (car p)) + (setq poss (cons (car p) poss)))) + (setq p (cdr p)))) + + ;; If table had duplicates, they can be here. + (delete-dups poss) + + ;; Handle completion-ignored-extensions + (and filename + (not (eq mode 'help)) + (let ((p2 poss)) + + ;; Build a regular expression representing the extensions list + (or (equal completion-ignored-extensions PC-ignored-extensions) + (setq PC-ignored-regexp + (concat "\\(" + (mapconcat + 'regexp-quote + (setq PC-ignored-extensions + completion-ignored-extensions) + "\\|") + "\\)\\'"))) + + ;; Check if there are any without an ignored extension. + ;; Also ignore `.' and `..'. + (setq p nil) + (while p2 + (or (string-match PC-ignored-regexp (car p2)) + (string-match "\\(\\`\\|/\\)[.][.]?/?\\'" (car p2)) + (setq p (cons (car p2) p))) + (setq p2 (cdr p2))) + + ;; If there are "good" names, use them + (and p (setq poss p)))) + + ;; Now we have a list of possible completions + + (cond + + ;; No valid completions found + ((null poss) + (if (and (eq mode 'word) + (not PC-word-failed-flag)) + (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]" + (if (eq mode 'help) + " [No completions]" + " [No match]"))) + nil)) + + ;; More than one valid completion found + ((or (cdr (setq helpposs poss)) + (memq mode '(help word))) + + ;; Is the actual string one of the possible completions? + (setq p (and (not (eq mode 'help)) poss)) + (while (and p + (not (string-equal (car p) basestr))) + (setq p (cdr p))) + (and p (null mode) + (PC-temp-minibuffer-message " [Complete, but not unique]")) + (if (and p + (not (and (null mode) + (eq this-command last-command)))) + t + + ;; If ambiguous, try for a partial completion + (let ((improved nil) + prefix + (pt nil) + (skip "\\`")) + + ;; Check if next few letters are the same in all cases + (if (and (not (eq mode 'help)) + (setq prefix (PC-try-completion + (PC-chunk-after basestr skip) poss))) + (let ((first t) i) + ;; Retain capitalization of user input even if + ;; completion-ignore-case is set. + (if (eq mode 'word) + (setq prefix (PC-chop-word prefix basestr))) + (goto-char (+ beg (length dirname))) + (while (and (progn + (setq i 0) ; index into prefix string + (while (< i (length prefix)) + (if (and (< (point) end) + (eq (downcase (aref prefix i)) + (downcase (following-char)))) + ;; same char (modulo case); no action + (forward-char 1) + (if (and (< (point) end) + (and (looking-at " ") + (memq (aref prefix i) + PC-delims-list))) + ;; replace " " by the actual delimiter + (progn + (delete-char 1) + (insert (substring prefix i (1+ i)))) + ;; insert a new character + (progn + (and filename (looking-at "\\*") + (progn + (delete-char 1) + (setq end (1- end)))) + (setq improved t) + (insert (substring prefix i (1+ i))) + (setq end (1+ end))))) + (setq i (1+ i))) + (or pt (setq pt (point))) + (looking-at PC-delim-regex)) + (setq skip (concat skip + (regexp-quote prefix) + PC-ndelims-regex) + prefix (PC-try-completion + (PC-chunk-after + ;; not basestr, because that does + ;; not reflect insertions + (buffer-substring + (+ beg (length dirname)) end) + skip) + (mapcar + (lambda (x) + (when (string-match skip x) + (substring x (match-end 0)))) + poss))) + (or (> i 0) (> (length prefix) 0)) + (or (not (eq mode 'word)) + (and first (> (length prefix) 0) + (setq first nil + prefix (substring prefix 0 1)))))) + (goto-char (if (eq mode 'word) end + (or pt beg))))) + + (if (and (eq mode 'word) + (not PC-word-failed-flag)) + + (if improved + + ;; We changed it... would it be complete without the space? + (if (test-completion (buffer-substring 1 (1- end)) + table pred) + (delete-region (1- end) end))) + + (if improved + + ;; We changed it... enough to be complete? + (and (eq mode 'exit) + (test-completion-ignore-case (field-string) table pred)) + + ;; If totally ambiguous, display a list of completions + (if (or (eq completion-auto-help t) + (and completion-auto-help + (eq last-command this-command)) + (eq mode 'help)) + (let ((prompt-end (minibuffer-prompt-end))) + (with-output-to-temp-buffer "*Completions*" + (display-completion-list (sort helpposs 'string-lessp)) + (setq PC-do-completion-end end + PC-goto-end goto-end) + (with-current-buffer standard-output + ;; Record which part of the buffer we are completing + ;; so that choosing a completion from the list + ;; knows how much old text to replace. + ;; This was briefly nil in the non-dirname case. + ;; However, if one calls PC-lisp-complete-symbol + ;; on "(ne-f" with point on the hyphen, PC offers + ;; all completions starting with "(ne", some of + ;; which do not match the "-f" part (maybe it + ;; should not, but it does). In such cases, + ;; completion gets confused trying to figure out + ;; how much to replace, so we tell it explicitly + ;; (ie, the number of chars in the buffer before beg). + ;; + ;; Note that choose-completion-string-functions + ;; plays around with point. + (setq completion-base-size (if dirname + dirlength + (- beg prompt-end)))))) + (PC-temp-minibuffer-message " [Next char not unique]")) + nil))))) + + ;; Only one possible completion + (t + (if (and (equal basestr (car poss)) + (not (and env-on filename))) + (if (null mode) + (PC-temp-minibuffer-message " [Sole completion]")) + (delete-region beg end) + (insert (format "%s" + (if filename + (substitute-in-file-name (concat dirname (car poss))) + (car poss))))) + t))))) (defun PC-chop-word (new old) (let ((i -1) @@ -857,13 +873,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) [-- Attachment #3: Type: text/plain, Size: 142 bytes --] _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: For after-the-release: enhanced partial completion [not found] ` <m2wsyjbd7a.fsf@sl392.st-edmunds.cam.ac.uk> 2007-06-04 22:10 ` Sean O'Rourke @ 2007-06-04 22:20 ` Sean O'Rourke 2007-06-05 6:40 ` Leo 2007-06-05 10:39 ` Leo 1 sibling, 2 replies; 19+ messages in thread From: Sean O'Rourke @ 2007-06-04 22:20 UTC (permalink / raw) To: emacs-devel [-- Attachment #1: Type: text/plain, Size: 60 bytes --] Here's a diff with "-w", which better shows the intent. /s [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #2: cvs.diff --] [-- Type: text/x-patch, Size: 3619 bytes --] Index: complete.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/complete.el,v retrieving revision 1.72 diff -p -u -w -r1.72 complete.el --- complete.el 14 Apr 2007 20:23:31 -0000 1.72 +++ complete.el 4 Jun 2007 22:12:42 -0000 @@ -454,6 +454,7 @@ GOTO-END is non-nil, however, it instead env-on regex p offset + abbreviated (poss nil) helpposs (case-fold-search completion-ignore-case)) @@ -590,17 +591,23 @@ GOTO-END is non-nil, however, it instead pred nil)) ;; Find an initial list of possible completions - (if (not (setq p (string-match (concat PC-delim-regex + (unless (setq p (string-match (concat PC-delim-regex (if filename "\\|\\*" "")) str - (+ (length dirname) offset)))) + (+ (length dirname) offset))) ;; Minibuffer contains no hyphens -- simple case! - (setq poss (all-completions (if env-on - basestr str) + (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 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 @@ -609,12 +616,17 @@ GOTO-END is non-nil, however, it instead 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 (set-text-properties 0 (length (car p)) '() (car p)) (setq poss (cons (car p) poss)))) - (setq p (cdr p))))) + (setq p (cdr p)))) ;; If table had duplicates, they can be here. (delete-dups poss) @@ -648,6 +660,7 @@ GOTO-END is non-nil, however, it instead (and p (setq poss p)))) ;; Now we have a list of possible completions + (cond ;; No valid completions found @@ -657,6 +670,9 @@ GOTO-END is non-nil, however, it instead (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 +873,11 @@ only symbols with function definitions a 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) [-- Attachment #3: Type: text/plain, Size: 142 bytes --] _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: For after-the-release: enhanced partial completion 2007-06-04 22:20 ` Sean O'Rourke @ 2007-06-05 6:40 ` Leo 2007-06-05 10:39 ` Leo 1 sibling, 0 replies; 19+ messages in thread From: Leo @ 2007-06-05 6:40 UTC (permalink / raw) To: emacs-devel ----- Sean O'Rourke (2007-06-04) wrote:----- > Here's a diff with "-w", which better shows the intent. > > /s [...] This patch works really well. Thanks. -- Leo <sdl.web AT gmail.com> (GPG Key: 9283AA3F) ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: For after-the-release: enhanced partial completion 2007-06-04 22:20 ` Sean O'Rourke 2007-06-05 6:40 ` Leo @ 2007-06-05 10:39 ` Leo 2007-06-05 14:56 ` Sean O'Rourke 1 sibling, 1 reply; 19+ messages in thread From: Leo @ 2007-06-05 10:39 UTC (permalink / raw) To: Sean O'Rourke; +Cc: emacs-devel Dear Sean, ----- Sean O'Rourke (2007-06-04) wrote:----- > Here's a diff with "-w", which better shows the intent. > > /s Just spotted a bug. Problem: PC-lisp-complete-symbol fails in `eval-expression'. Reproduce: 1. emacs -Q 2. M-x partial-completion-mode 3. M-: and then type in minibuffer `(emacs)' 4. Move the cursor to be on ")" and hit "M-TAB" BACKTRACE Debugger entered--Lisp error: (scan-error "Containing expression ends premature$ scan-sexps(13 1) forward-sexp(1) PC-lisp-complete-symbol() call-interactively(PC-lisp-complete-symbol) read-from-minibuffer("Eval: " nil (keymap (27 keymap (9 . PC-lisp-complete-sy$ (let ((minibuffer-completing-symbol t)) (read-from-minibuffer "Eval: " nil re$ (list (let (...) (read-from-minibuffer "Eval: " nil read-expression-map t ...$ call-interactively(eval-expression) HTH, -- Leo <sdl.web AT gmail.com> (GPG Key: 9283AA3F) ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: For after-the-release: enhanced partial completion 2007-06-05 10:39 ` Leo @ 2007-06-05 14:56 ` Sean O'Rourke 2007-06-05 15:32 ` Leo 0 siblings, 1 reply; 19+ messages in thread From: Sean O'Rourke @ 2007-06-05 14:56 UTC (permalink / raw) To: Leo; +Cc: emacs-devel [-- Attachment #1: Type: text/plain, Size: 253 bytes --] Leo <sdl.web@gmail.com> writes: > Reproduce: > 1. emacs -Q > 2. M-x partial-completion-mode > 3. M-: and then type in minibuffer `(emacs)' > 4. Move the cursor to be on ")" and hit "M-TAB" Thanks. Please try this version instead. /s [-- Attachment #2: Type: text/plain, Size: 3629 bytes --] Index: complete.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/complete.el,v retrieving revision 1.72 diff -p -u -w -r1.72 complete.el --- complete.el 14 Apr 2007 20:23:31 -0000 1.72 +++ complete.el 5 Jun 2007 14:54:14 -0000 @@ -454,6 +454,7 @@ GOTO-END is non-nil, however, it instead env-on regex p offset + abbreviated (poss nil) helpposs (case-fold-search completion-ignore-case)) @@ -590,17 +591,23 @@ GOTO-END is non-nil, however, it instead pred nil)) ;; Find an initial list of possible completions - (if (not (setq p (string-match (concat PC-delim-regex + (unless (setq p (string-match (concat PC-delim-regex (if filename "\\|\\*" "")) str - (+ (length dirname) offset)))) + (+ (length dirname) offset))) ;; Minibuffer contains no hyphens -- simple case! - (setq poss (all-completions (if env-on - basestr str) + (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 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 @@ -609,12 +616,17 @@ GOTO-END is non-nil, however, it instead 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 (set-text-properties 0 (length (car p)) '() (car p)) (setq poss (cons (car p) poss)))) - (setq p (cdr p))))) + (setq p (cdr p)))) ;; If table had duplicates, they can be here. (delete-dups poss) @@ -648,6 +660,7 @@ GOTO-END is non-nil, however, it instead (and p (setq poss p)))) ;; Now we have a list of possible completions + (cond ;; No valid completions found @@ -657,6 +670,9 @@ GOTO-END is non-nil, however, it instead (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 +873,11 @@ only symbols with function definitions a 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 + (skip-syntax-forward "_w") + (point)))) (beg (save-excursion (with-syntax-table lisp-mode-syntax-table (backward-sexp 1) [-- Attachment #3: Type: text/plain, Size: 142 bytes --] _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: For after-the-release: enhanced partial completion 2007-06-05 14:56 ` Sean O'Rourke @ 2007-06-05 15:32 ` Leo 2007-06-06 2:12 ` Sean O'Rourke 0 siblings, 1 reply; 19+ messages in thread From: Leo @ 2007-06-05 15:32 UTC (permalink / raw) To: Sean O'Rourke; +Cc: emacs-devel Dear Sean, ----- Sean O'Rourke (2007-06-05) wrote:----- > Leo <sdl.web@gmail.com> writes: >> Reproduce: >> 1. emacs -Q >> 2. M-x partial-completion-mode >> 3. M-: and then type in minibuffer `(emacs)' >> 4. Move the cursor to be on ")" and hit "M-TAB" > > Thanks. Please try this version instead. > > /s > > Index: complete.el > =================================================================== > RCS file: /cvsroot/emacs/emacs/lisp/complete.el,v > retrieving revision 1.72 [...] This patch indeed fixes all the aforementioned issues ;) One minor problem, see the following examples: M-x e-l-m TAB => M-x e-l-m ; patched M-x e-l-m TAB => M-x e-l-mode ; un-patched regards, -- Leo <sdl.web AT gmail.com> (GPG Key: 9283AA3F) ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: For after-the-release: enhanced partial completion 2007-06-05 15:32 ` Leo @ 2007-06-06 2:12 ` Sean O'Rourke 2007-06-07 1:46 ` Leo 0 siblings, 1 reply; 19+ messages in thread From: Sean O'Rourke @ 2007-06-06 2:12 UTC (permalink / raw) To: Leo; +Cc: emacs-devel [-- Attachment #1: Type: text/plain, Size: 422 bytes --] Leo <sdl.web@gmail.com> writes: > One minor problem, see the following examples: > > M-x e-l-m TAB => M-x e-l-m ; patched > M-x e-l-m TAB => M-x e-l-mode ; un-patched I can't reproduce this. I get the desired expansion to "e-l-mode" with point before the first dash. I haven't made any further changes since the last patch I sent, but I've attached it again in case something got screwed up. /s [-- Attachment #2: Type: text/plain, Size: 3629 bytes --] Index: complete.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/complete.el,v retrieving revision 1.72 diff -p -u -w -r1.72 complete.el --- complete.el 14 Apr 2007 20:23:31 -0000 1.72 +++ complete.el 6 Jun 2007 02:12:32 -0000 @@ -454,6 +454,7 @@ GOTO-END is non-nil, however, it instead env-on regex p offset + abbreviated (poss nil) helpposs (case-fold-search completion-ignore-case)) @@ -590,17 +591,23 @@ GOTO-END is non-nil, however, it instead pred nil)) ;; Find an initial list of possible completions - (if (not (setq p (string-match (concat PC-delim-regex + (unless (setq p (string-match (concat PC-delim-regex (if filename "\\|\\*" "")) str - (+ (length dirname) offset)))) + (+ (length dirname) offset))) ;; Minibuffer contains no hyphens -- simple case! - (setq poss (all-completions (if env-on - basestr str) + (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 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 @@ -609,12 +616,17 @@ GOTO-END is non-nil, however, it instead 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 (set-text-properties 0 (length (car p)) '() (car p)) (setq poss (cons (car p) poss)))) - (setq p (cdr p))))) + (setq p (cdr p)))) ;; If table had duplicates, they can be here. (delete-dups poss) @@ -648,6 +660,7 @@ GOTO-END is non-nil, however, it instead (and p (setq poss p)))) ;; Now we have a list of possible completions + (cond ;; No valid completions found @@ -657,6 +670,9 @@ GOTO-END is non-nil, however, it instead (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 +873,11 @@ only symbols with function definitions a 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 + (skip-syntax-forward "_w") + (point)))) (beg (save-excursion (with-syntax-table lisp-mode-syntax-table (backward-sexp 1) [-- Attachment #3: Type: text/plain, Size: 142 bytes --] _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: For after-the-release: enhanced partial completion 2007-06-06 2:12 ` Sean O'Rourke @ 2007-06-07 1:46 ` Leo 2007-06-07 4:08 ` Sean O'Rourke 0 siblings, 1 reply; 19+ messages in thread From: Leo @ 2007-06-07 1:46 UTC (permalink / raw) To: Sean O'Rourke; +Cc: emacs-devel ----- Sean O'Rourke (2007-06-06) wrote:----- >> One minor problem, see the following examples: >> >> M-x e-l-m TAB => M-x e-l-m ; patched >> M-x e-l-m TAB => M-x e-l-mode ; un-patched > > I can't reproduce this. I get the desired expansion to "e-l-mode" > with point before the first dash. I haven't made any further changes > since the last patch I sent, but I've attached it again in case > something got screwed up. > > /s > Index: complete.el [...] Weird. But then it might mean your patch has this glitch in emacs with unicode2, which you can obtain from: cvs -z3 -d:pserver:anonymous@cvs.savannah.gnu.org:/cvsroot/emacs co -r emacs-unicode-2 emacs regards, -- Leo <sdl.web AT gmail.com> (GPG Key: 9283AA3F) ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: For after-the-release: enhanced partial completion 2007-06-07 1:46 ` Leo @ 2007-06-07 4:08 ` Sean O'Rourke 2007-06-08 11:57 ` unicode-2 fail to bootstrap (was: For after-the-release: enhanced partial completion) Leo 0 siblings, 1 reply; 19+ messages in thread From: Sean O'Rourke @ 2007-06-07 4:08 UTC (permalink / raw) To: Leo; +Cc: emacs-devel Leo <sdl.web@gmail.com> writes: > Weird. But then it might mean your patch has this glitch in emacs with > unicode2, which you can obtain from: > > cvs -z3 -d:pserver:anonymous@cvs.savannah.gnu.org:/cvsroot/emacs co -r emacs-unicode-2 emacs I'll try to test this, but I can't get unicode-2 to bootstrap on Mac OS X Intel/Carbon. After initial checkout or "make distclean", I get to here: ../src/bootstrap-emacs -batch --no-site-file --multibyte \ -l autoload \ --eval "(setq generate-autoload-cookie \";;;###mh-autoload\")" \ --eval "(setq generated-autoload-file \"/Users/seano/src/emacs-unicode-2/lisp/mh-e/mh-loaddefs.el\")" \ --eval "(setq make-backup-files nil)" \ -f batch-update-autoloads /Users/seano/src/emacs-unicode-2/lisp/mh-e Wrong type argument: arrayp, nil make[2]: *** [/Users/seano/src/emacs-unicode-2/lisp/mh-e/mh-loaddefs.el] Error 255 I tried instead with a fresh checkout of the CVS head, and did not see the problem. Can we get an independent third party to check this out? /s ^ permalink raw reply [flat|nested] 19+ messages in thread
* unicode-2 fail to bootstrap (was: For after-the-release: enhanced partial completion) 2007-06-07 4:08 ` Sean O'Rourke @ 2007-06-08 11:57 ` Leo 2007-06-10 13:53 ` unicode-2 fail to bootstrap Sean O'Rourke 2007-06-10 23:42 ` unicode-2 fail to bootstrap (was: For after-the-release: enhanced partial completion) Kenichi Handa 0 siblings, 2 replies; 19+ messages in thread From: Leo @ 2007-06-08 11:57 UTC (permalink / raw) To: emacs-devel ----- Sean O'Rourke (2007-06-07) wrote:----- >> cvs -z3 -d:pserver:anonymous@cvs.savannah.gnu.org:/cvsroot/emacs co -r emacs-unicode-2 emacs > > I'll try to test this, but I can't get unicode-2 to bootstrap on Mac > OS X Intel/Carbon. After initial checkout or "make distclean", I get > to here: [...] Can someone help resolve this issue? Best, -- Leo <sdl.web AT gmail.com> (GPG Key: 9283AA3F) ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: unicode-2 fail to bootstrap 2007-06-08 11:57 ` unicode-2 fail to bootstrap (was: For after-the-release: enhanced partial completion) Leo @ 2007-06-10 13:53 ` Sean O'Rourke 2007-06-10 23:42 ` unicode-2 fail to bootstrap (was: For after-the-release: enhanced partial completion) Kenichi Handa 1 sibling, 0 replies; 19+ messages in thread From: Sean O'Rourke @ 2007-06-10 13:53 UTC (permalink / raw) To: Leo; +Cc: emacs-devel Leo <sdl.web@gmail.com> writes: > ----- Sean O'Rourke (2007-06-07) wrote:----- > >>> cvs -z3 -d:pserver:anonymous@cvs.savannah.gnu.org:/cvsroot/emacs co -r emacs-unicode-2 emacs >> >> I'll try to test this, but I can't get unicode-2 to bootstrap on Mac >> OS X Intel/Carbon. After initial checkout or "make distclean", I get >> to here: > [...] > > Can someone help resolve this issue? Here's more information: It fails in "make mh-loaddefs", when creating mh-e/mh-loaddefs.el, with the included backtraces. I didn't see anything obvious (to me) in the changes to set-keyboard-coding-system and set-locale-environment. Hope this helps. /s #0 Fsignal (error_symbol=41981121, data=21203077) at eval.c:1611 #1 0x000f3109 in xsignal (error_symbol=41981121, data=21203077) at eval.c:1722 #2 0x000f3369 in xsignal2 (error_symbol=41981121, arg1=41991489, arg2=41944073) at eval.c:1746 #3 0x000ddc15 in wrong_type_argument (predicate=41991489, value=41944073) at data.c:121 #4 0x000e084e in Faref (array=41944073, idx=64) at data.c:1971 #5 0x00124221 in Fbyte_code (bytestr=76704883, vector=10531972, maxdepth=5) at bytecode.c:979 #6 0x000f213e in Feval (form=21203029) at eval.c:2338 #7 0x000f3a48 in Fdefvar (args=21203021) at eval.c:844 #8 0x000f21a0 in Feval (form=21203013) at eval.c:2275 #9 0x0010c29e in readevalloop (readcharfun=42000281, stream=0xa000bd80, sourcename=76704387, evalfun=0xf1d4b <Feval>, printflag=0, unibyte=41944073, readfun=41944073, start=41944073, end=41944073) at lread.c:1739 #10 0x0010d2dc in Fload (file=42199259, noerror=41944073, nomessage=41944121, nosuffix=41944073, must_suffix=41944121) at lread.c:1206 #11 0x000f363b in do_autoload (fundef=17504005, funname=42082177) at eval.c:2166 #12 0x000f1eb2 in Feval (form=7878157) at eval.c:2382 #13 0x000f249a in Fprogn (args=7879565) at eval.c:447 #14 0x000f2707 in funcall_lambda (fun=7878208, nargs=1, arg_vector=0xbfffce30) at eval.c:3177 #15 0x000f27cb in apply_lambda (fun=7878213, args=19323333, eval_flag=1) at eval.c:3108 #16 0x000f1f35 in Feval (form=19323325) at eval.c:2388 #17 0x000f21a0 in Feval (form=19323309) at eval.c:2275 #18 0x000f247c in Fprogn (args=19323349) at eval.c:447 #19 0x000f4974 in Flet (args=19323301) at eval.c:1064 #20 0x000f21a0 in Feval (form=19323189) at eval.c:2275 #21 0x000f247c in Fprogn (args=21314245) at eval.c:447 #22 0x000f21a0 in Feval (form=21314269) at eval.c:2275 #23 0x000f20c3 in Feval (form=19323173) at eval.c:2386 #24 0x000f247c in Fprogn (args=21134149) at eval.c:447 #25 0x000f21a0 in Feval (form=21134141) at eval.c:2275 #26 0x000f21a0 in Feval (form=21134117) at eval.c:2275 #27 0x000f20c3 in Feval (form=19323077) at eval.c:2386 #28 0x000f247c in Fprogn (args=19324877) at eval.c:447 #29 0x000f4974 in Flet (args=19324653) at eval.c:1064 #30 0x000f21a0 in Feval (form=19324253) at eval.c:2275 #31 0x000f249a in Fprogn (args=21137149) at eval.c:447 #32 0x000f21a0 in Feval (form=21137141) at eval.c:2275 #33 0x000f21a0 in Feval (form=21137117) at eval.c:2275 #34 0x000f20c3 in Feval (form=19325861) at eval.c:2386 #35 0x000f249a in Fprogn (args=19325389) at eval.c:447 #36 0x000f4974 in Flet (args=19325125) at eval.c:1064 #37 0x000f21a0 in Feval (form=19325093) at eval.c:2275 #38 0x000f249a in Fprogn (args=19326789) at eval.c:447 #39 0x000f2707 in funcall_lambda (fun=6430136, nargs=1, arg_vector=0xbfffd930) at eval.c:3177 #40 0x000f27cb in apply_lambda (fun=6430141, args=20997765, eval_flag=1) at eval.c:3108 #41 0x000f1f35 in Feval (form=20997757) at eval.c:2388 #42 0x000f247c in Fprogn (args=21007029) at eval.c:447 #43 0x000f2707 in funcall_lambda (fun=21089952, nargs=0, arg_vector=0xbfffdaa0) at eval.c:3177 #44 0x000f27cb in apply_lambda (fun=21089957, args=41944073, eval_flag=1) at eval.c:3108 #45 0x000f1f35 in Feval (form=19876605) at eval.c:2388 #46 0x000f3300 in Funwind_protect (args=19876613) at eval.c:1324 #47 0x000f21a0 in Feval (form=19876597) at eval.c:2275 #48 0x000f247c in Fprogn (args=19896653) at eval.c:447 #49 0x000f4974 in Flet (args=19876589) at eval.c:1064 #50 0x000f21a0 in Feval (form=19876557) at eval.c:2275 #51 0x000f249a in Fprogn (args=19904029) at eval.c:447 #52 0x000f21a0 in Feval (form=19903965) at eval.c:2275 #53 0x000f247c in Fprogn (args=19896669) at eval.c:447 #54 0x000f2707 in funcall_lambda (fun=19896672, nargs=0, arg_vector=0xbfffdec0) at eval.c:3177 #55 0x000f27cb in apply_lambda (fun=19896677, args=41944073, eval_flag=1) at eval.c:3108 #56 0x000f1f35 in Feval (form=19811645) at eval.c:2388 #57 0x00083f39 in top_level_2 () at keyboard.c:1338 #58 0x000f0e92 in internal_condition_case (bfun=0x83f1d <top_level_2>, handlers=41981073, hfun=0x8a19d <cmd_error>) at eval.c:1481 #59 0x00083f81 in top_level_1 () at keyboard.c:1346 #60 0x000f0d83 in internal_catch (tag=41977353, func=0x83f3f <top_level_1>, arg=41944073) at eval.c:1222 #61 0x00083cd4 in command_loop () at keyboard.c:1303 #62 0x00083d9f in recursive_edit_1 () at keyboard.c:1006 #63 0x00083e8e in Frecursive_edit () at keyboard.c:1067 #64 0x0008304a in main (argc=5, argv=0xbfffe30c) at emacs.c:1786 Lisp Backtrace: "byte-code" (0x4926c73) "defvar" (0x143884d) "encoded-kbd-mode" (0x783635) "set-keyboard-coding-system" (0x2fdfe21) "if" (0x126d9b5) "let" (0x126d9a5) "if" (0x1453ad5) "unless" (0x126d92d) "progn" (0x1427b45) "if" (0x1427b2d) "when" (0x126d8cd) "let" (0x126deed) "progn" (0x14286fd) "if" (0x14286e5) "when" (0x126e3ad) "let" (0x126e0c5) "set-locale-environment" (0x2800409) "command-line" (0x2800409) "unwind-protect" (0x12f4b05) "let" (0x12f4aed) "if" (0x12fb5e5) "normal-top-level" (0x2800409) ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: unicode-2 fail to bootstrap (was: For after-the-release: enhanced partial completion) 2007-06-08 11:57 ` unicode-2 fail to bootstrap (was: For after-the-release: enhanced partial completion) Leo 2007-06-10 13:53 ` unicode-2 fail to bootstrap Sean O'Rourke @ 2007-06-10 23:42 ` Kenichi Handa 1 sibling, 0 replies; 19+ messages in thread From: Kenichi Handa @ 2007-06-10 23:42 UTC (permalink / raw) To: Leo; +Cc: emacs-devel In article <m2abva64l5.fsf_-_@sl392.st-edmunds.cam.ac.uk>, Leo <sdl.web@gmail.com> writes: > ----- Sean O'Rourke (2007-06-07) wrote:----- >>> cvs -z3 -d:pserver:anonymous@cvs.savannah.gnu.org:/cvsroot/emacs co -r emacs-unicode-2 emacs > > > > I'll try to test this, but I can't get unicode-2 to bootstrap on Mac > > OS X Intel/Carbon. After initial checkout or "make distclean", I get > > to here: > [...] > Can someone help resolve this issue? I did "cvs update", "make distclean", "configure", and "make bootstrap" on Debian, but it worked without any problem. So, perhaps it is a Mac-specific problem. --- Kenichi Handa handa@m17n.org ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: For after-the-release: enhanced partial completion 2007-06-04 16:19 ` Sean O'Rourke 2007-06-04 17:02 ` Leo @ 2007-06-04 19:27 ` Eli Zaretskii 1 sibling, 0 replies; 19+ messages in thread From: Eli Zaretskii @ 2007-06-04 19:27 UTC (permalink / raw) To: Sean O'Rourke; +Cc: sdl.web, emacs-devel > From: "Sean O'Rourke" <sorourke@cs.ucsd.edu> > Date: Mon, 04 Jun 2007 09:19:05 -0700 > Cc: emacs-devel@gnu.org > > Leo <sdl.web@gmail.com> writes: > > I have applied this patch. > > Wow, I'm impressed someone revisited this almost 4 months later! If this was supposed to be sarcasm, then please don't. This is a volunteer effort; we work on Emacs on our own free time. If you really would like to speed up things, offering help (in any number of ways) will have much more significant positive effect than witty email messages. TIA ^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2007-06-10 23:42 UTC | newest] Thread overview: 19+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2007-02-17 5:39 For after-the-release: enhanced partial completion Sean O'Rourke 2007-06-04 15:26 ` Leo 2007-06-04 16:09 ` Leo 2007-06-04 16:19 ` Sean O'Rourke 2007-06-04 17:02 ` Leo 2007-06-04 21:33 ` Sean O'Rourke [not found] ` <m2wsyjbd7a.fsf@sl392.st-edmunds.cam.ac.uk> 2007-06-04 22:10 ` Sean O'Rourke 2007-06-04 22:20 ` Sean O'Rourke 2007-06-05 6:40 ` Leo 2007-06-05 10:39 ` Leo 2007-06-05 14:56 ` Sean O'Rourke 2007-06-05 15:32 ` Leo 2007-06-06 2:12 ` Sean O'Rourke 2007-06-07 1:46 ` Leo 2007-06-07 4:08 ` Sean O'Rourke 2007-06-08 11:57 ` unicode-2 fail to bootstrap (was: For after-the-release: enhanced partial completion) Leo 2007-06-10 13:53 ` unicode-2 fail to bootstrap Sean O'Rourke 2007-06-10 23:42 ` unicode-2 fail to bootstrap (was: For after-the-release: enhanced partial completion) Kenichi Handa 2007-06-04 19:27 ` For after-the-release: enhanced partial completion Eli Zaretskii
Code repositories for project(s) associated with this external index https://git.savannah.gnu.org/cgit/emacs.git https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.