all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#17239: 24.3.50; competion error (cl-assertion-failed (string-prefix-p uprefix ustring))
@ 2014-04-11  9:02 Nicolas Richard
  2014-05-05  1:54 ` Stefan Monnier
  0 siblings, 1 reply; 5+ messages in thread
From: Nicolas Richard @ 2014-04-11  9:02 UTC (permalink / raw)
  To: 17239

Hello,

Recipe:
$ emacs -Q
C-x C-f
/ C-b TAB ;; hit tab between the last two slashes.
=> error.

Debugger entered--Lisp error: (cl-assertion-failed (string-prefix-p uprefix ustring))
  signal(cl-assertion-failed ((string-prefix-p uprefix ustring)))
  completion--file-name-table("~/sources/running-emacs//" 24 completion--unquote)
  complete-with-action(completion--unquote completion--file-name-table "~/sources/running-emacs//" 24)
  #[257 "\303\302\300\301$\207" ["~/sources/running-emacs//" 24 completion--unquote complete-with-action] 6 "\n\n(fn TABLE)"](completion--file-name-table)
  #[0 "\302\300\301\242\301\211\242A\240\210\242!\240\207" [#[257 "\303\302\300\301$\207" ["~/sources/running-emacs//" 24 completion--unquote complete-with-action] 6 "\n\n(fn TABLE)"] (nil) (nil)] 5 "\n\n(fn)"]()
  funcall(#[0 "\302\300\301\242\301\211\242A\240\210\242!\240\207" [#[257 "\303\302\300\301$\207" ["~/sources/running-emacs//" 24 completion--unquote complete-with-action] 6 "\n\n(fn TABLE)"] (nil) (nil)] 5 "\n\n(fn)"])
  completion--some(#[257 "\303\302\300\301$\207" ["~/sources/running-emacs//" 24 completion--unquote complete-with-action] 6 "\n\n(fn TABLE)"] (completion--embedded-envvar-table completion--file-name-table))
  read-file-name-internal("~/sources/running-emacs//" 24 completion--unquote)
  completion--nth-completion(1 "~/sources/running-emacs//" read-file-name-internal file-exists-p 24 (metadata (category . file) (completion--unquote-requote . t)))
  completion-try-completion("~/sources/running-emacs//" read-file-name-internal file-exists-p 24 (metadata (category . file) (completion--unquote-requote . t)))
  completion--do-completion(12 37)
  completion--in-region-1(12 37)
  #[1028 "\x01\x19\n\203!\304!\203\0\202\0\305!\305\306\"\x03F\307\310!\210\311\x04\"*\207" [minibuffer-completion-predicate minibuffer-completion-table completion-in-region-mode-predicate completion-in-region--data markerp copy-marker t completion-in-region-mode 1 completion--in-region-1] 8 "\n\n(fn START END COLLECTION PREDICATE)"](12 37 read-file-name-internal file-exists-p)
  apply(#[1028 "\x01\x19\n\203!\304!\203\0\202\0\305!\305\306\"\x03F\307\310!\210\311\x04\"*\207" [minibuffer-completion-predicate minibuffer-completion-table completion-in-region-mode-predicate completion-in-region--data markerp copy-marker t completion-in-region-mode 1 completion--in-region-1] 8 "\n\n(fn START END COLLECTION PREDICATE)"] (12 37 read-file-name-internal file-exists-p))
  #[771 ":\2030\x02@\301=\203\0\300\242\302\x05A\"\303#\207\304@\305\306\307\310\311\312\300!\313\"\314\315%\x06A\x06##\207\304\316\"\207" [(#0) t append nil apply apply-partially make-byte-code 642 "\300\242\x03#\207" vconcat vector [] 7 "\n\n(fn FUNS GLOBAL &rest ARGS)" #[1028 "\x01\x19\n\203!\304!\203\0\202\0\305!\305\306\"\x03F\307\310!\210\311\x04\"*\207" [minibuffer-completion-predicate minibuffer-completion-table completion-in-region-mode-predicate completion-in-region--data markerp copy-marker t completion-in-region-mode 1 completion--in-region-1] 8 "\n\n(fn START END COLLECTION PREDICATE)"]] 12 "\n\n(fn FUNS GLOBAL ARGS)"](nil nil (12 37 read-file-name-internal file-exists-p))
  completion--in-region(12 37 read-file-name-internal file-exists-p)
  completion-in-region(12 37 read-file-name-internal file-exists-p)
  minibuffer-complete()
  call-interactively(minibuffer-complete nil nil)
  command-execute(minibuffer-complete)
  read-from-minibuffer("Find file: " "~/sources/running-emacs/" (keymap (keymap (32)) keymap (10 . minibuffer-complete-and-exit) (13 . minibuffer-complete-and-exit) keymap (menu-bar keymap (minibuf "Minibuf" keymap (tab menu-item "Complete" minibuffer-complete :help "Complete as far as possible") (space menu-item "Complete Word" minibuffer-complete-word :help "Complete at most one word") (63 menu-item "List Completions" minibuffer-completion-help :help "Display all possible completions") "Minibuf")) (27 keymap (118 . switch-to-completions)) (prior . switch-to-completions) (63 . minibuffer-completion-help) (32 . minibuffer-complete-word) (9 . minibuffer-complete) keymap (menu-bar keymap (minibuf "Minibuf" keymap (previous menu-item "Previous History Item" previous-history-element :help "Put previous minibuffer history element in the minibuffer") (next menu-item "Next History Item" next-history-element :help "Put next minibuffer history element in the minibuffer") (isearch-backward menu-item "Isearch History Backward" isearch-backward :help "Incrementally search minibuffer history backward") (isearch-forward menu-item "Isearch History Forward" isearch-forward :help "Incrementally search minibuffer history forward") (return menu-item "Enter" exit-minibuffer :key-sequence "" :help "Terminate input and exit minibuffer") (quit menu-item "Quit" abort-recursive-edit :help "Abort input and exit minibuffer") "Minibuf")) (10 . exit-minibuffer) (13 . exit-minibuffer) (7 . abort-recursive-edit) (C-tab . file-cache-minibuffer-complete) (9 . self-insert-command) (XF86Back . previous-history-element) (up . previous-history-element) (prior . previous-history-element) (XF86Forward . next-history-element) (down . next-history-element) (next . next-history-element) (27 keymap (114 . previous-matching-history-element) (115 . next-matching-history-element) (112 . previous-history-element) (110 . next-history-element))) nil file-name-history "~/sources/running-emacs/" nil)
  completing-read-default("Find file: " read-file-name-internal file-exists-p confirm-after-completion "~/sources/running-emacs/" file-name-history "~/sources/running-emacs/" nil)
  completing-read("Find file: " read-file-name-internal file-exists-p confirm-after-completion "~/sources/running-emacs/" file-name-history "~/sources/running-emacs/")
  read-file-name-default("Find file: " nil "~/sources/running-emacs/" confirm-after-completion nil nil)
  read-file-name("Find file: " nil "~/sources/running-emacs/" confirm-after-completion)
  find-file-read-args("Find file: " confirm-after-completion)
  byte-code("\300\301\302 \"\207" [find-file-read-args "Find file: " confirm-nonexistent-file-or-buffer] 3)
  call-interactively(find-file nil nil)
  command-execute(find-file)


In GNU Emacs 24.3.50.10 (i686-pc-linux-gnu, X toolkit, Xaw3d scroll bars)
 of 2014-04-07 on geodiff-mac3

-- 
Nico.





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#17239: 24.3.50; competion error (cl-assertion-failed (string-prefix-p uprefix ustring))
  2014-04-11  9:02 bug#17239: 24.3.50; competion error (cl-assertion-failed (string-prefix-p uprefix ustring)) Nicolas Richard
@ 2014-05-05  1:54 ` Stefan Monnier
  2014-05-05 10:53   ` Nicolas Richard
  0 siblings, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2014-05-05  1:54 UTC (permalink / raw)
  To: Nicolas Richard; +Cc: 17239

> C-x C-f
> / C-b TAB ;; hit tab between the last two slashes.
> => error.

> Debugger entered--Lisp error: (cl-assertion-failed (string-prefix-p uprefix ustring))

Thanks.  I installed the patch below which fixes the most glaring
problem (the assertion failure).  The resulting behavior is not great,
but it's not really clear what we should do anyway.


        Stefan


=== modified file 'lisp/ChangeLog'
--- lisp/ChangeLog	2014-05-03 08:47:50 +0000
+++ lisp/ChangeLog	2014-05-05 01:44:49 +0000
@@ -1,3 +1,8 @@
+2014-05-05  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* minibuffer.el (completion-table-with-quoting) <completion--unquote>:
+	Make sure the new point we return is within the new string (bug#17239).
+
 2014-05-03  Eli Zaretskii  <eliz@gnu.org>
 
 	* mail/rmailsum.el (rmail-new-summary-1): Fix a typo in a comment.

=== modified file 'lisp/minibuffer.el'
--- lisp/minibuffer.el	2014-05-01 23:55:25 +0000
+++ lisp/minibuffer.el	2014-05-05 01:24:34 +0000
@@ -519,11 +519,35 @@
         completions))
 
      ((eq action 'completion--unquote)
-      (let ((ustring (funcall unquote string))
-            (uprefix (funcall unquote (substring string 0 pred))))
-        ;; We presume (more or less) that `concat' and `unquote' commute.
-        (cl-assert (string-prefix-p uprefix ustring))
-        (list ustring table (length uprefix)
+      ;; PRED is really a POINT in STRING.
+      ;; We should return a new set (STRING TABLE POINT REQUOTE)
+      ;; where STRING is a new (unquoted) STRING to match against the new TABLE
+      ;; using a new POINT inside it, and REQUOTE is a requoting function which
+      ;; should reverse the unquoting, (i.e. it receives the completion result
+      ;; of using the new TABLE and should turn it into the corresponding
+      ;; quoted result).
+      (let* ((qpos pred)
+	     (ustring (funcall unquote string))
+	     (uprefix (funcall unquote (substring string 0 qpos)))
+	     ;; FIXME: we really should pass `qpos' to `unuote' and have that
+	     ;; function give us the corresponding `uqpos'.  But for now we
+	     ;; presume (more or less) that `concat' and `unquote' commute.
+	     (uqpos (if (string-prefix-p uprefix ustring)
+			;; Yay!!  They do seem to commute!
+			(length uprefix)
+		      ;; They don't commute this time!  :-(
+		      ;; Maybe qpos is in some text that disappears in the
+		      ;; ustring (bug#17239).  Let's try a second chance guess.
+		      (let ((usuffix (funcall unquote (substring string qpos))))
+			(if (string-suffix-p usuffix ustring)
+			    ;; Yay!!  They still "commute" in a sense!
+			    (- (length ustring) (length usuffix))
+			  ;; Still no luck!  Let's just choose *some* position
+			  ;; within ustring.
+			  (/ (+ (min (length uprefix) (length ustring))
+				(max (- (length ustring) (length usuffix)) 0))
+			     2))))))
+        (list ustring table uqpos
               (lambda (unquoted-result op)
                 (pcase op
                   (1 ;;try
@@ -853,6 +877,7 @@
              (setq string (pop new))
              (setq table (pop new))
              (setq point (pop new))
+	     (cl-assert (<= point (length string)))
              (pop new))))
         (result
          (completion--some (lambda (style)






^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#17239: 24.3.50; competion error (cl-assertion-failed (string-prefix-p uprefix ustring))
  2014-05-05  1:54 ` Stefan Monnier
@ 2014-05-05 10:53   ` Nicolas Richard
  2014-05-05 12:52     ` Stefan Monnier
  0 siblings, 1 reply; 5+ messages in thread
From: Nicolas Richard @ 2014-05-05 10:53 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 17239

Le 05/05/2014 03:54, Stefan Monnier a écrit :
>> C-x C-f
>> / C-b TAB ;; hit tab between the last two slashes.
>> => error.
> 
>> Debugger entered--Lisp error: (cl-assertion-failed (string-prefix-p uprefix ustring))
> 
> Thanks.  I installed the patch below which fixes the most glaring
> problem (the assertion failure).

Thanks, the assertion failure is indeed gone.

> The resulting behavior is not great, but it's not really clear what we
> should do anyway.

As a point of comparison, when I do
C-x C-f ~ / C-b TAB
the behaviour of emacs depends on the current content of the minibuffer
(which is default-directory by default I guess).

I spotted these behaviours ("=>" means "hit C-b TAB and the minibuffer
becomes") :

~/~/     => ~/~/ [Complete, but not unique]
~/foo/~/ => ~/
/foo/~/  => /foo/~/ [Complete, but not unique]

(not hitting "C-b" doesn't change these results).

-- 
Nico.





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#17239: 24.3.50; competion error (cl-assertion-failed (string-prefix-p uprefix ustring))
  2014-05-05 10:53   ` Nicolas Richard
@ 2014-05-05 12:52     ` Stefan Monnier
  2020-08-25 10:46       ` Lars Ingebrigtsen
  0 siblings, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2014-05-05 12:52 UTC (permalink / raw)
  To: Nicolas Richard; +Cc: 17239

>> The resulting behavior is not great, but it's not really clear what we
>> should do anyway.
> As a point of comparison, when I do
> C-x C-f ~ / C-b TAB
> the behaviour of emacs depends on the current content of the minibuffer
> (which is default-directory by default I guess).

It shouldn't: it should complete the username (since the general form
of the ~ thingy is "~<user>/<filename>").

> I spotted these behaviours ("=>" means "hit C-b TAB and the minibuffer
> becomes") :
> ~/~/     => ~/~/ [Complete, but not unique]
> ~/foo/~/ => ~/
> /foo/~/  => /foo/~/ [Complete, but not unique]

Indeed, I'm not sure why ~/foo/~/ behaves differently.  It's probably
a side-effect of completion--sifn-requote.  You can take a look at that
function's leading comment to get an idea for why it might not always
behave perfectly ;-)


        Stefan





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#17239: 24.3.50; competion error (cl-assertion-failed (string-prefix-p uprefix ustring))
  2014-05-05 12:52     ` Stefan Monnier
@ 2020-08-25 10:46       ` Lars Ingebrigtsen
  0 siblings, 0 replies; 5+ messages in thread
From: Lars Ingebrigtsen @ 2020-08-25 10:46 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Nicolas Richard, 17239

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> I spotted these behaviours ("=>" means "hit C-b TAB and the minibuffer
>> becomes") :
>> ~/~/     => ~/~/ [Complete, but not unique]
>> ~/foo/~/ => ~/
>> /foo/~/  => /foo/~/ [Complete, but not unique]
>
> Indeed, I'm not sure why ~/foo/~/ behaves differently.  It's probably
> a side-effect of completion--sifn-requote.  You can take a look at that
> function's leading comment to get an idea for why it might not always
> behave perfectly ;-)

This is perhaps a bit inconsistent, but it's unclear what a consistent
behaviour here would be, anyway -- it's all a bit DWIM, and I think
that's OK.  So I'm closing this bug report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-08-25 10:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-11  9:02 bug#17239: 24.3.50; competion error (cl-assertion-failed (string-prefix-p uprefix ustring)) Nicolas Richard
2014-05-05  1:54 ` Stefan Monnier
2014-05-05 10:53   ` Nicolas Richard
2014-05-05 12:52     ` Stefan Monnier
2020-08-25 10:46       ` Lars Ingebrigtsen

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.