unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Kévin Le Gouguec" <kevin.legouguec@gmail.com>
To: Dmitry Gutov <dgutov@yandex.ru>
Cc: 45765@debbugs.gnu.org, Juri Linkov <juri@linkov.net>
Subject: bug#45765: [PATCH] 28.0.50; Change default-directory before prompting in project-compile
Date: Mon, 11 Jan 2021 22:24:31 +0100	[thread overview]
Message-ID: <87zh1fyxo0.fsf@gmail.com> (raw)
In-Reply-To: <01a19619-e48a-825f-b459-5b04df402ad6@yandex.ru> (Dmitry Gutov's message of "Mon, 11 Jan 2021 21:13:23 +0200")

[-- Attachment #1: Type: text/plain, Size: 391 bytes --]

Dmitry Gutov <dgutov@yandex.ru> writes:

> On 11.01.2021 20:35, Juri Linkov wrote:
>> But before rewriting with call-interactively,
>> we need to find a way to use project-compile in the init files, i.e.
>> to find a replacement for such configurations:
>>    <snip>
>
> Is it really possible to solve this without making project-compile a
> macro of some sort?

Something like this maybe?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Change-default-directory-before-prompting-in-project.patch --]
[-- Type: text/x-patch, Size: 1918 bytes --]

From 7d3ffd7f33276949669414ed4908ad8fee35dd93 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?K=C3=A9vin=20Le=20Gouguec?= <kevin.legouguec@gmail.com>
Date: Sun, 10 Jan 2021 10:43:41 +0100
Subject: [PATCH] Change default-directory before prompting in project-compile

This causes command completion to work from the project root, letting
users complete top-level folders, make targets, etc.

* lisp/progmodes/project.el (project-compile): Simplify using
call-interactively, as done with project(-aysnc)-shell-command.
---
 lisp/progmodes/project.el | 22 +++++++++-------------
 1 file changed, 9 insertions(+), 13 deletions(-)

diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 62c3cf44cb..dade8b4f1c 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -970,20 +970,16 @@ compilation-read-command
 (declare-function compilation-read-command "compile")
 
 ;;;###autoload
-(defun project-compile (command &optional comint)
+(defun project-compile (command &optional comint interactive)
   "Run `compile' in the project root.
-Arguments the same as in `compile'."
-  (interactive
-   (list
-    (let ((command (eval compile-command)))
-      (require 'compile)
-      (if (or compilation-read-command current-prefix-arg)
-	  (compilation-read-command command)
-	command))
-    (consp current-prefix-arg)))
-  (let* ((pr (project-current t))
-         (default-directory (project-root pr)))
-    (compile command comint)))
+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))))
 
 (defun project--read-project-buffer ()
   (let* ((pr (project-current t))
-- 
2.29.2


[-- Attachment #3: Type: text/plain, Size: 205 bytes --]


(Apologies if I misunderstood what Juri asked, or if my suggestion is
buggy)

We can also stick a "\(fn COMMAND &optional COMINT)" in the docstring if
we don't want to advertise the INTERACTIVE argument.

  reply	other threads:[~2021-01-11 21:24 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-10 12:57 bug#45765: [PATCH] 28.0.50; Change default-directory before prompting in project-compile Kévin Le Gouguec
2021-01-11  0:47 ` Dmitry Gutov
2021-01-11 18:35 ` Juri Linkov
2021-01-11 19:13   ` Dmitry Gutov
2021-01-11 21:24     ` Kévin Le Gouguec [this message]
2021-01-12 18:46       ` Juri Linkov
2021-01-13  1:06         ` Dmitry Gutov
2021-01-13 18:05           ` Juri Linkov
2021-01-13 19:46           ` Kévin Le Gouguec
2021-01-16  3:51             ` Dmitry Gutov
2021-01-19 17:38               ` Juri Linkov
2021-01-19 19:50                 ` Dmitry Gutov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87zh1fyxo0.fsf@gmail.com \
    --to=kevin.legouguec@gmail.com \
    --cc=45765@debbugs.gnu.org \
    --cc=dgutov@yandex.ru \
    --cc=juri@linkov.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).