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 \