emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/ivy-hydra accc0fe 339/395: counsel.el (counsel-compile-


From: Basil L. Contovounesios
Subject: [elpa] externals/ivy-hydra accc0fe 339/395: counsel.el (counsel-compile--probe-make-targets): fail more gracefully
Date: Thu, 25 Feb 2021 08:32:33 -0500 (EST)

branch: externals/ivy-hydra
commit accc0fefe2c5a1dad092aa88a84128b0c5d0dfe7
Author: Alex Bennée <alex.bennee@linaro.org>
Commit: Alex Bennée <alex.bennee@linaro.org>

    counsel.el (counsel-compile--probe-make-targets): fail more gracefully
    
    Actually handing a empty list back isn't especially helpful because
    you might still get away with just calling make with the default
    target. Importantly without having a list you can't construct a
    command line of any sort with the build environment.
    
    While here better handle a potential failure from call-process
    returning a non-numeric code.
---
 counsel.el | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/counsel.el b/counsel.el
index 687de60..fb5a06c 100644
--- a/counsel.el
+++ b/counsel.el
@@ -6326,26 +6326,26 @@ list is passed to `compilation-environment'."
 (defvar counsel-compile-phony-pattern "^\\.PHONY:[\t ]+\\(.+\\)$"
   "Regexp for extracting phony targets from Makefiles.")
 
-;; This is loosely based on the Bash Make completion code
+;; This is loosely based on the Bash Make completion code which
+;; relies on GNUMake having the following return codes:
+;;   0 = no-rebuild, -q & 1 needs rebuild, 2 error
 (defun counsel-compile--probe-make-targets (dir)
   "Return a list of Make targets for DIR.
 
-Return an empty list is Make exits with an error.  This might
-happen because some sort of configuration needs to be done first
-or the source tree is pristine and being used for multiple build
-trees."
-  (let ((default-directory dir)
-        (targets nil))
-    (with-temp-buffer
-      ;; 0 = no-rebuild, -q & 1 needs rebuild, 2 error (for GNUMake at
-      ;; least)
-      (when (< (call-process "make" nil t nil "-nqp") 2)
+Return a single blank target (so we invoke the default target)
+if Make exits with an error.  This might happen because some sort
+of configuration needs to be done first or the source tree is
+pristine and being used for multiple build trees."
+  (with-temp-buffer
+    (let* ((default-directory dir)
+           (res (call-process "make" nil t nil "-nqp"))
+           targets)
+      (if (or (not (numberp res)) (> res 1))
+          (list "")
         (goto-char (point-min))
         (while (re-search-forward counsel-compile-phony-pattern nil t)
-          (setq targets
-                (nconc targets (split-string
-                                (match-string-no-properties 1)))))))
-    (sort targets #'string-lessp)))
+          (push (split-string (match-string-no-properties 1)) targets))
+        (sort (apply #'nconc targets) #'string-lessp)))))
 
 (defun counsel-compile--pretty-propertize (leader text face)
   "Return a pretty string of the form \" LEADER TEXT\".
@@ -6516,7 +6516,7 @@ handling for the counsel-compile metadata."
     (if (get-char-property 0 'cmd cmd)
         (insert (substring-no-properties
                  cmd 0 (next-single-property-change 0 'cmd cmd)))
-      (substring-no-properties last 0 end))))
+      (insert (substring-no-properties cmd)))))
 
 ;; Currently the only thing we do is override ivy's default insert
 ;; operation which doesn't include the metadata we want.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]