From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Augusto Stoffel Newsgroups: gmane.emacs.bugs Subject: bug#70136: 30.0.50; compilation-mode [was: comint-mode] doesn't call hack-dir-local-variables-non-file-buffer Date: Sun, 14 Apr 2024 11:27:28 +0200 Message-ID: <87mspwcn0f.fsf_-_@gmail.com> References: <87zfuc48d5.fsf@gmail.com> <86msqc9dsa.fsf@gnu.org> <874jcjeuac.fsf@gmail.com> <86edbnajfp.fsf@gnu.org> 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="6628"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 70136@debbugs.gnu.org, Stefan Monnier To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Apr 14 11:28:04 2024 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 1rvw9c-0001aR-B0 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 14 Apr 2024 11:28:04 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rvw9S-00046y-FB; Sun, 14 Apr 2024 05:27:54 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rvw9Q-00046Y-Gg for bug-gnu-emacs@gnu.org; Sun, 14 Apr 2024 05:27:52 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rvw9Q-0005NX-7y for bug-gnu-emacs@gnu.org; Sun, 14 Apr 2024 05:27:52 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rvw9b-0006Z9-6G for bug-gnu-emacs@gnu.org; Sun, 14 Apr 2024 05:28:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Augusto Stoffel Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 14 Apr 2024 09:28:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70136 X-GNU-PR-Package: emacs Original-Received: via spool by 70136-submit@debbugs.gnu.org id=B70136.171308687025175 (code B ref 70136); Sun, 14 Apr 2024 09:28:03 +0000 Original-Received: (at 70136) by debbugs.gnu.org; 14 Apr 2024 09:27:50 +0000 Original-Received: from localhost ([127.0.0.1]:34308 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rvw9O-0006Xv-Au for submit@debbugs.gnu.org; Sun, 14 Apr 2024 05:27:50 -0400 Original-Received: from mail-ej1-x62b.google.com ([2a00:1450:4864:20::62b]:58614) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rvw9M-0006Wl-J3 for 70136@debbugs.gnu.org; Sun, 14 Apr 2024 05:27:49 -0400 Original-Received: by mail-ej1-x62b.google.com with SMTP id a640c23a62f3a-a5200202c1bso269934766b.0 for <70136@debbugs.gnu.org>; Sun, 14 Apr 2024 02:27:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713086852; x=1713691652; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=jstUUaQFYxoyRPplHgVYsT8sNGbyTxI8zUWVImqcJcw=; b=FyJfGDGv6StUHvuA2oTsmNqPyc8diN51cHbne+o6qbSqwFJleDoX4NvrPUkXKx1qHj vkskUK3hefsODJvsMLziX1xsSHGt1ZvJOVoo7MeAb2UgfkR5q0p0paEPscxl+5NRTO7F PvS2BRRmYf13r5HFg5IKUzSj8EZjWjQ7d2UYhwqLJCeUYtoUJPTGpILbeAm9CffdFsXq 7h07RRSqZQNMRuLXcdEOqk/UFfBKC5h0SCgOxAs3QUMhWpQLzaVDmWa8Hj9wPmWXWFhH YJwiMrMS99gFmDFCoNRE6lhT4Vr3WvsM31eApNw+EUJPXYh48/PCqSQWHRPoTle3Wf5r wXZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713086852; x=1713691652; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=jstUUaQFYxoyRPplHgVYsT8sNGbyTxI8zUWVImqcJcw=; b=Z0IiCrZdqAGKORb4Le7oTTfOHwvYyiKJ5b6rEKlLNig7DwA1sJE7vH2cKFPa4BKLbV esxbdX3WgqXY0kQCYakWUjD02UjEczMqWjdnZoANrC6RNtLHkc9+6JbJJdS1+fxftX5j HBSTM67PsSmqrp6O+4AdRetM0EP2CqF/0//XlPhYrMigI4It4+QvpKIHIzwAOzHMjiJy ZyNzDy8NsgmYM7zzcPzM1A44t3om5Yk/LztmF7fIgsHFVeinN40xsYDVF5IjNA6AzhBi b0lUtqKbwHkyXpwLPFH6nKGiL52U7lXioauu0TxN7hRzZ++mmBSDwc0qnRGRLzL/vf1o 3R4A== X-Gm-Message-State: AOJu0YzhePTifFQ26D+7kVzlbBD1NGNRZCDZNRUTH6dOHYXJr+nSXhoJ lHAZSnORdCnQDCC5yXwhhwv5TBPXZSQTH0bMCs93/+GfWGzEEBeR X-Google-Smtp-Source: AGHT+IHoqWZVz5RDyhmCSXfHTwOv/TfN9zaPu1AABVyTaTZUMcMVcCgFKXgVJE+vx3N3KgrythUcPQ== X-Received: by 2002:a17:906:d142:b0:a52:5e79:7970 with SMTP id br2-20020a170906d14200b00a525e797970mr850693ejb.15.1713086851521; Sun, 14 Apr 2024 02:27:31 -0700 (PDT) Original-Received: from ars3 ([2a02:8109:8a87:ff00::6223]) by smtp.gmail.com with ESMTPSA id go36-20020a1709070da400b00a51fea47897sm3980439ejc.214.2024.04.14.02.27.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Apr 2024 02:27:29 -0700 (PDT) In-Reply-To: <86edbnajfp.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 02 Apr 2024 18:11:22 +0300") 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:283263 Archived-At: --=-=-= Content-Type: text/plain Since compilation buffers go as far as to print the directory they're running on at the top of the buffer, I think it's pretty clear they should receive dir-local variables. So I'd suggest the attached patch, which does that and also removes a more limited mechanism I added some time ago to allow compilation with project-specific settings. I've CC'ed Stefan since at the time he kind of supported the changes I'm now suggesting to remove. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Add-dir-local-variables-to-compilation-buffers.patch >From e29f1849c278ebf55aa67470b5f35263ecf989f3 Mon Sep 17 00:00:00 2001 From: Augusto Stoffel Date: Sun, 14 Apr 2024 11:07:02 +0200 Subject: [PATCH] Add dir-local variables to compilation buffers * lisp/progmodes/compile.el (compilation-mode): Arrange for dir-local variables to be hacked into to non-file compilation buffers. (compilation-start): Remove a less flexible solution to set up the compilation environment (cf. discussion in bug#50607). --- lisp/progmodes/compile.el | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el index b18eb81fee1..f81c1edb8c3 100644 --- a/lisp/progmodes/compile.el +++ b/lisp/progmodes/compile.el @@ -1929,9 +1929,6 @@ compilation-start (replace-regexp-in-string "-mode\\'" "" (symbol-name mode)))) (thisdir default-directory) (thisenv compilation-environment) - (buffer-path (and (local-variable-p 'exec-path) exec-path)) - (buffer-env (and (local-variable-p 'process-environment) - process-environment)) outwin outbuf) (with-current-buffer (setq outbuf @@ -2004,12 +2001,6 @@ compilation-start ;; NB: must be done after (funcall mode) as that resets local variables (setq-local compilation-directory thisdir) (setq-local compilation-environment thisenv) - (if buffer-path - (setq-local exec-path buffer-path) - (kill-local-variable 'exec-path)) - (if buffer-env - (setq-local process-environment buffer-env) - (kill-local-variable 'process-environment)) (if highlight-regexp (setq-local compilation-highlight-regexp highlight-regexp)) (if (or compilation-auto-jump-to-first-error @@ -2372,6 +2363,11 @@ compilation-mode ;; some other input event happens. (setq-local jit-lock-defer-time nil) (setq buffer-read-only t) + (unless (buffer-file-name) + (let ((sym (make-symbol "hack-dir-local-variables-non-file-buffer"))) + (set sym #'hack-dir-local-variables-non-file-buffer) + ;; Ensure hack-dir-locals is called only after a derived mode is set. + (push sym delayed-mode-hooks))) (run-mode-hooks 'compilation-mode-hook)) ;;;###autoload -- 2.44.0 --=-=-=--