From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: Two problems with directory-local variables Date: Thu, 20 Sep 2018 01:38:35 +0300 Organization: LINKOV.NET Message-ID: <874leldw44.fsf@mail.linkov.net> References: <87a7ogzgul.fsf@mbork.pl> <1d2129643cecde529cb9b47e4e015c48@webmail.orcon.net.nz> <87y3c0xh44.fsf@mbork.pl> <87k1njyav9.fsf@mail.linkov.net> <475f19d58094495c2a56d829bb7bbdd5@webmail.orcon.net.nz> <87sh27eizs.fsf@mail.linkov.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1537399436 12065 195.159.176.226 (19 Sep 2018 23:23:56 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 19 Sep 2018 23:23:56 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Sep 20 01:23:52 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1g2lp2-000335-4U for ged-emacs-devel@m.gmane.org; Thu, 20 Sep 2018 01:23:52 +0200 Original-Received: from localhost ([::1]:47667 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g2lr8-0007UO-QN for ged-emacs-devel@m.gmane.org; Wed, 19 Sep 2018 19:26:02 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53792) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g2lq7-0007Tc-0L for emacs-devel@gnu.org; Wed, 19 Sep 2018 19:24:59 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g2lq3-0005k9-Gx for emacs-devel@gnu.org; Wed, 19 Sep 2018 19:24:58 -0400 Original-Received: from pop.dreamhost.com ([64.90.62.162]:60632 helo=pdx1-sub0-mail-a11.g.dreamhost.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1g2lq3-0005fd-0z for emacs-devel@gnu.org; Wed, 19 Sep 2018 19:24:55 -0400 Original-Received: from pdx1-sub0-mail-a11.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a11.g.dreamhost.com (Postfix) with ESMTP id 61F0C8007B; Wed, 19 Sep 2018 16:24:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=linkov.net; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=linkov.net; bh=VNxIY0XfE2Gw563pWk5UjM1LQjw=; b= EFvcIpW4Um4ykr4BcVMdIII/V0Ov3HgnXA7lIQLrMzu3X51iZYP1rIeH22l1wejg cDsqEu8gUnViNgtbsr08lxVtFqxk1H0YcdGyMv+bJr/XHofz1DwYo57S0Yl5SPBB 6pLQHeuMl9soEaRdhOvadPIxIsoKDN6s6TzlAkMdNuM= Original-Received: from localhost.linkov.net (m91-129-107-237.cust.tele2.ee [91.129.107.237]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: jurta@jurta.org) by pdx1-sub0-mail-a11.g.dreamhost.com (Postfix) with ESMTPSA id 67ACD7E530; Wed, 19 Sep 2018 16:24:51 -0700 (PDT) X-DH-BACKEND: pdx1-sub0-mail-a11 X-DH-BACKEND: pdx1-sub0-mail-a11 In-Reply-To: (Stefan Monnier's message of "Mon, 17 Sep 2018 22:15:07 -0400") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 64.90.62.162 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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:229972 Archived-At: >>> On this note, while I don't use the commands myself, I've often wished >>> that add-dir-local-variable would generate the dotted-pair syntax, >>> because I've often seen confusion about the syntax of dir-locals arising >>> from dotted vs non-dotted possibilities, and I feel strongly that the >>> dotted syntax is the most readable for these files. > > Agreed. We should probably have a `print-alist` kind of function for > that purpose and then try and make use of it from add-dir-local-variable. > >> I don't know if something exists that could allow printing dotted syntax for >> >> (pp-to-string '(eval message "hello")) >> >> In its implementation I see the references to print-escape-newlines >> and print-quoted, but there is no print-dotted. > > I don't think we could add a print-dotted because as you say we don't > want (eval . (message . ("hello" . nil))) and only the human coder can > know which cons cell should be printed dotted and which shouldn't. Examples in (info "(emacs) Directory Variables") recommend dotted syntax for alists on the first level: ((nil . ((indent-tabs-mode . t) (fill-column . 80))) (c-mode . ((c-file-style . "BSD") (subdirs . nil)))) as well as for the second level: (("src/imported" . ((nil . ((change-log-default-name . "ChangeLog.local")))))) Taking into account the original problematic case with `eval', dotted alist should be also on the third level: (("src/imported" . ((nil . ((eval . (message "hello"))))))) Given that, I don't see what would be a good choice for generalization: 1. Since requirements for this feature are too vague, it doesn't seem to fit well into low-level printing functions. 2. Reformatting the printed output in pp-buffer to add dots where necessary also doesn't look like an elegant solution. 3. Implementing print-alist poses a question how to define at which levels to print alists with dotted syntax. 4. Since only add-dir-local-variable knows the semantics of used data structures, the simplest way would be to implement printing of each level explicitly in add-dir-local-variable.