From: Leo <sdl.web@gmail.com>
To: emacs-devel@gnu.org
Subject: Re: PCM completion word boundaries
Date: Mon, 15 Aug 2011 17:56:40 +0800 [thread overview]
Message-ID: <m1hb5j2e1z.fsf@gmail.com> (raw)
In-Reply-To: jwv8vqx4a8g.fsf-monnier+emacs@gnu.org
On 2011-08-13 23:18 +0800, Stefan Monnier wrote:
>> The reason I am including > is that in Scheme there are tons of
>> functions with -> in it. > is a bit slower to type and would be great if
>> I can avoid it using completion.
>
> That would make sense, yes, but it would require more changes. You may
> want to start by looking at completion-pcm--string->pattern.
So it seems completion-pcm--string->pattern needs to handle three cases:
1. <word> any <delim>
2. <delim> any <delim>
3. <delim> any-delim <word>
Case 3 is missing i.e. it should insert delim chars between delim char
and the following word.
How about something along these lines (diff against emacs-23)?
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index 297cecb5..0c08eb33 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -1799,7 +1799,7 @@ (defun completion-pcm--pattern-trivial-p (pattern)
(defun completion-pcm--string->pattern (string &optional point)
"Split STRING into a pattern.
A pattern is a list where each element is either a string
-or a symbol chosen among `any', `star', `point'."
+or a symbol chosen among `any', `any-delim', `star', `point'."
(if (and point (< point (length string)))
(let ((prefix (substring string 0 point))
(suffix (substring string point)))
@@ -1824,18 +1824,28 @@ (defun completion-pcm--string->pattern (string &optional point)
;; This is determined by the presence of a submatch-1 which delimits
;; the prefix.
(if (match-end 1) (setq p (match-end 1)))
+ (when (and (/= p p0) (not (zerop p0)))
+ (push 'any-delim pattern))
(push (substring string p0 p) pattern)
+ (when (/= p p0)
+ (push 'any pattern))
(if (eq (aref string p) ?*)
(progn
(push 'star pattern)
(setq p0 (1+ p)))
- (push 'any pattern)
+ (when (= p p0)
+ (push 'any pattern))
+ (push (string (aref string p)) pattern)
(setq p0 p))
+ (incf p0)
(incf p))
+ (when (/= p0 (length string))
+ (push 'any-delim pattern))
+ (push (substring string p0) pattern)
;; An empty string might be erroneously added at the beginning.
;; It should be avoided properly, but it's so easy to remove it here.
- (delete "" (nreverse (cons (substring string p0) pattern))))))
+ (delete "" (nreverse pattern)))))
(defun completion-pcm--pattern->regex (pattern &optional group)
(let ((re
@@ -1846,6 +1856,10 @@ (defun completion-pcm--pattern->regex (pattern &optional group)
((star any point)
(if (if (consp group) (memq x group) group)
"\\(.*?\\)" ".*?"))
+ (any-delim
+ (concat (and group "\\(")
+ completion-pcm--delim-wild-regex "*"
+ (and group "\\)")))
(t (regexp-quote x))))
pattern
""))))
prev parent reply other threads:[~2011-08-15 9:56 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-06 10:40 PCM completion word boundaries Leo
2011-08-13 15:18 ` Stefan Monnier
2011-08-15 9:56 ` Leo [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m1hb5j2e1z.fsf@gmail.com \
--to=sdl.web@gmail.com \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.