bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#45765: [PATCH] 28.0.50; Change default-directory before prompting in


From: Dmitry Gutov
Subject: bug#45765: [PATCH] 28.0.50; Change default-directory before prompting in project-compile
Date: Wed, 13 Jan 2021 03:06:37 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0

Hi Juri,

On 12.01.2021 20:46, Juri Linkov wrote:
Something like this maybe?

+(defun project-compile (command &optional comint interactive)
+COMMAND and COMINT work as with `compile'.  When calling this
+function from Lisp, you can pretend that it was called
+interactively by passing a non-nil INTERACTIVE argument."
+  (interactive (list nil nil t))
+  (let ((default-directory (project-root (project-current t))))
+    (if interactive
+        (call-interactively #'compile)
+      (compile command comint))))

(Apologies if I misunderstood what Juri asked, or if my suggestion is
buggy)
Perfect, thank you for finding the middle ground for different needs.

So you're not worried about compilation-read-command in your code being called in the wrong directory (exhibiting what the current bug report aims to fix)?

I think you might as well inline the definition, it's almost as short:

(define-key my-map "m" ;; mnemonics "make"
    (lambda ()
      (interactive)
      (let ((default-directory (project-root (project-current t))))
        (compile
         ;; Use previous command from history
         ;; instead of the default from compile-command
         (compilation-read-command (car compile-history))
         ;; Don't use compilation-shell-minor-mode
         nil))))

But if you really like the new version of project-compile, OK.

I'm not a big fan of the 'interactive' argument. It could be replaced by using (called-interactively-p 'interactive), though I'm not sure how idiomatic that is.





reply via email to

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