From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?K=C3=A9vin?= Le Gouguec Newsgroups: gmane.emacs.bugs Subject: bug#45765: [PATCH] 28.0.50; Change default-directory before prompting in project-compile Date: Sun, 10 Jan 2021 13:57:07 +0100 Message-ID: <87bldx2bmk.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="14650"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Juri Linkov To: 45765@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Jan 10 13:58:10 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kyaIM-0003hT-OC for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 10 Jan 2021 13:58:10 +0100 Original-Received: from localhost ([::1]:47218 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kyaIL-0000O4-Az for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 10 Jan 2021 07:58:09 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52904) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyaIE-0000Nv-HK for bug-gnu-emacs@gnu.org; Sun, 10 Jan 2021 07:58:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:41842) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kyaIE-0005CL-AE for bug-gnu-emacs@gnu.org; Sun, 10 Jan 2021 07:58:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kyaIE-00040b-7U for bug-gnu-emacs@gnu.org; Sun, 10 Jan 2021 07:58:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?K=C3=A9vin?= Le Gouguec Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 10 Jan 2021 12:58:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 45765 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.161028343615340 (code B ref -1); Sun, 10 Jan 2021 12:58:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 10 Jan 2021 12:57:16 +0000 Original-Received: from localhost ([127.0.0.1]:53388 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kyaHT-0003zL-WA for submit@debbugs.gnu.org; Sun, 10 Jan 2021 07:57:16 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:41352) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kyaHS-0003zD-4Q for submit@debbugs.gnu.org; Sun, 10 Jan 2021 07:57:14 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52750) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyaHR-0000Jq-SE for bug-gnu-emacs@gnu.org; Sun, 10 Jan 2021 07:57:13 -0500 Original-Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]:54011) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kyaHO-0004v6-Pk for bug-gnu-emacs@gnu.org; Sun, 10 Jan 2021 07:57:13 -0500 Original-Received: by mail-wm1-x329.google.com with SMTP id k10so11542380wmi.3 for ; Sun, 10 Jan 2021 04:57:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version; bh=/XNALqb9AJIIfM0uAz6pRRZ3l/wDmNdnRViBDEReXzA=; b=MxGWEuw7Tw99+BqwDKSfVJWWnmW5vUqLrAPQ2xgABla08UebflIFafMltEPr8igfn1 zMfD/GCwQ6xoFxUSVUNxbKQ4GG1qNRj7QH1e1XLqahVi89PzBF3fdJw8h24xdZtawtIk 0x5EP4osU+E7GqfhM7DVI+VAKxtxqPEh896lVMCEYlHO4gbVCF7e9xDRT0uDEqYMppvd C3WbtLwHKWFJXfGW8oChu/5ZaWkIXNRF0qSES+UTiNEQQAiobxDP3AJnk1VAzmuFEQqo lxLPBgyG1jsJbp18ajL7Pzc798kaBJ2rJn2OuK7MMHIrokX7eNJ30kMKDcZauX+JFfho qXyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version; bh=/XNALqb9AJIIfM0uAz6pRRZ3l/wDmNdnRViBDEReXzA=; b=aLyK48NNbZDSH+TVoPnvWoSJqu9QsEEisFKdMNbTrps7xeESebWvB0aHL89xpS9REx rRz69yMraLxRUzaR79I8eVOXh1GzJkKl4HO1pOzBi7H8bmNZb7jd0Uw3Tx5Odvwd24iz zzbUmOFIYV7lA/FpJPgVWXkSzLwokCxmRnz2swChg2mjN7Eny1awfgM3ras91FT1R9q/ lPSA0Nhm8Y5LIjQ4umCRD33eEhe32WPq+sJHwJqNGWipKcuZzVh5DsmWMBLORUoSDqjU cfZYJMgAmAaBKndqZzSd6vMLXmQN1Al4ZVT5ifLgui5OCjm3FD6s9/OlrlNyS/EN6urh +uEw== X-Gm-Message-State: AOAM5306D4DJHjx/IqgrebV3Eg9OcnUTmVQMjbiExN10wqlle10ofJSY 6XNAKpTWCV8aqFjN+bkyRv8= X-Google-Smtp-Source: ABdhPJzfvGAqBccKVfAMJxWlzLmyKbnZDkNNaID8//OFVOuVbNW9FEZyjWMA8yWlRyIoA550EI+KZg== X-Received: by 2002:a7b:cc90:: with SMTP id p16mr10396628wma.105.1610283428900; Sun, 10 Jan 2021 04:57:08 -0800 (PST) Original-Received: from my-little-tumbleweed ([2a01:e0a:20e:d340:922b:34ff:fe95:9aed]) by smtp.gmail.com with ESMTPSA id m8sm19480671wmc.27.2021.01.10.04.57.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Jan 2021 04:57:07 -0800 (PST) Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=kevin.legouguec@gmail.com; helo=mail-wm1-x329.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:197600 Archived-At: --=-=-= Content-Type: text/plain Hello, Unlike project-shell-command, project-compile first prompts for a command, then binds default-directory and calls compile. Binding default-directory first makes completion work from the project root, which is useful for completing on filenames relative to the root, on targets from the toplevel Makefile, etc. I see three ways to achieve this: (1) Rewrite project-compile with call-interactively, the way project-shell-command is written (see patch #1). (2) Set COMMAND to nil in the interactive spec, then prompt for it after binding default-directory (see patch #2). (3) Let-binding default-directory once in the interactive spec, and again before calling compile. I'm assuming (1) is out of the question, given 2020-06-02 "* lisp/progmodes/project.el (project-vc-dir, project-shell): New commands." (2c1e5b9e77). I'm CC'ing Juri to get his opinion though; project-compile is new in Emacs 28.1, so its argument list is not yet set in stone. I've taken a stab at (2), but my patch changes the semantics of COMMAND for an edge case: for now calling (project-compile nil) from Lisp causes (compile nil) to be called (which errors out); with my patch, (project-compile nil) yields a prompt. This can be solved using called-interactively-p (or using an optional INTERACTIVE argument); I just don't know if it's worth the hassle? I haven't given much thought to (3), so I haven't yet figured out how to avoid prompting twice for the project (on the rare occasions where prompting is needed). Thanks for your time. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Change-default-directory-before-prompting-in-project-1.patch >From 801311cef5a825af93a41cc044b4f753b648a866 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Le=20Gouguec?= 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 | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index 62c3cf44cb..06966f33b7 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -970,20 +970,11 @@ compilation-read-command (declare-function compilation-read-command "compile") ;;;###autoload -(defun project-compile (command &optional comint) - "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))) +(defun project-compile () + "Run `compile' in the project root." + (interactive) + (let ((default-directory (project-root (project-current t)))) + (call-interactively #'compile))) (defun project--read-project-buffer () (let* ((pr (project-current t)) -- 2.29.2 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Change-default-directory-before-prompting-in-project-2.patch >From b1b10d01a83b2b07a27ce6bcf12cf000fabaf22a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Le=20Gouguec?= Date: Sun, 10 Jan 2021 13:18:07 +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): Read command after binding default-directory to project root. --- lisp/progmodes/project.el | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index 62c3cf44cb..1e7f6d7c06 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -974,15 +974,17 @@ project-compile "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))) + (list nil + (consp current-prefix-arg))) + ;; Bind `default-directory' before prompting for COMMAND, so that + ;; command completion works from the project root. + (let ((default-directory (project-root (project-current t))) + (command (or command + (let ((command (eval compile-command))) + (require 'compile) + (if (or compilation-read-command current-prefix-arg) + (compilation-read-command command) + command))))) (compile command comint))) (defun project--read-project-buffer () -- 2.29.2 --=-=-= Content-Type: text/plain In GNU Emacs 28.0.50 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.24, cairo version 1.16.0) of 2021-01-04 built on my-little-tumbleweed Repository revision: 2c847902522ae74c9b25b2a3fa60565e0187fd0a Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.12010000 System Description: openSUSE Tumbleweed Configured using: 'configure --with-xwidgets --with-cairo' Configured features: XPM JPEG TIFF GIF PNG RSVG CAIRO SOUND GPM DBUS GSETTINGS GLIB NOTIFY INOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE HARFBUZZ M17N_FLT LIBOTF ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM MODULES THREADS XWIDGETS JSON PDUMPER LCMS2 Important settings: value of $LC_CTYPE: en_US.UTF-8 value of $LC_TIME: en_GB.UTF-8 value of $LANG: en_US.UTF-8 value of $XMODIFIERS: @im=local locale-coding-system: utf-8-unix --=-=-=--