Fix khard.el

This commit is contained in:
Alexander Rosenberg 2023-10-29 03:03:24 -07:00
parent 2118704d98
commit c26beed6e9
Signed by: Zander671
GPG Key ID: 5FD0394ADBD72730

View File

@ -4,7 +4,7 @@
(require 'with-editor) (require 'with-editor)
(add-to-list 'display-buffer-alist '("\\*khard output\\*" . (display-buffer-no-window))) (add-to-list 'display-buffer-alist '(" \\*khard output\\*" . (display-buffer-no-window)))
(defun khard--build-list-entry-detail (&rest items) (defun khard--build-list-entry-detail (&rest items)
"Build a detail in the format \" (ITEMS)\", or an empty string." "Build a detail in the format \" (ITEMS)\", or an empty string."
@ -62,7 +62,7 @@ If NO-CONFIRM is nil, do not ask the user."
:command :command
`("khard" "delete" "--force" `("khard" "delete" "--force"
,(format "uid:%s" (cdr-safe contact))) ,(format "uid:%s" (cdr-safe contact)))
:buffer "*khard output*" :buffer " *khard output*"
:sentinel #'khard--process-sentinel))) :sentinel #'khard--process-sentinel)))
(defun khard--prompt-address-book () (defun khard--prompt-address-book ()
@ -72,19 +72,18 @@ If NO-CONFIRM is nil, do not ask the user."
(defun khard--new-process-filter (proc str) (defun khard--new-process-filter (proc str)
"Process filter for `khard-new'. "Process filter for `khard-new'.
PROC and STR are described in `set-process-filter'." PROC and STR are described in `set-process-filter'."
(let ((lines (string-split str "\n"))) (let ((lines (string-split str "\n"))
(error-msg nil))
(dolist (line lines) (dolist (line lines)
(cond (if (equal
((string-prefix-p "Error: " line) "Do you want to open the editor again? (y/N) "
(setq error-msg line)) line)
((equal (if (y-or-n-p (format "%sReopen the editor? "
"Do you want to open the editor again? (y/N) " (or error-msg
line) "Unknown error")))
(if (y-or-n-p (format "%s! Reopen the editor? " (process-send-string proc "y\n")
(or error-msg (process-send-string proc "n\n"))
"Unknown error"))) (setq error-msg (concat error-msg "\n" line)))))
(process-send-string proc "y\n")
(process-send-string proc "n\n"))))))
(with-editor-process-filter proc str t)) (with-editor-process-filter proc str t))
(defun khard-new (abook) (defun khard-new (abook)
@ -97,7 +96,7 @@ When called interactively, prompt for ABOOK."
:command :command
`("env" ,(concat "EDITOR=" with-editor-sleeping-editor) `("env" ,(concat "EDITOR=" with-editor-sleeping-editor)
"khard" "new" "--edit" "-a" ,abook) "khard" "new" "--edit" "-a" ,abook)
:buffer "*khard output*" :buffer " *khard output*"
:filter #'khard--new-process-filter :filter #'khard--new-process-filter
:sentinel #'khard--process-sentinel)))) :sentinel #'khard--process-sentinel))))
@ -109,7 +108,7 @@ When called interactively, prompt the user."
:command :command
`("env" ,(concat "EDITOR=" with-editor-sleeping-editor) `("env" ,(concat "EDITOR=" with-editor-sleeping-editor)
"khard" "edit" "--edit" ,(format "uid:%s" uid)) "khard" "edit" "--edit" ,(format "uid:%s" uid))
:buffer "*khard output*" :buffer " *khard output*"
:filter #'khard--new-process-filter :filter #'khard--new-process-filter
:sentinel #'khard--process-sentinel)) :sentinel #'khard--process-sentinel))