Slawomir Grochowski <[email protected]> writes:

> Hi,
>
> this patch adds a quick-help popup for Org column view, bound to `?'.
>
> I am Cc'ing Philip Kaludercic, who authored `help-quick'.  Thanks for the
> package and for the idea; it fits this use case nicely.

(Thanks :))

> I wanted to add something like this a couple of years ago:
> <https://list.orgmode.org/[email protected]/>
>
> At that time I was not fully convinced by the approach.  I was hoping
> for a tighter integration with something like which-key.
>
> There are still things that could eventually provide a more integrated
> UI for this, for example the recent discussion around:
> <https://list.orgmode.org/[email protected]/>

The actual links appears to be
https://yhetil.org/emacs-devel/[email protected]/

>
> and related attempts in Org:
> <https://list.orgmode.org/[email protected]/>
>
> However, I think this small popup is already useful in its current form.
> Column view has enough specialized bindings that a compact quick-help
> buffer makes it much easier to move around and edit values.  If a more
> integrated generic facility appears later, we can replace the
> implementation then.  I do not think we need to keep waiting for that
> before improving the current user experience.
>
> It looks roughly like this:
>
>   Value                      Column                  Move row/column          
> View                Misc.
>   e         edit             M-S-<right> add         M-<up>    row up         
> c       contents    g redo
>   a         allowed          M-S-<left>  delete      M-<down>  row down       
> o       overview    ? quick help
>   S-<right> next             <           narrow      M-<left>  column left    
> v       show value  q quit
>   S-<left>  previous         >           widen       M-<right> column right   
> C-c C-o open link
>   C-c C-c   toggle checkbox  s           attributes
>   C-c C-t   TODO
>
> The implementation reuses Emacs' `help-quick'.  Since `help-quick'
> shows only one binding for each command, the quick-help command uses a
> copy of `org-columns-map' and removes `n' and `p' from that copy.  This
> makes the popup show `S-<right>' and `S-<left>' for cycling allowed
> values, which is more consistent with the usual Org interface for
> changing values, such as TODO states.

This is related to bug#60101.

We could fix this upstream by checking for a symbol property, say
`canonical-binding', and prefer that if FIRSTONLY is non-nil.

> I would like to hear whether people are fine with this direction.  I
> used `?' because it is a common key for contextual help in special
> buffers, and column view already has its own overlay keymap while it is
> active.  Since I maintain this file, I can merge it after review if
> there are no objections.
>
> Best,
> -- 
> Slawomir Grochowski
>
> From 33457e554003ce7818d39dac82cd6c2cc4c3028b Mon Sep 17 00:00:00 2001
> From: Slawomir Grochowski <[email protected]>
> Date: Fri, 5 Jun 2026 09:04:09 +0200
> Subject: [PATCH] org-colview: Add quick help for column view
>
> * lisp/org-colview.el (help-quick-toggle, help-quick-sections)
> (help-quick-use-map): Declare.
> (org-columns-map, org-columns-menu): Add quick help entry.
> (org-columns-help-quick-sections): New variable.
> (org-columns-help-quick-toggle, org-columns--help-quick-close): New
> functions.
> (org-columns-quit): Close quick help window.
> ---
>  lisp/org-colview.el | 60 +++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 60 insertions(+)
>
> diff --git a/lisp/org-colview.el b/lisp/org-colview.el
> index efee7cc6e..9428ab891 100644
> --- a/lisp/org-colview.el
> +++ b/lisp/org-colview.el
> @@ -46,11 +46,14 @@
>  (declare-function org-element-property "org-element-ast" (property node))
>  (declare-function org-element-restriction "org-element" (element))
>  (declare-function org-element-type-p "org-element-ast" (node types))
> +(declare-function help-quick-toggle "help" ())
>  (declare-function org-link-display-format "ol" (s))
>  (declare-function org-link-open-from-string "ol" (s &optional arg))
>  (declare-function face-remap-remove-relative "face-remap" (cookie))
>  (declare-function face-remap-add-relative "face-remap" (face &rest specs))
>  
> +(defvar help-quick-sections)
> +(defvar help-quick-use-map)
>  (defvar org-agenda-columns-add-appointments-to-effort-sum)
>  (defvar org-agenda-columns-active) ;; defined in org-agenda.el
>  (defvar org-agenda-columns-compute-summary-properties)
> @@ -183,6 +186,7 @@ This is the compiled version of the format.")
>    (org-cycle-content))
>  
>  (org-defkey org-columns-map "c"        #'org-columns-content)
> +(org-defkey org-columns-map "?"        #'org-columns-help-quick-toggle)
>  (org-defkey org-columns-map "o"        #'org-overview)
>  (org-defkey org-columns-map "e"        #'org-columns-edit-value)
>  (org-defkey org-columns-map "\C-c\C-t" #'org-columns-todo)
> @@ -242,8 +246,63 @@ This is the compiled version of the format.")
>      "--"
>      ["Open link" org-columns-open-link t]
>      "--"
> +    ["Quick help" org-columns-help-quick-toggle t]
> +    "--"
>      ["Quit" org-columns-quit t]))
>  
> +;;;; Quick help
> +
> +(defvar org-columns-help-quick-sections
> +  '(("Value"
> +     (org-columns-edit-value . "edit")
> +     (org-columns-edit-allowed . "allowed")
> +     (org-columns-next-allowed-value . "next")
> +     (org-columns-previous-allowed-value . "previous")
> +     (org-columns-toggle-or-columns-quit . "toggle checkbox")
> +     (org-columns-todo . "TODO"))
> +    ("Column"
> +     (org-columns-new . "add")
> +     (org-columns-delete . "delete")
> +     (org-columns-narrow . "narrow")
> +     (org-columns-widen . "widen")
> +     (org-columns-edit-attributes . "attributes"))
> +    ("Move row/column"
> +     (org-columns-move-row-up . "row up")
> +     (org-columns-move-row-down . "row down")
> +     (org-columns-move-left . "column left")
> +     (org-columns-move-right . "column right"))
> +    ("View"
> +     (org-columns-content . "contents")
> +     (org-overview . "overview")
> +     (org-columns-show-value . "show value")
> +     (org-columns-open-link . "open link"))
> +    ("Misc."
> +     (org-columns-redo . "redo")
> +     (org-columns-help-quick-toggle . "quick help")
> +     (org-columns-quit . "quit")))
> +  "Quick-help sections for column view.
> +See `help-quick-sections' for the format.")
> +
> +(defun org-columns-help-quick-toggle ()
> +  "Toggle quick help for column view."
> +  (interactive nil org-mode org-agenda-mode)
> +  (let ((quick-help-window (get-buffer-window "*Quick Help*" t))
> +        (map (copy-keymap org-columns-map)))
> +    (define-key map "n" nil)
> +    (define-key map "p" nil)
> +    (let ((help-quick-sections org-columns-help-quick-sections)
> +          (help-quick-use-map (list map)))
> +      (help-quick-toggle))
> +    (unless quick-help-window
> +      (message "Toggle display of quick-help buffer using %s."
> +               (propertize "?" 'face 'help-key-binding
> +                            'font-lock-face 'help-key-binding)))))
> +
> +(defun org-columns--help-quick-close ()
> +  "Close column view quick-help, if it is visible."
> +  (when-let* ((quick-help-window (get-buffer-window "*Quick Help*" t)))
> +    (quit-window t quick-help-window)))
> +
>  ;;;; Value collection
>  
>  (defun org-columns--displayed-value (spec value &optional no-star)
> @@ -702,6 +761,7 @@ This is needed to later remove this relative remapping.")
>  (defun org-columns-quit ()
>    "Remove the column overlays and in this way exit column editing."
>    (interactive nil org-mode org-agenda-mode)
> +  (org-columns--help-quick-close)
>    (org-columns-remove-overlays)
>    (if (not (eq major-mode 'org-agenda-mode))
>        (setq org-columns-current-fmt nil)

Reply via email to