Finish fixing (hopefully) emacs-bookmark.zsh
This commit is contained in:
parent
8d3ef4b4e4
commit
db347d3f5c
@ -120,16 +120,16 @@ function bm {
|
|||||||
${=EDITOR} "${target}"
|
${=EDITOR} "${target}"
|
||||||
else
|
else
|
||||||
printf 'Bookmark exists, but trailing path doesn'"'"'t: "%s"\n' \
|
printf 'Bookmark exists, but trailing path doesn'"'"'t: "%s"\n' \
|
||||||
"${__bm_res[3]}"
|
"${(q)__bm_res[3]}"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
printf 'No such bookmark: "%s"\n' "${1}"
|
printf 'No such bookmark: "%s"\n' "${(q)1}"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
function _bm {
|
function _bm {
|
||||||
local arg="${words[${CURRENT}]}"
|
local arg="${(Q)words[${CURRENT}]}"
|
||||||
if ! [[ "${arg}" == */* ]]; then
|
if ! [[ "${arg}" == */* ]]; then
|
||||||
_arguments '1::bookmark:_bookmarks'
|
_arguments '1::bookmark:_bookmarks'
|
||||||
else
|
else
|
||||||
@ -137,7 +137,7 @@ function _bm {
|
|||||||
if [[ -d "${__bm_res[1]}" ]]; then
|
if [[ -d "${__bm_res[1]}" ]]; then
|
||||||
local parts=(${(s:/:)__bm_res[3]})
|
local parts=(${(s:/:)__bm_res[3]})
|
||||||
local bm="${${(s:/:)${arg}}[1]}"
|
local bm="${${(s:/:)${arg}}[1]}"
|
||||||
local subdir="${(j:/:)parts[1,${#parts}-1]}"
|
local subdir="${(j:/:)parts[1,-2]}"
|
||||||
local search="${parts[${#parts}]}"
|
local search="${parts[${#parts}]}"
|
||||||
if ((${#parts} > 0)) && [[ "${arg}" == */ ]]; then
|
if ((${#parts} > 0)) && [[ "${arg}" == */ ]]; then
|
||||||
subdir="${subdir}/${search}"
|
subdir="${subdir}/${search}"
|
||||||
@ -145,7 +145,8 @@ function _bm {
|
|||||||
search=""
|
search=""
|
||||||
fi
|
fi
|
||||||
local pre_path="${__bm_res[1]}/${subdir}/"
|
local pre_path="${__bm_res[1]}/${subdir}/"
|
||||||
local prefix="${bm}/${subdir}"
|
local raw_arg="${words[${CURRENT}]}"
|
||||||
|
local prefix="${${(s:/:)${raw_arg}}[1]}/${subdir}"
|
||||||
if ! [[ -z "${subdir}" ]]; then
|
if ! [[ -z "${subdir}" ]]; then
|
||||||
prefix+='/'
|
prefix+='/'
|
||||||
fi
|
fi
|
||||||
@ -182,7 +183,7 @@ function bmadd {
|
|||||||
esac
|
esac
|
||||||
__bm_update_bookmark_list
|
__bm_update_bookmark_list
|
||||||
if __bm_bookmark_location "${name}" >/dev/null; then
|
if __bm_bookmark_location "${name}" >/dev/null; then
|
||||||
printf 'Bookmark "%s" already exists. Overwrite it? [y/N] ' "${name}"
|
printf 'Bookmark "%s" already exists. Overwrite it? [y/N] ' "${(q)name}"
|
||||||
read -q
|
read -q
|
||||||
let ans=${?}
|
let ans=${?}
|
||||||
printf '\n'
|
printf '\n'
|
||||||
@ -198,7 +199,7 @@ function bmadd {
|
|||||||
(inhibit-message t))
|
(inhibit-message t))
|
||||||
(bookmark-save)
|
(bookmark-save)
|
||||||
res)")"
|
res)")"
|
||||||
[[ "${res}" = 'nil' ]] && printf 'Added bookmark "%s"\n' "${name}" \
|
[[ "${res}" = 'nil' ]] && printf 'Added bookmark "%s"\n' "${(q)name}" \
|
||||||
|| { printf '%s\n' "${res}"; return 1 }
|
|| { printf '%s\n' "${res}"; return 1 }
|
||||||
__bm_update_bookmark_list
|
__bm_update_bookmark_list
|
||||||
}
|
}
|
||||||
@ -220,7 +221,7 @@ function bmrm {
|
|||||||
__bm_update_bookmark_list
|
__bm_update_bookmark_list
|
||||||
__bm_bookmark_location "${1}" >/dev/null || \
|
__bm_bookmark_location "${1}" >/dev/null || \
|
||||||
{ printf 'No such bookmark: "%s"\n' "${1}"; return 1 }
|
{ printf 'No such bookmark: "%s"\n' "${1}"; return 1 }
|
||||||
printf 'Really delete "%s"? [y/N] ' "${1}"
|
printf 'Really delete "%s"? [y/N] ' "${(q)1}"
|
||||||
if read -q; then
|
if read -q; then
|
||||||
printf '\n'
|
printf '\n'
|
||||||
local res="$(emacsclient --eval \
|
local res="$(emacsclient --eval \
|
||||||
@ -228,7 +229,7 @@ function bmrm {
|
|||||||
(inhibit-message t))
|
(inhibit-message t))
|
||||||
(bookmark-save)
|
(bookmark-save)
|
||||||
res)")"
|
res)")"
|
||||||
[[ "${res}" = 'nil' ]] && printf 'Deleted bookmark "%s"\n' "${1}" \
|
[[ "${res}" = 'nil' ]] && printf 'Deleted bookmark "%s"\n' "${(q)1}" \
|
||||||
|| { printf '%s\n' "${res}"; return 1 }
|
|| { printf '%s\n' "${res}"; return 1 }
|
||||||
else
|
else
|
||||||
printf '\n'
|
printf '\n'
|
||||||
|
Loading…
Reference in New Issue
Block a user