From 46400826eb5ddc4fd2d1f50e508cde4b3ae04d9e Mon Sep 17 00:00:00 2001 From: Daniel Borchmann Date: Wed, 24 Jan 2018 19:29:42 +0100 Subject: [PATCH] =?UTF-8?q?[EShell]=20Don=E2=80=99t=20barf=20if=20git=20co?= =?UTF-8?q?mmands=20cannot=20be=20found?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- site-lisp/db-eshell.el | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/site-lisp/db-eshell.el b/site-lisp/db-eshell.el index fff89b1..d0a97fb 100644 --- a/site-lisp/db-eshell.el +++ b/site-lisp/db-eshell.el @@ -62,17 +62,18 @@ (defun pcmpl-git-commands () "Return the most common git commands by parsing the git output." (with-temp-buffer - (call-process "git" nil (current-buffer) nil "help" "--all") - (goto-char 0) - (search-forward "available git commands in") - (let (commands) - (while (re-search-forward - "^[[:blank:]]+\\([[:word:]-.]+\\)[[:blank:]]*\\([[:word:]-.]+\\)?" - nil t) - (push (match-string 1) commands) - (when (match-string 2) - (push (match-string 2) commands))) - (sort commands #'string<)))) + (if (not (zerop (call-process "git" nil (current-buffer) nil "help" "--all"))) + (warn "Cannot call `git’ to obtain list of available commands; completion won’t be available.") + (goto-char 0) + (search-forward "available git commands in") + (let (commands) + (while (re-search-forward + "^[[:blank:]]+\\([[:word:]-.]+\\)[[:blank:]]*\\([[:word:]-.]+\\)?" + nil t) + (push (match-string 1) commands) + (when (match-string 2) + (push (match-string 2) commands))) + (sort commands #'string<))))) (defconst pcmpl-git-commands (pcmpl-git-commands) "List of `git' commands.")