mirror of
https://github.com/occivink/kakoune-sudo-write
synced 2025-04-02 22:40:36 +02:00
Don't rely on delete-buffer taking us to the previous buffer
This doesn't work in a draft context.
This commit is contained in:
parent
f43b341bd3
commit
f9bbf4606b
@ -3,6 +3,7 @@
|
||||
|
||||
define-command -hidden sudo-write-impl %{
|
||||
eval -save-regs f %{
|
||||
# TOOD this could take the content of the buffer from stdin instead
|
||||
reg f %sh{ mktemp --tmpdir XXXXX }
|
||||
write %reg{f}
|
||||
eval %sh{
|
||||
@ -18,18 +19,21 @@ define-command -hidden sudo-write-impl %{
|
||||
}
|
||||
|
||||
define-command -hidden -params 1 sudo-cache-password %{
|
||||
eval -save-regs '"' -no-hooks -draft %{
|
||||
edit -scratch *sudo_write_pass*
|
||||
eval -no-hooks -save-regs '"c' %{
|
||||
eval -draft %{
|
||||
edit -scratch *sudo-write-pass*
|
||||
reg '"' %arg{1}
|
||||
exec "<a-p>|sudo -S echo ok<ret>"
|
||||
try %{
|
||||
exec <a-k>ok<ret>
|
||||
delete-buffer
|
||||
exec '%H<a-k>ok<ret>'
|
||||
reg c nop
|
||||
} catch %{
|
||||
delete-buffer
|
||||
fail
|
||||
reg c fail
|
||||
}
|
||||
}
|
||||
delete-buffer *sudo-write-pass*
|
||||
eval %reg{c}
|
||||
}
|
||||
}
|
||||
|
||||
define-command -hidden sudo-prompt-password %{
|
||||
|
Loading…
x
Reference in New Issue
Block a user