From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Thibaut Verron Newsgroups: gmane.emacs.help Subject: Re: don't understand setq-default Date: Mon, 19 Apr 2021 14:49:02 +0200 Message-ID: <296fa68b-c0ca-a3a8-e19f-1a8c85726e75@gmail.com> References: <87mttvx1lo.fsf@zoho.eu> <87eef7ycd9.fsf@omarpolo.com> <87blabww2u.fsf@zoho.eu> <877dkzww0r.fsf@zoho.eu> <8735vnwu8z.fsf@zoho.eu> <87blaby6xx.fsf@omarpolo.com> <87lf9fkm6l.fsf@zoho.eu> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24443"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.7.1 To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Mon Apr 19 14:50:36 2021 Return-path: Envelope-to: geh-help-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 1lYTMK-0006Dx-K9 for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 19 Apr 2021 14:50:36 +0200 Original-Received: from localhost ([::1]:33634 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lYTMJ-0002sY-N5 for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 19 Apr 2021 08:50:35 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:37470) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lYTKu-0002qG-0M for help-gnu-emacs@gnu.org; Mon, 19 Apr 2021 08:49:08 -0400 Original-Received: from mail-ej1-x636.google.com ([2a00:1450:4864:20::636]:38657) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lYTKs-0004Va-73 for help-gnu-emacs@gnu.org; Mon, 19 Apr 2021 08:49:07 -0400 Original-Received: by mail-ej1-x636.google.com with SMTP id r12so52744543ejr.5 for ; Mon, 19 Apr 2021 05:49:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=5UqWeYTv4ZsSVEl5NRG7FBOoz1vK6yA6yK0gTpcVDOk=; b=L6JrH1LE0J5+x6SfULFMtyeQUf0wwtQcIH5TAYHYEN2xFJary0O7YAQbvBeDwA8RgD 1kjQRnryWL3x7WGIcJWMqaw+vncK6QE9fN31vmGL0dEMquw3mlOLteFCwGnOhfQyVNWF PCvKwlSzH5mkNctnxLzM7ko9/9CpK6aioj9kBFGOQsVLexMks2TsdEy+rLizgkTs2VJX il9Ipn8wQnWKUtIf43RnIDnfNfNklHT5uoaJIpbIe4nCVHiS6vYQ6mmtu7cwBDDCMvey 8BrifZ7ih9RcMQPKMOSj/L+j5aieKYtDa+xsa+1MdDq+8DCo2V+aORI3kFGfKfnsIYJr LGJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=5UqWeYTv4ZsSVEl5NRG7FBOoz1vK6yA6yK0gTpcVDOk=; b=RxymB3EfRKfupH/XiYAsQ3bn/JQlgLXtZUo1UsWsgM0j9hWMGVtg0iS9Z/W+G9++20 vepDSUtIgAx+6VmJWtzuwiYD4fU27bl2MPe+pY1clUjUZXg63sBfC/s+Mny1ZVNvDiUL W7RpkbI4r3qgUGbKBgFZ4Q+jP7plvsAZBYhs7/fq3xxyLhX9R/ytSIg7ekKa3eR8dGbZ Oh/soI5ZbcGQ4ZiYoJLYdMYTixbFezdryMkE4LjSEfvO9Ch5EHCkq9G7SY+t+WIjlnMf OiLz49QLZfnfLsKhzefjJSt4uA0sKkHr1i5+3wGGUMzLtueThsLCyAkrwv+NXYIHp8cb FMww== X-Gm-Message-State: AOAM531hq3aAwb+RL+SVj22v2mh66M0n7GPu4fTDdCucvrPi/N6D5JpL /a0xgOKySJx6fZGecJcVON6ZnLepJx5Tc+LhLpA= X-Google-Smtp-Source: ABdhPJxAjdvMekyq8Fs8bANC5C5CLQkRRxoimSt8Zv+eaQlpXhu0mGtOhC78uhiZpSi7e5zclxGrWg== X-Received: by 2002:a17:907:984d:: with SMTP id jj13mr21656896ejc.45.1618836544036; Mon, 19 Apr 2021 05:49:04 -0700 (PDT) Original-Received: from [192.168.2.103] (dslb-088-066-248-118.088.066.pools.vodafone-ip.de. [88.66.248.118]) by smtp.googlemail.com with ESMTPSA id ws15sm10462477ejb.38.2021.04.19.05.49.03 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 19 Apr 2021 05:49:03 -0700 (PDT) In-Reply-To: <87lf9fkm6l.fsf@zoho.eu> Content-Language: en-US Received-SPF: pass client-ip=2a00:1450:4864:20::636; envelope-from=thibaut.verron@gmail.com; helo=mail-ej1-x636.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, NICE_REPLY_A=-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: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:129074 Archived-At: On 2021-04-19 5:06 a.m., Emanuel Berg via Users list for the GNU Emacs text editor wrote: > So the pecking order is: > local var > global var > local default > global default > I'm not sure if that's a good way to look at it. A global variable has a (global) value. You can give it a buffer-local value in a specific buffer (with make-local-variable or setq-local), in which case what you get is another variable with the same name, which is buffer local. The buffer does not see the global variable anymore. It doesn't have a default value, but its initial value is that of the global variable. On the other hand, a variable which is buffer-local-when-set is essentially always buffer-local. In that case, it has a default value (which is global) and possibly a buffer-local value. For those variables, setq is the same as setq-local: it creates a buffer-local variable if one does not exist, and sets the buffer-local value. If you really want to think of it in terms of precedence, it would be local value > default value > global value. But I can't really imagine a situation where a local variable would have the same name as a global variable and a default value different from the global value. So I find it more natural to think of it as two different situations: - for a global variable which you made local in some buffer, the precedence is local value > global value; - for a buffer-local-when-set variable, the precedence is (local) value > (global) default value.