From bf92e25100faf9fad40ff303b9bbb6471d8499e0 Mon Sep 17 00:00:00 2001 From: Alexander Rosenberg Date: Sun, 10 Mar 2024 06:12:51 -0700 Subject: [PATCH] Add completions to emacs-bookmark.zsh --- emacs-bookmark.zsh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/emacs-bookmark.zsh b/emacs-bookmark.zsh index 5e9acd4..5bc5dd4 100644 --- a/emacs-bookmark.zsh +++ b/emacs-bookmark.zsh @@ -86,6 +86,12 @@ function __bm_list_bookmarks { done } +function _bookmarks { + for ((i = 1; i < ${#__bm_bookmark_cache}; i+=4)); do + compadd "${__bm_bookmark_cache[${i}]}" + done +} + alias lsbm="__bm_update_bookmark_list && __bm_list_bookmarks" function bm { __bm_update_bookmark_list || \ @@ -102,6 +108,10 @@ function bm { return 1 fi } +function _bm { + _arguments ':bookmark:_bookmarks' +} +compdef _bm bm function bmadd { if [[ "${1}" = '-h' ]]; then @@ -138,6 +148,10 @@ function bmadd { [[ "${res}" = 'nil' ]] && printf 'Added bookmark "%s"\n' "${name}" \ || { printf '%s\n' "${res}"; return 1 } } +function _bmadd { + _arguments ':file:_files' ':name' +} +compdef _bmadd bmadd function bmrm { if [[ "${1}" = '-h' ]]; then @@ -164,3 +178,9 @@ function bmrm { return 1 fi } +function _bmrm { + _arguments ':bookmark:_bookmarks' +} +compdef _bmrm bmrm + +__bm_update_bookmark_list