From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.help Subject: Re: Is there a way of setting a variable only when it exists? Date: Mon, 14 Mar 2022 14:52:02 +0200 Message-ID: <83zglsk87h.fsf@gnu.org> References: <87lexdul8e.fsf@mbork.pl> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37989"; mail-complaints-to="usenet@ciao.gmane.io" To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Mon Mar 14 13:53:35 2022 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 1nTkCd-0009l7-AC for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 14 Mar 2022 13:53:35 +0100 Original-Received: from localhost ([::1]:50286 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nTkCc-0008PO-94 for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 14 Mar 2022 08:53:34 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:60140) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nTkBM-0008NA-8x for help-gnu-emacs@gnu.org; Mon, 14 Mar 2022 08:52:16 -0400 Original-Received: from [2001:470:142:3::e] (port=46520 helo=fencepost.gnu.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nTkBM-0001IX-03 for help-gnu-emacs@gnu.org; Mon, 14 Mar 2022 08:52:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=aapUJTfWia89A3y4qmqe9t9gKRwCNFMu/3XdbE4SZYY=; b=cUbXMLYWEmLW Gs/+5Qj1SaeqCcmP4KzuxAbXDrSuVCa17ZMwZZXnng3WhtqzDH/nUTAbTVBr+929rD16ouhZF0tEc 3dwXERZS+i1Osq0iB1la/ODQBDAD9TQiLAGOlxmgBMBYQWAj8AygXEritxDWkSVKdQAuhAeK0kK8y EDdD0sTD4osyme52MkL78UimMZFE7D/XoLX7SBwBohrDeq25aTN7cVBtZwKS9XilDIOqUlgD+junr rO21wsHcA6gJotsjshS5XMbwBzJ/N0qttQ9VNQa0aNruQcSjfI3NJF1vz6PunbAlCDcTDsYSQGkkc WZA+5yyxCZ3GKQqgMN0Aag==; Original-Received: from [87.69.77.57] (port=4266 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nTkBJ-0004K2-Rp for help-gnu-emacs@gnu.org; Mon, 14 Mar 2022 08:52:15 -0400 In-Reply-To: <87lexdul8e.fsf@mbork.pl> (message from Marcin Borkowski on Mon, 14 Mar 2022 07:00:33 +0100) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 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:136535 Archived-At: > From: Marcin Borkowski > Date: Mon, 14 Mar 2022 07:00:33 +0100 > > I'd like to be able to say something like > > (setq-safe hello "world") > > so that `hello' is set to `"world"' if it is an existing variable (e.g., > defined by `defvar') and an error is raised if `hello' does not exist. > > Rationale: I'm setting an internal Emacs variable. At the same time, > I submitted a feature request to turn it into a user option, so that > it's possible that in a future version of Emacs it's going to change its > name (it has two dashes in it). I want to be warned then that I need to > change my `init.el' accordingly. > > I assume it would be fairly easy to code such a macro (using `boundp'), > but maybe it exists already? Why not just use boundp?