unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#74631: 30.0.92; [PATCH] autoload project-recompile and set default-directory
@ 2024-12-01 10:46 Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2024-12-10  2:10 ` Dmitry Gutov
  0 siblings, 1 reply; 6+ messages in thread
From: Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2024-12-01 10:46 UTC (permalink / raw)
  To: 74631; +Cc: Dmitry Gutov

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

In order to make `project-recompile' symmetric to `recompile' it should
be autoloaded and it should run in the project root. This makes it
possible to call `project-recompile' directly without calling `compile'
first.

    ;;;###autoload
    (defun project-recompile (&optional edit-command)
      "Run `recompile' with appropriate buffer."
      (declare (interactive-only recompile))
      (interactive "P")
      (let ((default-directory (project-root (project-current t)))
            (compilation-buffer-name-function
             (or project-compilation-buffer-name-function
                 compilation-buffer-name-function)))
        (recompile edit-command)))

This change also resolves the comment in project-recompile:

    ;; Should we error instead?  When there's no
    ;; project-specific naming, there is no point in using
    ;; this command.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-project-recompile-Autoload-and-run-in-project-root.patch --]
[-- Type: text/x-diff, Size: 1355 bytes --]

From a330baaaf7a50f3bdf665b32efadb27283453f7f Mon Sep 17 00:00:00 2001
From: Daniel Mendler <mail@daniel-mendler.de>
Date: Sun, 1 Dec 2024 11:43:48 +0100
Subject: [PATCH] project-recompile: Autoload and run in project root

* lisp/progmodes/project.el (project-recompile): Autoload and
use project root as `default-directory'.
---
 lisp/progmodes/project.el | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index ba5a6b6f056..d47b732712f 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -1455,15 +1455,14 @@ project-compile
              compilation-buffer-name-function)))
     (call-interactively #'compile)))
 
+;;;###autoload
 (defun project-recompile (&optional edit-command)
   "Run `recompile' with appropriate buffer."
   (declare (interactive-only recompile))
   (interactive "P")
-  (let ((compilation-buffer-name-function
+  (let ((default-directory (project-root (project-current t)))
+        (compilation-buffer-name-function
          (or project-compilation-buffer-name-function
-             ;; Should we error instead?  When there's no
-             ;; project-specific naming, there is no point in using
-             ;; this command.
              compilation-buffer-name-function)))
     (recompile edit-command)))
 
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-12-10 23:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-01 10:46 bug#74631: 30.0.92; [PATCH] autoload project-recompile and set default-directory Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-10  2:10 ` Dmitry Gutov
2024-12-10  7:40   ` Juri Linkov
2024-12-10 23:27     ` Dmitry Gutov
2024-12-10 15:38   ` Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-12-10 23:29     ` Dmitry Gutov

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).