From: Philip Kaludercic <philipk@posteo.net>
To: "Sławomir Grochowski" <slawomir.grochowski@gmail.com>
Cc: Ihor Radchenko <yantar92@posteo.net>,
emacs-orgmode@gnu.org, emacs-devel@gnu.org,
stefankangas@gmail.com, larsi@gnus.org, hmelman@gmail.com,
eliz@gnu.org, info@protesilaos.com
Subject: Re: [DISCUSSION] "quick-help" popup for org-columns (column view)
Date: Sat, 06 Apr 2024 22:40:20 +0000 [thread overview]
Message-ID: <87zfu6p12j.fsf@posteo.net> (raw)
In-Reply-To: <87zfu6b4w3.fsf@gmail.com> ("Sławomir Grochowski"'s message of "Sat, 06 Apr 2024 22:41:32 +0200")
Sławomir Grochowski <slawomir.grochowski@gmail.com> writes:
> Ihor Radchenko <yantar92@posteo.net> writes:
>
>> I see no downside supporting `help-quick' command in Org mode's column
>> view. Generally, better integration with Emacs built-in functionality is
>> welcome.
>
> Great. I'll be happy to take care of it.
>
> But first, we need to modify `help-quick' to be more reusable.
> I tried to do it, but I'm not experienced in elisp.
> I wanted to remove references to global variables, so I did a wrapper
> function to pass arguments to `help-quick'. I understand it's not a lispy way.
> I would be grateful for your comment.
>
> Patch in attachment.
I have to admit that I am not entirely certain what the plan is, but I
have a few concrete comments/questions on this patch
> From 5f343fd15c53f5bc5e7515ef0cd3049b4e0ec388 Mon Sep 17 00:00:00 2001
> From: Slawomir Grochowski <slawomir.grochowski@gmail.com>
> Date: Sat, 6 Apr 2024 22:11:01 +0200
> Subject: [PATCH] lisp/help: make `help-quick-toggle' reusable for other
> keymaps
>
> ---
> lisp/help.el | 22 +++++++++++++---------
> 1 file changed, 13 insertions(+), 9 deletions(-)
>
> diff --git a/lisp/help.el b/lisp/help.el
> index 1ef46e394f3..c32d1a2e943 100644
> --- a/lisp/help.el
> +++ b/lisp/help.el
> @@ -76,7 +76,7 @@ help-map
> "C-n" #'view-emacs-news
> "C-o" #'describe-distribution
> "C-p" #'view-emacs-problems
> - "C-q" #'help-quick-toggle
> + "C-q" #'help-quick-toggle-wrapper
> "C-s" #'search-forward-help-for-help
> "C-t" #'view-emacs-todo
> "C-w" #'describe-no-warranty
> @@ -178,22 +178,22 @@ help-quick-sections
> (declare-function prop-match-value "text-property-search" (match))
>
> ;; Inspired by a mg fork (https://github.com/troglobit/mg)
> -(defun help-quick ()
> +(defun help-quick (name-for-buffer sections &optional keymap)
> "Display a quick-help buffer showing popular commands and their bindings.
> The window showing quick-help can be toggled using \\[help-quick-toggle].
> You can click on a key binding shown in the quick-help buffer to display
> the documentation of the command bound to that key sequence."
> (interactive)
> - (with-current-buffer (get-buffer-create "*Quick Help*")
> + (with-current-buffer (get-buffer-create name-for-buffer)
Is there a reason not to re-use the same buffer? I am not sure if we
need multiple quick-help buffer to co-exist at the same time.
> (let ((inhibit-read-only t) (padding 2) blocks)
>
> ;; Go through every section and prepare a text-rectangle to be
> ;; inserted later.
> - (dolist (section help-quick-sections)
> + (dolist (section sections)
The idea here was that some other function could rebind
`help-quick-sections' dynamically. That way you avoid the redundant
arguments (which would all have to be documented).
> (let ((max-key-len 0) (max-cmd-len 0) keys)
> (dolist (ent (reverse (cdr section)))
> (catch 'skip
> - (let* ((bind (where-is-internal (car ent) nil t))
> + (let* ((bind (where-is-internal (car ent) keymap t))
> (key (if bind
> (propertize
> (key-description bind)
> @@ -259,21 +259,25 @@ help-quick
> (message
> (substitute-command-keys "Toggle display of quick-help buffer using \\[help-quick-toggle]."))))
>
> -(defun help-quick-toggle ()
> +(defun help-quick-toggle-wrapper ()
The naming here is weird IMO, usually the other function should be
called something like `help-quick-toggle-internal' and this would be
`help-quick-toggle'.
> + (interactive)
> + (help-quick-toggle "*Quick Help*" help-quick-sections))
> +
> +(defun help-quick-toggle (name-for-buffer sections &optional keymap)
> "Toggle display of a window showing popular commands and their bindings.
> This toggles on and off the display of the quick-help buffer, which shows
> popular commands and their bindings as produced by `help-quick'.
> You can click on a key binding shown in the quick-help buffer to display
> the documentation of the command bound to that key sequence."
> (interactive)
> - (if (and-let* ((window (get-buffer-window "*Quick Help*")))
> + (if (and-let* ((window (get-buffer-window name-for-buffer)))
> (quit-window t window))
> ;; Clear the message we may have gotten from `C-h' and then
> ;; waiting before hitting `q'.
> (message "")
> - (help-quick)))
> + (help-quick name-for-buffer sections keymap)))
>
> -(defalias 'cheat-sheet #'help-quick)
> +(defalias 'cheat-sheet #'help-quick-wrapper)
>
> (defun help-quit ()
> "Just exit from the Help command's command loop."
> --
> 2.30.2
>
>
>
> JD Smith <jdtsmith@gmail.com> writes:
>
>> Also recall we had a discussion in bug#68236
>> <https://lists.gnu.org/archive/html/bug-gnu-emacs/2024-01/msg00124.html>
>> about expanding quick-help to include mode-local
>> personalized binding shortcuts (with org as a particular target of interest).
>
> Thank you for the link I haven't seen that topic.
>
> Regards,
--
Philip Kaludercic on icterid
next prev parent reply other threads:[~2024-04-06 22:41 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-08 19:55 [DISCUSSION] "quick-help" popup for org-columns (column view) Sławomir Grochowski
2024-02-08 22:16 ` Adam Porter
2024-02-08 23:01 ` Stefan Kangas
2024-02-09 23:02 ` Ihor Radchenko
2024-02-10 15:44 ` Philip Kaludercic
2024-02-10 18:04 ` [External] : " Drew Adams
2024-03-20 23:15 ` JD Smith
2024-03-20 14:08 ` Ihor Radchenko
2024-04-06 20:41 ` Sławomir Grochowski
2024-04-06 22:08 ` chad
2024-04-06 22:40 ` Philip Kaludercic [this message]
2024-04-07 5:57 ` Eli Zaretskii
2024-04-08 7:38 ` Sławomir Grochowski
2024-04-08 8:24 ` Philip Kaludercic
2024-04-08 19:13 ` Sławomir Grochowski
2024-04-10 8:26 ` Philip Kaludercic
2024-04-10 20:42 ` Sławomir Grochowski
2024-04-11 6:37 ` Philip Kaludercic
2024-04-11 6:58 ` Philip Kaludercic
2024-04-11 8:43 ` Sławomir Grochowski
2024-04-13 8:37 ` Philip Kaludercic
2024-04-15 12:39 ` Sławomir Grochowski
2024-04-16 7:24 ` Philip Kaludercic
2024-04-18 20:55 ` Sławomir Grochowski
2024-05-02 18:04 ` Sławomir Grochowski
2024-04-08 11:46 ` Eli Zaretskii
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
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87zfu6p12j.fsf@posteo.net \
--to=philipk@posteo.net \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=emacs-orgmode@gnu.org \
--cc=hmelman@gmail.com \
--cc=info@protesilaos.com \
--cc=larsi@gnus.org \
--cc=slawomir.grochowski@gmail.com \
--cc=stefankangas@gmail.com \
--cc=yantar92@posteo.net \
/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 public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.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).