* Tab advance for tabulated-list-mode [CODE ATTACHED]
@ 2021-01-17 7:17 Boruch Baum
2021-01-17 11:05 ` Daniel Martín
0 siblings, 1 reply; 6+ messages in thread
From: Boruch Baum @ 2021-01-17 7:17 UTC (permalink / raw)
To: Emacs-Devel List
Tabulated-list-mode provides for sorting by column at POINT, but not for
navigating by column to quickly get to the column one wishes to sort.
The following code provides that feature.
(defun tabulated-list-tab-backward (&optional n)
"Navigated N column entries backward in tabulated listing.
Default is to advance one column."
(interactive "p")
(crossword-summary-tab-forward (- n)))
(defun tabulated-list-tab-forward (&optional n)
"Navigate N column entries forward in tabulated listing.
Default is to advance one column."
(interactive "p")
(let* ((direction (if (< 0 n)
'next-single-property-change
(setq n (- n))
'previous-single-property-change))
(pos (point))
N)
(dotimes (N n)
(if (not pos)
(setq N n)
(while (and (setq pos (funcall direction pos 'tabulated-list-column-name))
(not (get-text-property pos 'tabulated-list-entry))))))
(goto-char (or pos (if (eq direction 'next-property-change)
(point-max)
(point-min))))))
(define-key tabulated-list-mode-map "\t" 'tabulated-list-tab-forward)
(define-key tabulated-list-mode-map (kbd "<backtab>") 'tabulated-list-tab-backward)
--
hkp://keys.gnupg.net
CA45 09B5 5351 7C11 A9D1 7286 0036 9E45 1595 8BC0
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Tab advance for tabulated-list-mode [CODE ATTACHED]
2021-01-17 7:17 Tab advance for tabulated-list-mode [CODE ATTACHED] Boruch Baum
@ 2021-01-17 11:05 ` Daniel Martín
2021-01-17 12:00 ` Boruch Baum
2021-01-17 15:20 ` Stefan Monnier
0 siblings, 2 replies; 6+ messages in thread
From: Daniel Martín @ 2021-01-17 11:05 UTC (permalink / raw)
To: Boruch Baum; +Cc: Emacs-Devel List
Boruch Baum <boruch_baum@gmx.com> writes:
> Tabulated-list-mode provides for sorting by column at POINT, but not for
> navigating by column to quickly get to the column one wishes to sort.
> The following code provides that feature.
>
[...]
>
> (define-key tabulated-list-mode-map "\t" 'tabulated-list-tab-forward)
> (define-key tabulated-list-mode-map (kbd "<backtab>") 'tabulated-list-tab-backward)
How would this work when the tabulated list has one or more buttons?
(package.el is the most prominent example of that). By default, TAB and
<backtab> are bound to forward-button and backward-button, respectively.
Perhaps we could provide the functions but leave the keybindings to the
tabulated-list-mode implementors, or choose a different keybidinding.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Tab advance for tabulated-list-mode [CODE ATTACHED]
2021-01-17 11:05 ` Daniel Martín
@ 2021-01-17 12:00 ` Boruch Baum
2021-01-17 15:20 ` Stefan Monnier
1 sibling, 0 replies; 6+ messages in thread
From: Boruch Baum @ 2021-01-17 12:00 UTC (permalink / raw)
To: Daniel Martín; +Cc: Emacs-Devel List
On 2021-01-17 12:05, Daniel Martín wrote:
> Boruch Baum <boruch_baum@gmx.com> writes:
> [...]
> >
> > (define-key tabulated-list-mode-map "\t" 'tabulated-list-tab-forward)
> > (define-key tabulated-list-mode-map (kbd "<backtab>") 'tabulated-list-tab-backward)
>
>
> How would this work when the tabulated list has one or more buttons?
> (package.el is the most prominent example of that). By default, TAB and
> <backtab> are bound to forward-button and backward-button, respectively.
>
> Perhaps we could provide the functions but leave the keybindings to the
> tabulated-list-mode implementors, or choose a different keybidinding.
I did overlook that (my personal use-case isn't using buttons).
Shame, because TAB/BACKTAB are the intuitive bindings for both ideas.
Maybe alt-arrow (M-Left, M-Right)? Not nearly as discover-able, but we
are living in the age of PPRTM ...
--
hkp://keys.gnupg.net
CA45 09B5 5351 7C11 A9D1 7286 0036 9E45 1595 8BC0
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Tab advance for tabulated-list-mode [CODE ATTACHED]
2021-01-17 11:05 ` Daniel Martín
2021-01-17 12:00 ` Boruch Baum
@ 2021-01-17 15:20 ` Stefan Monnier
2021-01-17 16:00 ` Daniel Martín
1 sibling, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2021-01-17 15:20 UTC (permalink / raw)
To: Daniel Martín; +Cc: Boruch Baum, Emacs-Devel List
>> Tabulated-list-mode provides for sorting by column at POINT, but not for
>> navigating by column to quickly get to the column one wishes to sort.
>> The following code provides that feature.
>>
> [...]
>>
>> (define-key tabulated-list-mode-map "\t" 'tabulated-list-tab-forward)
>> (define-key tabulated-list-mode-map (kbd "<backtab>") 'tabulated-list-tab-backward)
>
>
> How would this work when the tabulated list has one or more buttons?
Presumably the major mode will be derived from `tabulated-list-mode` and
the keymap will have `tabulated-list-mode-map` as its parent, so any
specific local bindings (or local buttons) should take precedence, so
the above patch shouldn't cause a regression.
Stefan
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Tab advance for tabulated-list-mode [CODE ATTACHED]
2021-01-17 15:20 ` Stefan Monnier
@ 2021-01-17 16:00 ` Daniel Martín
2021-01-17 18:58 ` Stefan Monnier
0 siblings, 1 reply; 6+ messages in thread
From: Daniel Martín @ 2021-01-17 16:00 UTC (permalink / raw)
To: Stefan Monnier; +Cc: Boruch Baum, Emacs-Devel List
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>>>
>>> (define-key tabulated-list-mode-map "\t" 'tabulated-list-tab-forward)
>>> (define-key tabulated-list-mode-map (kbd "<backtab>") 'tabulated-list-tab-backward)
>>
>>
>> How would this work when the tabulated list has one or more buttons?
>
> Presumably the major mode will be derived from `tabulated-list-mode` and
> the keymap will have `tabulated-list-mode-map` as its parent, so any
> specific local bindings (or local buttons) should take precedence, so
> the above patch shouldn't cause a regression.
I didn't mean a regression, but a change in behavior. I've installed
the patch locally, and pressing TAB in *Packages* now goes from column
to column. Before the patch, it went from package to package. We can
either:
a) Accept the new behavior, as it is more intuitive in my opinion.
b) Override the binding in package.el, to preserve the original
behavior.
(The same may happen to other packages that inherit from
tabulated-list-mode.)
I'm in favor of the change. If it's documented well in NEWS, it
shouldn't cause much trouble if packages need to adapt to it.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Tab advance for tabulated-list-mode [CODE ATTACHED]
2021-01-17 16:00 ` Daniel Martín
@ 2021-01-17 18:58 ` Stefan Monnier
0 siblings, 0 replies; 6+ messages in thread
From: Stefan Monnier @ 2021-01-17 18:58 UTC (permalink / raw)
To: Daniel Martín; +Cc: Boruch Baum, Emacs-Devel List
> I didn't mean a regression, but a change in behavior. I've installed
> the patch locally, and pressing TAB in *Packages* now goes from column
> to column. Before the patch, it went from package to package.
Hmm... that's what I thought wouldn't happen.
Stefan
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-01-17 18:58 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-17 7:17 Tab advance for tabulated-list-mode [CODE ATTACHED] Boruch Baum
2021-01-17 11:05 ` Daniel Martín
2021-01-17 12:00 ` Boruch Baum
2021-01-17 15:20 ` Stefan Monnier
2021-01-17 16:00 ` Daniel Martín
2021-01-17 18:58 ` Stefan Monnier
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.