From: Jambunathan K <kjambunathan@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 12638@debbugs.gnu.org
Subject: bug#12638: 24.2.50; FR: Some suggestions for icomplete-mode
Date: Thu, 13 Dec 2012 19:21:06 +0530 [thread overview]
Message-ID: <87bodykqlx.fsf@gmail.com> (raw)
In-Reply-To: <87391ieck9.fsf@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1147 bytes --]
Jambunathan K <kjambunathan@gmail.com> writes:
> Stefan Monnier <monnier@iro.umontreal.ca> writes:
>
>>> 2. M-x debbugs-gnu
>>> There is no way I can C-s C-j to the second or third candidates.
>>> I normally use debbbugs-gnu-search which is the second candidate.
>>
>> Better ask this elsewhere, I'm not up to speed on debbugs-gnu.
>
> I am attaching screenshot of minibuffer.
>
> 1. M-x debbugs-gnu
> 2. Immediately cycle with C-s
>
> Cycling may happen internally but the UI presents the "most-is-exact"
> always at the head. This is a definite bug.
The case to be handled is "Complete, but not unique".
The attached patch fixes the issue by sneaking a Ctrl-M in to the try
try completion field.
Attachments:
M-x debbugs-gnu RET with icomplete-mode on.
icomplete-1.png:
Note the ^M and the empty first entry
icomplete-2.png:
After a C-s. Note the ^M indicator and empty entry pushed to
the last.
icomplete-3.png:
This is the second invocation of M-x debbugs-gnu RET. Note that
the entry from the recent history is at the head. Also note ^M
and the empty entries.
[-- Attachment #2: icomplete-bug12638.diff --]
[-- Type: text/x-diff, Size: 5337 bytes --]
=== modified file 'lisp/ChangeLog'
--- lisp/ChangeLog 2012-12-13 05:29:15 +0000
+++ lisp/ChangeLog 2012-12-13 13:32:58 +0000
@@ -1,3 +1,10 @@
+2012-12-13 Jambunathan K <kjambunathan@gmail.com>
+
+ * icomplete.el (icomplete-hide-common-prefix): New user variable.
+ (icomplete-first-match): New user face.
+ (icomplete-completions): Honor above settings. Correctly handle
+ the case when NAME is complete but not unique (Bug#12638).
+
2012-12-13 Alan Mackenzie <acm@muc.de>
Make CC Mode not hang when _some_ lines end in CRLF. Bug #11841.
=== modified file 'lisp/icomplete.el'
--- lisp/icomplete.el 2012-11-30 17:09:55 +0000
+++ lisp/icomplete.el 2012-12-13 13:16:31 +0000
@@ -76,6 +76,18 @@
:type 'string
:version "24.4")
+(defcustom icomplete-hide-common-prefix t
+ "When non-nil, hide common prefix from completion candidates.
+When nil, show candidates in full."
+ :type 'boolean
+ :version "24.4"
+ :group 'icomplete)
+
+(defface icomplete-first-match '((t :weight bold))
+ "Face used by icomplete for highlighting first match."
+ :version "24.4"
+ :group 'icomplete)
+
;;;_* User Customization variables
(defcustom icomplete-prospects-height
;; 20 is an estimated common size for the prompt + minibuffer content, to
@@ -332,14 +344,12 @@ are exhibited within the square braces.)
(determ (unless (or (eq t compare) (eq t most-try)
(= (setq compare (1- (abs compare)))
(length most)))
- (concat open-bracket
(cond
((= compare (length name))
;; Typical case: name is a prefix.
(substring most compare))
((< compare 5) most)
- (t (concat "..." (substring most compare))))
- close-bracket)))
+ (t (concat "..." (substring most compare))))))
;;"-prospects" - more than one candidate
(prospects-len (+ (length determ) 6 ;; take {,...} into account
(string-width (buffer-string))))
@@ -350,6 +360,8 @@ are exhibited within the square braces.)
;; one line, increase the allowable space accordingly.
(/ prospects-len (window-width)))
(window-width)))
+ (prefix (when icomplete-hide-common-prefix
+ (try-completion "" comps)))
(prefix-len
;; Find the common prefix among `comps'.
;; We can't use the optimization below because its assumptions
@@ -359,37 +371,58 @@ are exhibited within the square braces.)
;; ;; Common case.
;; (length most)
;; Else, use try-completion.
- (let ((comps-prefix (try-completion "" comps)))
- (and (stringp comps-prefix)
- (length comps-prefix)))) ;;)
-
+ (and (stringp prefix) (length prefix))) ;;)
prospects most-is-exact comp limit)
(if (eq most-try t) ;; (or (null (cdr comps))
(setq prospects nil)
+ (when (and (cdr comps) (member name comps))
+ ;; NAME is complete but not unique. This scenario, poses
+ ;; following UI issues:
+ ;;
+ ;; - When common prefix is hidden, NAME is stripped empty.
+ ;; This would make the entry inconspicuous.
+ ;; - Due to sorting of completions, NAME may not be the
+ ;; first of the prospects and could be hidden deep in the
+ ;; displayed string.
+ ;; - Because of truncation, NAME may not even be displayed
+ ;; to the user.
+ ;;
+ ;; To circumvent all the above problems, provide a visual
+ ;; cue to the user via try completion field.
+ (setq determ "\r"))
(while (and comps (not limit))
(setq comp
(if prefix-len (substring (car comps) prefix-len) (car comps))
comps (cdr comps))
- (cond ((string-equal comp "") (setq most-is-exact t))
- ((member comp prospects))
- (t (setq prospects-len
+ (setq prospects-len
(+ (string-width comp) 1 prospects-len))
(if (< prospects-len prospects-max)
(push comp prospects)
- (setq limit t))))))
+ (setq limit t))))
+ (setq prospects (nreverse prospects))
+ ;; Decorate the first of prospects.
+ (when prospects
+ (let ((first (copy-sequence (pop prospects))))
+ (put-text-property 0 (length first)
+ 'face 'icomplete-first-match first)
+ (push first prospects)))
;; Restore the base-size info, since completion-all-sorted-completions
;; is cached.
(if last (setcdr last base-size))
+ (when determ
+ (setq determ (concat open-bracket determ close-bracket)))
(if prospects
(concat determ
+ (if (not (cdr prospects))
+ ;; NAME is not complete but will complete to
+ ;; an EXACT match on next try.
+ ""
+ (concat
"{"
- (and most-is-exact
- (substring icomplete-separator
- (string-match "[^ ]" icomplete-separator)))
- (mapconcat 'identity (nreverse prospects)
- icomplete-separator)
+ (mapconcat 'identity prospects icomplete-separator)
(and limit (concat icomplete-separator "…"))
- "}")
+ "}"
+ )))
(concat determ " [Matched]"))))))
;;_* Local emacs vars.
[-- Attachment #3: icomplete-3.png --]
[-- Type: image/png, Size: 5177 bytes --]
[-- Attachment #4: icomplete-2.png --]
[-- Type: image/png, Size: 2134 bytes --]
[-- Attachment #5: icomplete-1.png --]
[-- Type: image/png, Size: 2081 bytes --]
next prev parent reply other threads:[~2012-12-13 13:51 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-13 17:33 bug#12638: 24.2.50; FR: Some suggestions for icomplete-mode Jambunathan K
2012-10-13 22:14 ` Stefan Monnier
2012-10-14 4:18 ` Drew Adams
2012-10-23 19:43 ` Stefan Monnier
2012-10-23 20:08 ` Jambunathan K
2012-10-23 20:17 ` Jambunathan K
2012-10-24 13:09 ` Stefan Monnier
2012-11-02 11:49 ` Jambunathan K
2012-11-02 12:12 ` Jambunathan K
2012-11-09 1:53 ` Stefan Monnier
2012-11-09 2:17 ` Stefan Monnier
2012-11-09 4:25 ` Jambunathan K
2012-11-09 14:12 ` Stefan Monnier
2012-11-29 21:34 ` Stefan Monnier
2012-11-30 6:18 ` Jambunathan K
2012-11-30 19:37 ` Stefan Monnier
2012-12-04 12:54 ` Jambunathan K
2012-12-04 15:02 ` Stefan Monnier
2012-12-04 15:30 ` Jambunathan K
2012-12-04 15:45 ` Stefan Monnier
2012-12-04 16:12 ` Jambunathan K
2012-12-04 17:14 ` Stefan Monnier
2012-12-04 17:32 ` Jambunathan K
2012-12-12 3:18 ` Stefan Monnier
2012-12-12 3:42 ` Drew Adams
2012-12-12 6:34 ` Kevin Rodgers
2012-12-12 16:15 ` Drew Adams
2012-12-04 15:51 ` Jambunathan K
2012-12-13 13:51 ` Jambunathan K [this message]
2012-12-17 16:28 ` Stefan Monnier
2012-12-17 19:22 ` Jambunathan K
2012-12-17 20:12 ` Stefan Monnier
2012-12-17 20:58 ` Jambunathan K
2012-12-18 1:26 ` Stefan Monnier
2012-12-18 3:09 ` Drew Adams
2012-12-18 14:40 ` Jambunathan K
2013-01-11 5:47 ` Jambunathan K
2013-01-11 14:17 ` Stefan Monnier
2013-02-13 13:56 ` Jambunathan K
2013-02-13 15:15 ` Stefan Monnier
2013-02-13 17:18 ` Jambunathan K
2013-11-15 4:42 ` Jambunathan K
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=87bodykqlx.fsf@gmail.com \
--to=kjambunathan@gmail.com \
--cc=12638@debbugs.gnu.org \
--cc=monnier@iro.umontreal.ca \
/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.