6 次代码提交 49e7967ea8 ... 5995b4605b

作者 SHA1 备注 提交日期
  Ryan C. Thompson 5995b4605b Add change log entry for #179 1 年之前
  Ryan C. Thompson 1609049c0a Remove display properties from return value of ido-completing-read+ 1 年之前
  Ryan C. Thompson 43039dedf5 Add a test for issue #179 1 年之前
  Ryan C. Thompson f6a6d2253b Run tests on Emacs versions up to 29.2 1 年之前
  Ryan C. Thompson 1d12193f56 Update Github workflow to checkout V4 1 年之前
  Ryan C. Thompson 271d775b97 Fix a spurious test failure 1 年之前
共有 4 个文件被更改,包括 38 次插入14 次删除
  1. 4 6
      .github/workflows/test.yml
  2. 6 0
      ChangeLog
  3. 13 4
      ido-completing-read+.el
  4. 15 4
      tests/test-ido-completing-read+.el

+ 4 - 6
.github/workflows/test.yml

@@ -16,15 +16,13 @@ jobs:
     strategy:
       fail-fast: false
       matrix:
+        # See https://github.com/purcell/nix-emacs-ci/blob/master/flake.nix
         emacs_version:
+          - 29.2
+          - 28.2
           - 27.2
-          # - 27.1
           - 26.3
-          # - 26.2
-          # - 26.1
           - 25.3
-          # - 25.2
-          # - 25.1
           - 24.5
           - 24.4
           - snapshot
@@ -40,7 +38,7 @@ jobs:
       run: curl -fsSL https://raw.github.com/doublep/eldev/master/webinstall/github-eldev | sh
 
     - name: Check out the source code
-      uses: actions/checkout@v2
+      uses: actions/checkout@v4
 
     - name: Install Elisp dependencies
       run: eldev prepare test

+ 6 - 0
ChangeLog

@@ -1,3 +1,9 @@
+2024-01-29  Ryan C. Thompson  <rct@thompsonclan.org>
+
+	* ido-completing-read+.el (ido-completing-read+): Fix an
+	incompatibility with `yank-pop' and other functions by stripping
+	display properties from the return value. Fixes #179.
+
 2021-03-30  Ryan C. Thompson  <rct@thompsonclan.org>
 
 	* ido-completing-read+.el (ido-cr+-disable-list): Rename from

+ 13 - 4
ido-completing-read+.el

@@ -776,10 +776,19 @@ See `completing-read' for the meaning of the arguments."
                     ;; Reset this for recursive calls to ido-cr+
                     (ido-cr+-assume-static-collection nil))
                 (unwind-protect
-                    (ido-completing-read
-                     prompt collection
-                     predicate require-match initial-input hist def
-                     inherit-input-method)
+                    (let ((return-value
+                           (ido-completing-read
+                            prompt collection
+                            predicate require-match initial-input hist def
+                            inherit-input-method)))
+                      ;; Functions like `read-from-kill-ring' add
+                      ;; display properties for things like ellipses,
+                      ;; which need to be removed. (Somehow
+                      ;; `completing-read-default' removes these
+                      ;; properties from its return value, though I
+                      ;; don't understand how.)
+                      (remove-text-properties 0 (length return-value) '(display) return-value)
+                      return-value)
                   (when ido-cr+-dynamic-update-timer
                     (cancel-timer ido-cr+-dynamic-update-timer)
                     (setq ido-cr+-dynamic-update-timer nil))))

+ 15 - 4
tests/test-ido-completing-read+.el

@@ -328,9 +328,10 @@ also accept a quoted list for the sake of convenience."
          :to-throw))
 
       (it "shouldn't allow C-j to select an ambiguous match"
-        ;; Make this a no-op to avoid end-of-buffer errors, which are
-        ;; irrelevant to this test.
-        (spy-on 'scroll-other-window)
+        ;; Make this a no-op to prevent spurious end-of-buffer errors
+        ;; when ido tries to create a help buffer in a noninteractive
+        ;; emacs.
+        (spy-on 'ido-completion-auto-help)
         (expect
          (with-simulated-input "b C-j C-j C-j"
            (ido-completing-read+
@@ -695,7 +696,17 @@ also accept a quoted list for the sake of convenience."
          (with-simulated-input "forward-char RET"
            (ido-completing-read+ "Prompt: " obarray #'commandp
                                  t nil nil "backward-char"))
-         :to-equal "forward-char"))))
+         :to-equal "forward-char"))
+
+      (it "should strip display properties from the return value"
+        (expect
+         (let ((string-with-display-prop "apple"))
+           (add-text-properties 4 5 '(display "...") string-with-display-prop)
+           (next-single-property-change
+            0 'display
+            (with-simulated-input "appl RET"
+              (ido-completing-read+ "Prompt: " (list string-with-display-prop)))))
+         :to-be nil))))
 
   (describe "ido-ubiquitous-mode"
     ;; Set up a test command that calls `completing-read'