Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-obvious "Join it, or load link with browser?" prompt #241

Closed
phil-s opened this issue Nov 22, 2023 · 12 comments · Fixed by #260
Closed

Non-obvious "Join it, or load link with browser?" prompt #241

phil-s opened this issue Nov 22, 2023 · 12 comments · Fixed by #260
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Milestone

Comments

@phil-s
Copy link

phil-s commented Nov 22, 2023

I selected a chat URL someone had posted, and ement.el prompted me with:

Room not joined on current session. Join it, or load link with browser?

To which my thought was: "Uh, Yes?"

I.e. It's a completing-read, but the prompt comes across like a paradoxical yes-or-yes-p query. Guessing what was happening, I typed TAB and got the completions buffer "2 possible completions: Join room, Load link with browser".

I suspect the code was written with an expectation that users are running some completion framework which automatically displays the completions, but that's not the default behaviour and I think this isn't the best way to handle such a query.

How about this:?

(let ((read-answer-short t))
  (read-answer
   "Room not joined on current session. (j)oin it, or (l)oad link with browser? "
   '(("join" ?j "Join room in ement.el")
     ("load" ?l "Load link with web browser"))))
@alphapapa
Copy link
Owner

Seems like a good idea. Thanks.

@alphapapa alphapapa self-assigned this Nov 22, 2023
@alphapapa alphapapa added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers labels Nov 22, 2023
@alphapapa alphapapa added this to the 0.14 milestone Nov 22, 2023
@phil-s
Copy link
Author

phil-s commented Dec 3, 2023

Before I go ahead with a PR... I wonder if there's a better phrasing/letter for the second option. (j)oin seems sensible, but "load" is a pretty generic word -- in context, "[web] browser" is really the key part of load link with browser.

OTOH (M-x browse-url notwithstanding) web browsers are "browsing" the web collectively, not "browsing" individual URLs, so (b)rowse doesn't work to my mind either. Firefox and Chromium both use the terminology "Open URL" (and even Emacs sometimes uses "open" in its menus, whereas "load" is something quite different in Emacs); so maybe (o)pen link in web browser works slightly better.

Or Open link in web (b)rowser; or Open link in (w)eb browser. My initial feeling was that it seems preferable to use the first letter of the first word as the active character, but I'm less convinced of that now.

Room not joined on current session. (j)oin it, or (l)oad link with browser?
Room not joined on current session. (j)oin it, or (o)pen link with browser?
Room not joined on current session. (j)oin it, or open link with (b)rowser?
Room not joined on current session. (j)oin it, or open link with (w)eb browser?
Room not joined on current session. (j)oin it, or (b)rowse url?

I admit there's a succinct and familiar ring to the last one, despite my earlier comments, but I don't have a single firm favourite, and there might be something else which is better than those.

What do you think?

@alphapapa
Copy link
Owner

"View with browser?" "Visit with browser?" I don't know if those are necessarily better than "open", "load", or "browse", but maybe worth considering.

@phil-s
Copy link
Author

phil-s commented Dec 6, 2023

Whatever the phrasing, it looks like read-multiple-choice provides a nicer implementation than read-answer (both were added in Emacs 26).

(read-multiple-choice
 "Room not joined on current session."
 '((?j "join" "Join room in ement.el")
   (?w "web browser" "Open URL in web browser")))

...and because I was experimenting, a fancier (but probably unnecessary) version help-wise:

(let* ((help-format "\
You are not currently joined to that room.  You can either join the room
in ement.el, or visit the link URL in your web browser.\n\n%s")
       (prompt-choices '((?j "join" "Join room in ement.el")
                         (?w "web browser" "Open URL in web browser")))
       (help-choices (mapconcat (lambda (c)
                                  (format "%c: %s\n" (car c) (caddr c)))
                                prompt-choices)))
  (read-multiple-choice "Room not joined on current session."
                        prompt-choices
                        (format help-format help-choices)))

@alphapapa
Copy link
Owner

Sure, I think that's fine. Maybe say "in Emacs" rather than "in ement.el"?

@phil-s
Copy link
Author

phil-s commented Dec 9, 2023

Sure thing. For clarity, did you want the more basic version or the one with the fancier help?

@alphapapa
Copy link
Owner

Sure thing. For clarity, did you want the more basic version or the one with the fancier help?

I'm comfortable with deferring to your judgment on that. Since I'm the original developer and you're also a user, your perspective may be more important than mine.

@alphapapa
Copy link
Owner

@phil-s If you're still interested, I'll be glad to merge a PR for this without delay. It doesn't seem like something that needs much testing first.

@alphapapa alphapapa modified the milestones: 0.14, 0.15 Jan 25, 2024
@phil-s
Copy link
Author

phil-s commented Jan 25, 2024

Let's leave it for 0.15. I can't do a PR immediately, and it's a minor thing.

@phil-s
Copy link
Author

phil-s commented Jan 26, 2024

I quite like the verbose help, and I also think the default multi-column help formatting seems awkward in the way in which it wraps lines, so here's a wrapper which resolves those things.

(defun ement-read-multiple-choice (prompt choices &optional help)
  "Wrapper for `read-multiple-choice'."
  (let ((help-format (if help
                         (concat (replace-regexp-in-string "%" "%%" help)
                                 "\n\n%s")
                       "%s"))
        (help-choices (mapconcat (lambda (c)
                                   (format "%c: %s\n" (car c) (caddr c)))
                                 choices)))
    (read-multiple-choice prompt choices
                          (format help-format help-choices))))

(cl-case (car (ement-read-multiple-choice
               "Room not joined on current session."
               '((?j "join" "Join room in ement.el")
                 (?w "web browser" "Open URL in web browser"))
               "\
You are not currently joined to that room.  You can either join the room
in ement.el, or visit the link URL in your web browser."))
  (?j 'join-it)
  (?w 'browse-it))

@phil-s
Copy link
Author

phil-s commented Jan 27, 2024

I've just realised that the "load link with browser" browse-url call here has always resulted in a recursive call to this function :)

I'll fix that while I'm at it...

@alphapapa
Copy link
Owner

Thanks for your work and your patience!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants