From 8459b7e1ac4ae6f77132cf59e18a63e2f2dcd32e Mon Sep 17 00:00:00 2001 From: Alexander Rosenberg Date: Sun, 10 Mar 2024 06:32:19 -0700 Subject: [PATCH] Add extra confirmation to emacs-bookmark.zsh --- emacs-bookmark.zsh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/emacs-bookmark.zsh b/emacs-bookmark.zsh index 5bc5dd4..2eeff98 100644 --- a/emacs-bookmark.zsh +++ b/emacs-bookmark.zsh @@ -135,6 +135,14 @@ function bmadd { name="${2}" ;; esac + __bm_update_bookmark_list + if __bm_bookmark_location "${name}" >/dev/null; then + printf 'Bookmark "%s" already exists. Overwrite it? [y/N] ' "${name}" + read -q + let ans=${?} + printf '\n' + (( ${ans} != 0 )) && return 1 + fi local res="$(emacsclient --eval \ "(let* ((loc \"${loc:gs#\\#\\\\#:gs#\"#\\\"#}\") (name \"${name:gs#\\#\\\\#:gs#\"#\\\"#}\") @@ -163,7 +171,10 @@ function bmrm { printf 'usage: bmrm [NAME]\n' return 1 fi - printf 'Really delete "%s" [y/N]: ' "${1}" + __bm_update_bookmark_list + __bm_bookmark_location "${1}" >/dev/null || \ + { printf 'No such bookmark: "%s"\n' "${1}"; return 1 } + printf 'Really delete "%s"? [y/N] ' "${1}" if read -q; then printf '\n' local res="$(emacsclient --eval \