Subject: bug#11562: 24.0.97; Error "Not in an editable field" when `M-TAB' in editable Customize field

From: Mauro Aranda <[email-masked]>
Date: Sat, 5 Oct 2019 10:48:34 -0300

tags 11562 + patch
quit

"Drew Adams" <[email-masked]> writes:

> emacs -Q
>
> (defcustom foo '(current-time-string)
>   "@@@@@@@@@@@@@@@"
>   :type 'sexp)
>
> M-x customize-option foo
>
> Type this into the editable field:
>
> (current-
>
> Then hit `M-TAB'.  You get this inappropriate error message:
>
> "Not in an editable field"
>
> If completion is not available, the message should say that.  It should
> not claim that the field is not editable when it is.

I attach a patch to fix this.

Best regards,
Mauro.
From d0f1970d061c3ee977d1d8ec0072afd016d4a0c2 Mon Sep 17 00:00:00 2001
From: Mauro Aranda <[email-masked]>
Date: Wed, 2 Oct 2019 11:11:01 -0300
Subject: [PATCH] Fix message when no completions available for editable field
 (Bug#11562)

* lisp/wid-edit.el (widget-completions-at-point): Detect here if point
is not in an editable field.
(widget-complete): And here say there are no completions available.
---
 lisp/wid-edit.el | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/lisp/wid-edit.el b/lisp/wid-edit.el
index 916d41a..a5999c0 100644
--- a/lisp/wid-edit.el
+++ b/lisp/wid-edit.el
@@ -1166,7 +1166,7 @@ widget-complete
                               (plist-get completion-extra-properties
                                          :predicate))))
      (t
-      (error "Not in an editable field")))))
+      (error "No completions available for this field")))))
 ;; We may want to use widget completion in buffers where the major mode
 ;; hasn't added widget-completions-at-point to completion-at-point-functions,
 ;; so it's not really obsolete (yet).
@@ -1174,8 +1174,9 @@ widget-complete
 
 (defun widget-completions-at-point ()
   (let ((field (widget-field-find (point))))
-    (when field
-      (widget-apply field :completions-function))))
+    (if field
+        (widget-apply field :completions-function)
+      (error "Not in an editable field"))))
 
 ;;; Setting up the buffer.
 
-- 
2.7.4