all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Thierry Volpiatto <thievol@posteo.net>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 68602@debbugs.gnu.org
Subject: bug#68602: 29.2; describe-language-environment fails to specify default in its CR
Date: Sat, 20 Jan 2024 19:33:36 +0000	[thread overview]
Message-ID: <87a5ozztnz.fsf@posteo.net> (raw)
In-Reply-To: <83ttn7sxef.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 20 Jan 2024 19:54:48 +0200")

[-- Attachment #1: Type: text/plain, Size: 1708 bytes --]

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Thierry Volpiatto <thievol@posteo.net>
>> Cc: 68602@debbugs.gnu.org
>> Date: Sat, 20 Jan 2024 16:37:04 +0000
>> 
>> >> From: Thierry Volpiatto <thievol@posteo.net>
>> >> Date: Sat, 20 Jan 2024 05:56:11 +0000
>> >> 
>> >> 
>> >> Its read-language-name specify default in prompt but not as DEFAULT arg.
>> >
>> > Thanks.  But why is that a problem?
>> 
>> Because Helm needs this info to handle DEFAULT, it can't be aware of the
>> code running after the completing-read (read-language-name in this
>> case).
>
> Can you elaborate on this?  I don't think I follow (I don't use Helm).

When you press RET on an empty completing-read prompt and the function
provides a default, the completing-read returns this default.
When you run this function with helm-mode enabled, helm provide its
interface for completion on this completing-read and puts default on top
of its list to allow user pressing RET with an empty prompt to have this
default.  If the default arg is handled AFTER the completing-read helm
cannot guess what is it.

Example (selection is "|"):

(defun foo ()
  (let ((val (completing-read
              "test: " '("a" "b" "c" "d") nil nil nil nil "d")))
    val))

d|
a
b
c

(defun foo-1 ()
  (let ((val (completing-read "test: " '("a" "b" "c" "d"))))
    (if (string= val "") "d" val)))

a|
b
c
d

In `foo` and `foo-1` with helm-mode enabled and press RET with nothing
in prompt, helm will return "d" with `foo` but "a" with `foo-1`.

In `foo` helm is aware that "d" is the default, in `foo-1` it has no
ideas of what the default is even if `foo-1` code is as correct as `foo`. 

-- 
Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 686 bytes --]

  reply	other threads:[~2024-01-20 19:33 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-20  5:56 bug#68602: 29.2; describe-language-environment fails to specify default in its CR Thierry Volpiatto
2024-01-20  7:47 ` Eli Zaretskii
2024-01-20 16:37   ` Thierry Volpiatto
2024-01-20 17:54     ` Eli Zaretskii
2024-01-20 19:33       ` Thierry Volpiatto [this message]
2024-01-21 18:26         ` Thierry Volpiatto
2024-01-27  9:47           ` Eli Zaretskii
2024-01-27 12:31             ` Thierry Volpiatto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87a5ozztnz.fsf@posteo.net \
    --to=thievol@posteo.net \
    --cc=68602@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.