@@ -410,9 +410,17 @@ def get_hook_indices(
410410
411411 Examples
412412 --------
413- >>> # After setting hooks at indices 0, 1, 5:
414- >>> # session.get_hook_indices('session-renamed')
415- >>> # [0, 1, 5]
413+ >>> session.set_hook('session-renamed[0]', 'display-message "test"')
414+ Session($...)
415+
416+ >>> session.set_hook('session-renamed[5]', 'display-message "test"')
417+ Session($...)
418+
419+ >>> session.get_hook_indices('session-renamed')
420+ [0, 5]
421+
422+ >>> session.clear_hook('session-renamed')
423+ Session($...)
416424 """
417425 hooks_output = self ._show_hook (
418426 hook = hook ,
@@ -455,9 +463,18 @@ def get_hook_values(
455463
456464 Examples
457465 --------
458- >>> # values = session.get_hook_values('session-renamed')
459- >>> # for val in values.iter_values():
460- >>> # print(val)
466+ >>> session.set_hook('session-renamed[0]', 'display-message "first"')
467+ Session($...)
468+
469+ >>> values = session.get_hook_values('session-renamed')
470+ >>> 0 in values
471+ True
472+
473+ >>> 'display-message' in values[0]
474+ True
475+
476+ >>> session.clear_hook('session-renamed')
477+ Session($...)
461478 """
462479 hooks_output = self ._show_hook (
463480 hook = hook ,
@@ -511,21 +528,40 @@ def set_hooks_bulk(
511528 --------
512529 Set hooks with explicit indices:
513530
514- >>> # session.set_hooks_bulk('session-renamed', {
515- >>> # 0: 'display-message "hook 0"',
516- >>> # 1: 'display-message "hook 1"',
517- >>> # })
531+ >>> session.set_hooks_bulk('session-renamed', {
532+ ... 0: 'display-message "hook 0"',
533+ ... 1: 'display-message "hook 1"',
534+ ... })
535+ Session($...)
536+
537+ >>> session.get_hook_indices('session-renamed')
538+ [0, 1]
518539
519540 Set hooks from a list (sequential indices):
520541
521- >>> # session.set_hooks_bulk('after-new-window', [
522- >>> # 'select-pane -t 0',
523- >>> # 'send-keys "clear" Enter',
524- >>> # ])
542+ >>> session.set_hooks_bulk('after-new-window', [
543+ ... 'select-pane -t 0',
544+ ... 'send-keys "clear" Enter',
545+ ... ])
546+ Session($...)
547+
548+ >>> session.get_hook_indices('after-new-window')
549+ [0, 1]
550+
551+ Replace all existing hooks with ``clear_existing=True``:
525552
526- Replace all existing hooks:
553+ >>> session.set_hooks_bulk('session-renamed', {0: 'display-message "new"'},
554+ ... clear_existing=True)
555+ Session($...)
527556
528- >>> # session.set_hooks_bulk('session-renamed', [...], clear_existing=True)
557+ >>> session.get_hook_indices('session-renamed')
558+ [0]
559+
560+ >>> session.clear_hook('session-renamed')
561+ Session($...)
562+
563+ >>> session.clear_hook('after-new-window')
564+ Session($...)
529565 """
530566 if clear_existing :
531567 self .clear_hook (hook , _global = _global , scope = scope )
@@ -571,7 +607,20 @@ def clear_hook(
571607
572608 Examples
573609 --------
574- >>> # session.clear_hook('session-renamed')
610+ >>> session.set_hook('session-renamed[0]', 'display-message "test"')
611+ Session($...)
612+
613+ >>> session.set_hook('session-renamed[1]', 'display-message "test2"')
614+ Session($...)
615+
616+ >>> session.get_hook_indices('session-renamed')
617+ [0, 1]
618+
619+ >>> session.clear_hook('session-renamed')
620+ Session($...)
621+
622+ >>> session.get_hook_indices('session-renamed')
623+ []
575624 """
576625 indices = self .get_hook_indices (
577626 hook ,
@@ -615,7 +664,17 @@ def append_hook(
615664
616665 Examples
617666 --------
618- >>> # session.append_hook('session-renamed', 'display-message "appended"')
667+ >>> session.set_hook('session-renamed[0]', 'display-message "first"')
668+ Session($...)
669+
670+ >>> session.append_hook('session-renamed', 'display-message "appended"')
671+ Session($...)
672+
673+ >>> session.get_hook_indices('session-renamed')
674+ [0, 1]
675+
676+ >>> session.clear_hook('session-renamed')
677+ Session($...)
619678 """
620679 indices = self .get_hook_indices (
621680 hook ,
0 commit comments