>From 6e192d6bb5c2c8c3565df14505b15327fb061d48 Mon Sep 17 00:00:00 2001 From: "Basil L. Contovounesios" Date: Wed, 25 Oct 2017 16:22:06 +0100 Subject: [PATCH 2/2] * lisp/simple.el (shell-command): Simplify cond with pcase --- lisp/simple.el | 54 +++++++++++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/lisp/simple.el b/lisp/simple.el index 96f5a321f3..147cc34646 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -3497,33 +3497,33 @@ shell-command ;; Ask the user what to do with already running process. (setq proc (get-buffer-process buffer)) (when proc - (cond - ((eq async-shell-command-buffer 'confirm-kill-process) - ;; If will kill a process, query first. - (if (yes-or-no-p "A command is running in the default buffer. Kill it? ") - (kill-process proc) - (error "Shell command in progress"))) - ((eq async-shell-command-buffer 'confirm-new-buffer) - ;; If will create a new buffer, query first. - (if (yes-or-no-p "A command is running in the default buffer. Use a new buffer? ") - (setq buffer (generate-new-buffer name)) - (error "Shell command in progress"))) - ((eq async-shell-command-buffer 'new-buffer) - ;; It will create a new buffer. - (setq buffer (generate-new-buffer name))) - ((eq async-shell-command-buffer 'confirm-rename-buffer) - ;; If will rename the buffer, query first. - (if (yes-or-no-p "A command is running in the default buffer. Rename it? ") - (progn - (with-current-buffer buffer - (rename-uniquely)) - (setq buffer (get-buffer-create name))) - (error "Shell command in progress"))) - ((eq async-shell-command-buffer 'rename-buffer) - ;; It will rename the buffer. - (with-current-buffer buffer - (rename-uniquely)) - (setq buffer (get-buffer-create name))))) + (pcase async-shell-command-buffer + ('confirm-kill-process + ;; If will kill a process, query first. + (if (yes-or-no-p "A command is running in the default buffer. Kill it? ") + (kill-process proc) + (error "Shell command in progress"))) + ('confirm-new-buffer + ;; If will create a new buffer, query first. + (if (yes-or-no-p "A command is running in the default buffer. Use a new buffer? ") + (setq buffer (generate-new-buffer name)) + (error "Shell command in progress"))) + ('new-buffer + ;; It will create a new buffer. + (setq buffer (generate-new-buffer name))) + ('confirm-rename-buffer + ;; If will rename the buffer, query first. + (if (yes-or-no-p "A command is running in the default buffer. Rename it? ") + (progn + (with-current-buffer buffer + (rename-uniquely)) + (setq buffer (get-buffer-create name))) + (error "Shell command in progress"))) + ('rename-buffer + ;; It will rename the buffer. + (with-current-buffer buffer + (rename-uniquely)) + (setq buffer (get-buffer-create name))))) (with-current-buffer buffer (shell-command--save-pos-or-erase) (setq default-directory directory) -- 2.14.2