[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [DISCUSSION] "quick-help" popup for org-columns (column view)
From: |
Philip Kaludercic |
Subject: |
Re: [DISCUSSION] "quick-help" popup for org-columns (column view) |
Date: |
Sat, 06 Apr 2024 22:40:20 +0000 |
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
- Re: [DISCUSSION] "quick-help" popup for org-columns (column view), Sławomir Grochowski, 2024/04/06
- Re: [DISCUSSION] "quick-help" popup for org-columns (column view), chad, 2024/04/06
- Re: [DISCUSSION] "quick-help" popup for org-columns (column view),
Philip Kaludercic <=
- Re: [DISCUSSION] "quick-help" popup for org-columns (column view), Eli Zaretskii, 2024/04/07
- Re: [DISCUSSION] "quick-help" popup for org-columns (column view), Sławomir Grochowski, 2024/04/08
- Re: [DISCUSSION] "quick-help" popup for org-columns (column view), Philip Kaludercic, 2024/04/08
- Re: [DISCUSSION] "quick-help" popup for org-columns (column view), Sławomir Grochowski, 2024/04/08
- Re: [DISCUSSION] "quick-help" popup for org-columns (column view), Philip Kaludercic, 2024/04/10
- Re: [DISCUSSION] "quick-help" popup for org-columns (column view), Sławomir Grochowski, 2024/04/10
- Re: [DISCUSSION] "quick-help" popup for org-columns (column view), Philip Kaludercic, 2024/04/11
- Re: [DISCUSSION] "quick-help" popup for org-columns (column view), Philip Kaludercic, 2024/04/11
- Re: [DISCUSSION] "quick-help" popup for org-columns (column view), Sławomir Grochowski, 2024/04/11
- Re: [DISCUSSION] "quick-help" popup for org-columns (column view), Philip Kaludercic, 2024/04/13