unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#30072: 27.0.50; completing-read-multiple chokes on list of default values
@ 2018-01-10 21:37 Basil L. Contovounesios
  2018-04-11 11:36 ` Basil L. Contovounesios
  0 siblings, 1 reply; 3+ messages in thread
From: Basil L. Contovounesios @ 2018-01-10 21:37 UTC (permalink / raw)
  To: 30072

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: 0001-Support-list-of-default-values-in-completing-read-mu.patch --]
[-- Type: text/x-diff, Size: 1119 bytes --]

From dac3aeb9a53efa53851b588d599f990cba592e49 Mon Sep 17 00:00:00 2001
From: "Basil L. Contovounesios" <contovob@tcd.ie>
Date: Wed, 10 Jan 2018 20:21:25 +0000
Subject: [PATCH] Support list of default values in completing-read-multiple

* lisp/emacs-lisp/crm.el (completing-read-multiple):
Consider head of DEF argument when specified as a list,
as per completing-read-default.
---
 lisp/emacs-lisp/crm.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lisp/emacs-lisp/crm.el b/lisp/emacs-lisp/crm.el
index 5aa856f467..1a67494d3c 100644
--- a/lisp/emacs-lisp/crm.el
+++ b/lisp/emacs-lisp/crm.el
@@ -263,7 +263,8 @@ completing-read-multiple
 	       (input (read-from-minibuffer
 		       prompt initial-input map
 		       nil hist def inherit-input-method)))
-	  (and def (string-equal input "") (setq input def))
+          (when (and def (string-equal input ""))
+            (setq input (if (consp def) (car def) def)))
           ;; Remove empty strings in the list of read strings.
 	  (split-string input crm-separator t)))
     (remove-hook 'choose-completion-string-functions
-- 
2.15.1


[-- Attachment #2: Type: text/plain, Size: 1087 bytes --]


Steps to reproduce:

1) emacs -Q
2) Evaluate the following form:

   (let ((l '("a" "b")))
     (completing-read-multiple "" l nil nil nil nil l))

3) C-m

I expect this to result in the string "a", as is the case when
completing-read-multiple is replaced with completing-read in step 2,
given the following excerpt from the docstring of c-r-m:

  The arguments are the same as those of `completing-read'.

Instead, the following error is signalled:

Debugger entered--Lisp error: (wrong-type-argument stringp ("a" "b"))
  string-match("[ \011]*,[ \011]*" ("a" "b") 0)
  split-string(("a" "b") "[ \011]*,[ \011]*" t)
  completing-read-multiple("" ("a" "b") nil nil nil nil ("a" "b"))

I attach a fix which follows the implementation of
completing-read-default.

Thanks,

-- 
Basil

In GNU Emacs 27.0.50 (build 14, x86_64-pc-linux-gnu, X toolkit, Xaw3d scroll bars)
 of 2018-01-10 built on thunk
Repository revision: b877e9aa0225ad186b544f127702e16c61b08444
Windowing system distributor 'The X.Org Foundation', version 11.0.11905000
System Description: Debian GNU/Linux testing (buster)

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

* bug#30072: 27.0.50; completing-read-multiple chokes on list of default values
  2018-01-10 21:37 bug#30072: 27.0.50; completing-read-multiple chokes on list of default values Basil L. Contovounesios
@ 2018-04-11 11:36 ` Basil L. Contovounesios
  2018-04-12 20:37   ` Juri Linkov
  0 siblings, 1 reply; 3+ messages in thread
From: Basil L. Contovounesios @ 2018-04-11 11:36 UTC (permalink / raw)
  To: 30072

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: 0001-Support-list-of-default-values-in-completing-read-mu.patch --]
[-- Type: text/x-diff, Size: 1131 bytes --]

From 7a33c02e2815e0a9625ffc48f3850894522169b6 Mon Sep 17 00:00:00 2001
From: "Basil L. Contovounesios" <contovob@tcd.ie>
Date: Wed, 10 Jan 2018 20:21:25 +0000
Subject: [PATCH] Support list of default values in completing-read-multiple

* lisp/emacs-lisp/crm.el (completing-read-multiple):
Consider head of DEF argument when specified as a list,
as per completing-read-default. (bug#30072)
---
 lisp/emacs-lisp/crm.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lisp/emacs-lisp/crm.el b/lisp/emacs-lisp/crm.el
index 5aa856f467..1a67494d3c 100644
--- a/lisp/emacs-lisp/crm.el
+++ b/lisp/emacs-lisp/crm.el
@@ -263,7 +263,8 @@ completing-read-multiple
 	       (input (read-from-minibuffer
 		       prompt initial-input map
 		       nil hist def inherit-input-method)))
-	  (and def (string-equal input "") (setq input def))
+          (when (and def (string-equal input ""))
+            (setq input (if (consp def) (car def) def)))
           ;; Remove empty strings in the list of read strings.
 	  (split-string input crm-separator t)))
     (remove-hook 'choose-completion-string-functions
-- 
2.16.3


[-- Attachment #2: Type: text/plain, Size: 193 bytes --]


"Basil L. Contovounesios" <contovob@tcd.ie> writes:

> I attach a fix which follows the implementation of
> completing-read-default.

Updated to include bug ticket number.

Thanks,

-- 
Basil

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

* bug#30072: 27.0.50; completing-read-multiple chokes on list of default values
  2018-04-11 11:36 ` Basil L. Contovounesios
@ 2018-04-12 20:37   ` Juri Linkov
  0 siblings, 0 replies; 3+ messages in thread
From: Juri Linkov @ 2018-04-12 20:37 UTC (permalink / raw)
  To: Basil L. Contovounesios; +Cc: 30072-done

>> I attach a fix which follows the implementation of
>> completing-read-default.
>
> Updated to include bug ticket number.

Thanks, pushed to master as 3d6fa0b.





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

end of thread, other threads:[~2018-04-12 20:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-10 21:37 bug#30072: 27.0.50; completing-read-multiple chokes on list of default values Basil L. Contovounesios
2018-04-11 11:36 ` Basil L. Contovounesios
2018-04-12 20:37   ` Juri Linkov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).