[EShell] Don’t barf if git commands cannot be found

This commit is contained in:
Daniel - 2018-01-24 19:29:42 +01:00
parent e7ab32951b
commit 46400826eb
Signed by: dbo
GPG Key ID: 4F63DB96D45AA9C6
1 changed files with 12 additions and 11 deletions

View File

@ -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 wont 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.")