Add extra confirmation to emacs-bookmark.zsh

This commit is contained in:
Alexander Rosenberg 2024-03-10 06:32:19 -07:00
parent bf92e25100
commit 8459b7e1ac
Signed by: Zander671
GPG Key ID: 5FD0394ADBD72730

View File

@ -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 \