Skip to content

Commit 8a37592

Browse files
committed
hooks(refactor): rename set_hooks_bulk -> set_hooks
why: Align with libtmux naming conventions (singular/plural pattern) what: - Rename method from set_hooks_bulk to set_hooks - Update doctests to use show_hook().keys() instead of get_hook_indices - Update module docstring bulk operations list Squash target: d4de173 (hooks feat: add bulk operations)
1 parent 83f3568 commit 8a37592

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

src/libtmux/hooks.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,7 @@
2727
-------------------
2828
This module provides bulk operations for managing multiple indexed hooks:
2929
30-
- :meth:`~HooksMixin.get_hook_indices` - Get list of existing indices for a hook
31-
- :meth:`~HooksMixin.get_hook_values` - Get all values as SparseArray
32-
- :meth:`~HooksMixin.set_hooks_bulk` - Set multiple hooks at once
33-
- :meth:`~HooksMixin.clear_hook` - Unset all indexed values for a hook
34-
- :meth:`~HooksMixin.append_hook` - Append at next available index
30+
- :meth:`~HooksMixin.set_hooks` - Set multiple hooks at once
3531
"""
3632

3733
from __future__ import annotations
@@ -492,7 +488,7 @@ def get_hook_values(
492488
result: SparseArray[str] = hook_array
493489
return result
494490

495-
def set_hooks_bulk(
491+
def set_hooks(
496492
self,
497493
hook: str,
498494
values: HookValues,
@@ -528,39 +524,42 @@ def set_hooks_bulk(
528524
--------
529525
Set hooks with explicit indices:
530526
531-
>>> session.set_hooks_bulk('session-renamed', {
527+
>>> session.set_hooks('session-renamed', {
532528
... 0: 'display-message "hook 0"',
533529
... 1: 'display-message "hook 1"',
534530
... })
535531
Session($...)
536532
537-
>>> session.get_hook_indices('session-renamed')
533+
>>> hooks = session.show_hook('session-renamed')
534+
>>> sorted(hooks.keys())
538535
[0, 1]
539536
540537
Set hooks from a list (sequential indices):
541538
542-
>>> session.set_hooks_bulk('after-new-window', [
539+
>>> session.set_hooks('after-new-window', [
543540
... 'select-pane -t 0',
544541
... 'send-keys "clear" Enter',
545542
... ])
546543
Session($...)
547544
548-
>>> session.get_hook_indices('after-new-window')
545+
>>> hooks = session.show_hook('after-new-window')
546+
>>> sorted(hooks.keys())
549547
[0, 1]
550548
551549
Replace all existing hooks with ``clear_existing=True``:
552550
553-
>>> session.set_hooks_bulk('session-renamed', {0: 'display-message "new"'},
554-
... clear_existing=True)
551+
>>> session.set_hooks('session-renamed', {0: 'display-message "new"'},
552+
... clear_existing=True)
555553
Session($...)
556554
557-
>>> session.get_hook_indices('session-renamed')
555+
>>> hooks = session.show_hook('session-renamed')
556+
>>> sorted(hooks.keys())
558557
[0]
559558
560-
>>> session.clear_hook('session-renamed')
559+
>>> session.unset_hook('session-renamed')
561560
Session($...)
562561
563-
>>> session.clear_hook('after-new-window')
562+
>>> session.unset_hook('after-new-window')
564563
Session($...)
565564
"""
566565
if clear_existing:

0 commit comments

Comments
 (0)