From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?Cl=c3=a9ment_Pit-Claudel?= Newsgroups: gmane.emacs.devel Subject: Re: Add a separate mode for .dir-locals.el Date: Sat, 19 Oct 2019 08:53:23 -0400 Message-ID: <7f141905-6be3-2c21-e2af-b5926dd80223@gmail.com> References: <2058328b-aee5-8cb1-2659-a793e1354517@mit.edu> <835zkndcz4.fsf@gnu.org> <83ftjrbjhm.fsf@gnu.org> <83ftjr9sx4.fsf@gnu.org> <83eezb9s5b.fsf@gnu.org> <83bluf9qgb.fsf@gnu.org> <835zkn9o01.fsf@gnu.org> <83lfti8ovn.fsf@gnu.org> <83d0eu8c80.fsf@gnu.org> <83lfth6p0y.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="209729"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 Cc: monnier@iro.umontreal.ca, emacs-devel@gnu.org To: Eli Zaretskii , =?UTF-8?B?Sm/Do28gVMOhdm9yYQ==?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Oct 19 14:53:35 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iLoEg-000sLv-Vk for ged-emacs-devel@m.gmane.org; Sat, 19 Oct 2019 14:53:35 +0200 Original-Received: from localhost ([::1]:54162 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iLoEf-0006wz-E6 for ged-emacs-devel@m.gmane.org; Sat, 19 Oct 2019 08:53:33 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35390) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iLoEZ-0006ws-HS for emacs-devel@gnu.org; Sat, 19 Oct 2019 08:53:28 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iLoEX-0004vR-Vo for emacs-devel@gnu.org; Sat, 19 Oct 2019 08:53:27 -0400 Original-Received: from mail-qt1-x830.google.com ([2607:f8b0:4864:20::830]:41737) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iLoEX-0004uq-RZ; Sat, 19 Oct 2019 08:53:25 -0400 Original-Received: by mail-qt1-x830.google.com with SMTP id c17so10309839qtn.8; Sat, 19 Oct 2019 05:53:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=bFbOF2P7tbeBbXODozrwCImowD0hn+GSDjSIIPIFUBI=; b=acMvJamkL/vjLSB2icOFZ3HcslxP6ZEnCfCpC8bgpsXP/jzyoPAU/LLBxKQ0/A9Zba rWlx4Fni+cYZ2Ayvyvrp0CidU6FtF4DMMvwFXw2W+6ghPoOpnOCnQWsCb0CznV0gyJvC YUlBZg4phxVEBUMkuT3TDbMwFOlqbuk52jeEssuz037G0tOTr7zl4Tln2uvmEz8Ol8uG eoVxl8lOv+ev1l+aJVyaOCwHfYs1nxJn3pOz4nzNjxL5M53sX2ipoSIbkq6ZEFWbNVJR SOKAHByOGc7SbigIenvyaEG/GwOy3zQbbqtA4U4vncSRgnfrfrPVT/HdLauiN9BqwvG2 ICDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=bFbOF2P7tbeBbXODozrwCImowD0hn+GSDjSIIPIFUBI=; b=fsas8FY+v3lQOwDfPR9xBNQuWihIuLHIWrxc0jsH0RRXKiZaOM5KMPw3IUxQFEQiMl JB6VlsaeBlqjHJCWM0t3CAPyUBxPOIs5eRuFdr+u4Xg2VCaORQR9fJW+dSWILda0C98x zuSqcAlvn5tCfk5v6zLxBaw+uBswURCQN8VeBXeRZnbkWbMwZNN2C/nEseFxyfa3hNOa Gb4LgrFX7Imva8MF500EnlnsdavYaC3KyMM2yaE9xS+FlyP2zfm3/P0WDHLZfH57kiHN /AxydjvncCCplN1EkVsJcaWLZKnanDG9ww89rHWil1CBq93J9c0YaQuRBhe6hfsAuF+J sdkQ== X-Gm-Message-State: APjAAAUAqiuCcTIb4es/nb/oP016OOesG3UJ6O6etTgn2HxqMlJCCPpA mxL9A8ftrYAFXBtprq3vde1CKZpL X-Google-Smtp-Source: APXvYqzh0GDFHFevMpEox/UYliI9cWDaMuBab7fE1QUA4aY1hm+fNk82wdpnOVWw6DhbvjpRhLSw/A== X-Received: by 2002:ac8:6c4:: with SMTP id j4mr15425080qth.237.1571489604705; Sat, 19 Oct 2019 05:53:24 -0700 (PDT) Original-Received: from ?IPv6:2601:184:4180:66e7:29f4:b2db:5f83:f6d2? ([2601:184:4180:66e7:29f4:b2db:5f83:f6d2]) by smtp.googlemail.com with ESMTPSA id j2sm4895313qki.15.2019.10.19.05.53.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 19 Oct 2019 05:53:24 -0700 (PDT) In-Reply-To: <83lfth6p0y.fsf@gnu.org> Content-Language: en-GB X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::830 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:241227 Archived-At: On 2019-10-19 05:52, Eli Zaretskii wrote: > Clément, you've reported the original problem, so could you please > tell more details about it? What triggers the problem, and how does > it manifest itself to the user? Is it just due to an attempt to > byte-compile .dir-locals.el, or is it due to something else Flymake > does? Thanks. Hi Eli, Yes, I can describe in more details. In fact, I was first made aware of the problem while working on Flycheck, and noticed that it appeared in Flymake too. Over the years, we've had multiple user complaints that opening .dir-locals.el files in Flycheck cause spurious warnings to appear (e.g. https://github.com/flycheck/flycheck/issues/908). This is because Flycheck, like Flymake, tries to byte-compile these files, and runs checkdoc on them. Both of these return spurious warnings. Flycheck tries to run the byte-compiler and checkdoc because of the major-mode in which .dir-locals.el files are opened. The reasoning is that, if these files are Emacs Lisp files, then they should conform to Emacs Lisp coding conventions: they should include proper headers, licenses, a `provide' form at the end, etc. This is how Flycheck works in general: each checker is enabled by one or multiple major modes. Flymake works in a slightly different fashion: major modes add local hooks to run the relevant checkers. Of course, .dir-locals.el are not proper Emacs Lisp files, and as a result both the byte compiler and checkdoc produce spurious warnings — but Flycheck doesn't know that, since it relies on the current major mode to decide which checkers to run. One workaround is to change Flycheck to pattern match on the name of the current file in addition to its major mode, so that .dir-locals.el files are not checked. This is the solution that I will apply if we decide against introducing a separate mode for dir-locals.el. On the Flymake side, the definition of emacs-lisp-mode would check the name of the current file, and only add the relevant Flymake hooks if the current file isn't called .dir-locals.el. My motivation for proposing a separate mode was that we already have a mechanism (atuo-mode-alist) to attach specific behaviors to specific file names, so it seemed natural to reuse that mechanism to run different code for regular ELisp files and dir-locals files. IOW, I thought it was an anti-pattern to do file-name checks in a major-mode definition. Finally, what motivated me to propose a split was the fact that a fix was needed in two places (Flymake and Flycheck), and likely in others (company and completion-at-point-functions should ideally work differently in .dir-locals.el; imenu doesn't make much sense there, ELisp syntax-highlighting is sub-optimal for these files outside of `eval' forms, etc.). Thanks for your patience and your dedication, Clément.