emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r108691: * lisp/minibuffer.el (comple


From: Stefan Monnier
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r108691: * lisp/minibuffer.el (completion--twq-try): Try to fail more gracefully when
Date: Fri, 22 Jun 2012 23:48:18 -0400
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 108691
fixes bug: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=11714
committer: Stefan Monnier <address@hidden>
branch nick: trunk
timestamp: Fri 2012-06-22 23:48:18 -0400
message:
  * lisp/minibuffer.el (completion--twq-try): Try to fail more gracefully when
  the requote function doesn't work properly.
modified:
  lisp/ChangeLog
  lisp/minibuffer.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2012-06-23 01:02:17 +0000
+++ b/lisp/ChangeLog    2012-06-23 03:48:18 +0000
@@ -1,3 +1,8 @@
+2012-06-23  Stefan Monnier  <address@hidden>
+
+       * minibuffer.el (completion--twq-try): Try to fail more gracefully when
+       the requote function doesn't work properly (bug#11714).
+
 2012-06-23  Glenn Morris  <address@hidden>
 
        * pcmpl-rpm.el (pcmpl-rpm-packages): Give status messages.

=== modified file 'lisp/minibuffer.el'
--- a/lisp/minibuffer.el        2012-06-18 20:39:52 +0000
+++ b/lisp/minibuffer.el        2012-06-23 03:48:18 +0000
@@ -488,7 +488,7 @@
 
 (defun completion--twq-try (string ustring completion point
                                    unquote requote)
-  ;; Basically two case: either the new result is
+  ;; Basically two cases: either the new result is
   ;; - commonprefix1 <point> morecommonprefix <qpos> suffix
   ;; - commonprefix <qpos> newprefix <point> suffix
   (pcase-let*
@@ -505,8 +505,13 @@
          ((> point (length prefix)) (+ qpos (length qstr1)))
          (t (car (funcall requote point string))))))
     ;; Make sure `requote' worked.
-    (assert (equal (funcall unquote qstring) completion))
-    (cons qstring qpoint)))
+    (if (equal (funcall unquote qstring) completion)
+       (cons qstring qpoint)
+      ;; If requote failed (e.g. because sifn-requote did not handle
+      ;; Tramp's "/foo:/bar//baz -> /foo:/baz" truncation), then at least
+      ;; try requote properly.
+      (let ((qstr (funcall qfun completion)))
+       (cons qstr (length qstr))))))
 
 (defun completion--string-equal-p (s1 s2)
   (eq t (compare-strings s1 nil nil s2 nil nil 'ignore-case)))
@@ -2130,6 +2135,12 @@
   ;; find the position corresponding to UPOS in QSTR, but
   ;; substitute-in-file-name can do anything, depending on file-name-handlers.
   ;; Kind of like in rfn-eshadow-update-overlay, only worse.
+  ;; FIXME: example of thing we do not handle: Tramp's makes
+  ;; (substitute-in-file-name "/foo:~/bar//baz") -> "/scpc:foo:/baz".
+  ;; FIXME: One way to try and handle "all" cases is to require
+  ;; substitute-in-file-name to preserve text-properties, so we could
+  ;; apply text-properties to the input string and then look for them in
+  ;; the output to understand what comes from where.
   (let ((qpos 0))
     ;; Handle substitute-in-file-name's truncation behavior.
     (let (tpos)
@@ -2824,14 +2835,14 @@
 
 (defun completion--sreverse (str)
   "Like `reverse' but for a string STR rather than a list."
-  (apply 'string (nreverse (mapcar 'identity str))))
+  (apply #'string (nreverse (mapcar 'identity str))))
 
 (defun completion--common-suffix (strs)
   "Return the common suffix of the strings STRS."
   (completion--sreverse
    (try-completion
     ""
-    (mapcar 'completion--sreverse strs))))
+    (mapcar #'completion--sreverse strs))))
 
 (defun completion-pcm--merge-completions (strs pattern)
   "Extract the commonality in STRS, with the help of PATTERN.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]