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

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

[elpa] master b65cdb5 274/399: counsel.el (counsel-compile): track build


From: Oleh Krehel
Subject: [elpa] master b65cdb5 274/399: counsel.el (counsel-compile): track build dir for the benefit of M-i
Date: Sat, 20 Jul 2019 14:57:39 -0400 (EDT)

branch: master
commit b65cdb52aac4e2fbff0629c0d3f7e72cc927abcd
Author: Alex Bennée <address@hidden>
Commit: Oleh Krehel <address@hidden>

    counsel.el (counsel-compile): track build dir for the benefit of M-i
    
    We can't recover the current build directory when the user invokes M-i
    so let's track it in a variable. The user still has to delete the
    extra verbiage but at least won't be surprised about where the command
    is run.
    
    Fixes #2077
---
 counsel.el | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/counsel.el b/counsel.el
index c56487b..10b2390 100644
--- a/counsel.el
+++ b/counsel.el
@@ -5498,6 +5498,12 @@ This is determined by `counsel-compile-local-builds', 
which see."
                          `(srcdir ,srcdir blddir ,blddir bldenv ,bldenv) cmd)
     (add-to-history 'counsel-compile-history cmd)))
 
+(defvar counsel-compile--current-build-dir nil
+  "Tracks the last directory `counsel-compile' was called with.
+
+This state allows us to set it correctly if the user has manually
+edited the command loosing our embedded state.")
+
 (defun counsel-compile--action (cmd)
   "Process CMD to call `compile'.
 
@@ -5511,7 +5517,9 @@ specified by the `blddir' property."
       (when (get-char-property 0 'cmd cmd)
         (setq cmd (substring-no-properties
                    cmd 0 (next-single-property-change 0 'cmd cmd))))
-      (let ((default-directory (or blddir default-directory))
+      (let ((default-directory (or blddir
+                                   counsel-compile--current-build-dir
+                                   default-directory))
             (compilation-environment bldenv))
         ;; No need to specify `:history' because of this hook.
         (add-hook 'compilation-start-hook #'counsel-compile--update-history)
@@ -5523,6 +5531,7 @@ specified by the `blddir' property."
 (defun counsel-compile (&optional dir)
   "Call `compile' completing with smart suggestions, optionally for DIR."
   (interactive)
+  (setq counsel-compile--current-build-dir (or dir default-directory))
   (ivy-read "Compile command: "
             (counsel--get-compile-candidates dir)
             :action #'counsel-compile--action



reply via email to

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