From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Leo Butler Newsgroups: gmane.emacs.help Subject: Re: How to store list of variable values into another dynamically created variables Date: Tue, 05 Jan 2021 12:24:48 -0600 Message-ID: <86turvqm1b.fsf@x201.butler.org> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="10687"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) To: Emacs Help Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Tue Jan 05 19:40:49 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 1kwrGD-0002e9-63 for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 05 Jan 2021 19:40:49 +0100 Original-Received: from localhost ([::1]:57646 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kwrGC-0000v9-7u for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 05 Jan 2021 13:40:48 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57898) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kwrFP-0000uu-98 for help-gnu-emacs@gnu.org; Tue, 05 Jan 2021 13:39:59 -0500 Original-Received: from mail-eopbgr670124.outbound.protection.outlook.com ([40.107.67.124]:47635 helo=CAN01-TO1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kwrFN-0006NQ-0g for help-gnu-emacs@gnu.org; Tue, 05 Jan 2021 13:39:58 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HhWJlubvzN49EcfAcjwQ/DjqfHFtf7xwllBzv1RQGPZG+u+BNn5Ano9OUxAva262YOeBmpvvr+2T4koFSsEpj/XisI2CXosBZ6T75gfgPP/WNcpLu6vDMSJi5xzv/Gbx6wu4wSkois4gfvBYv0zOndLz6f5KK7jt0HLTxymWICukN8oQxbf5DsR9Cm413M75MjrKdXK6S4PdjRkjXzyYvIk+2e5J5wU4DYdN6vAOZMaup8GlP5jhehwbIhIqkBNpTjJw1wg6fQWaSKzyGsXTVJVUeKCII8yWc1mz75grY9Ca8zv/07GqpI39nEVIZFBfK7z5GP0v1SFJYTWZC95XRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=i8ma4KySr9mj2Eg5wTAK+p94FPIHYwFEPfVSCjyf+Fk=; b=MLlVB5Htjl128nlHqGeOnbT1HhT4Y35mjFJWNyap9skw2KVlkvkH0fG62JiPe6aMeFncvLJ+Jr27F6FmvPvr1BlAlx+HBk+gLCVrjL4+zZVGJWsdNR3jhNs1SEWx3OZYiBSNGx9BL376akHmlJnZk8HnHeI6D1RnOTX0uyGDFhNuUxSbCWMQ7XpV25lUM89Q7BNt1rYWmrDRwoZ9X+uEziUj+UrYUXmKnli1n6eWb7rGpJcf+1pnMZlhCfk/nWWhA3OK1rZ1P4Sf+Usy+DJxN5OliIMtvJJyVQiTwtp+Xfsksn6XaRj6PBMPIu6sRTiNP2h//NMwGL4C8RnEbYTiiQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=umanitoba.ca; dmarc=pass action=none header.from=umanitoba.ca; dkim=pass header.d=umanitoba.ca; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=umanitoba.onmicrosoft.com; s=selector2-umanitoba-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=i8ma4KySr9mj2Eg5wTAK+p94FPIHYwFEPfVSCjyf+Fk=; b=by2dKyWSmfo+59bNjoaq/CUkzAJWtVLwiN7+H4O+OTYDsg10hjDH4YiCruvpjrCnHLWAkc23c4RoQ/AQbEEV0C2nqxUYMBUPUPK4OIP4c9XtlxguWJCVNgf+QxrQT9FXITb0cmXz5zDYOkvVTFPS4eYacmK2NPUZDunoFIbkxGk= Authentication-Results: gnu.org; dkim=none (message not signed) header.d=none;gnu.org; dmarc=none action=none header.from=umanitoba.ca; Original-Received: from YTBPR01MB3053.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:21::31) by YT1PR01MB3244.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:e::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6; Tue, 5 Jan 2021 18:24:52 +0000 Original-Received: from YTBPR01MB3053.CANPRD01.PROD.OUTLOOK.COM ([fe80::e557:4be:b224:e3ca]) by YTBPR01MB3053.CANPRD01.PROD.OUTLOOK.COM ([fe80::e557:4be:b224:e3ca%4]) with mapi id 15.20.3721.024; Tue, 5 Jan 2021 18:24:52 +0000 In-Reply-To: (miles christopher's message of "Mon, 4 Jan 2021 14:51:32 +0000") X-Originating-IP: [45.44.33.194] X-ClientProxiedBy: MW4PR03CA0405.namprd03.prod.outlook.com (2603:10b6:303:115::20) To YTBPR01MB3053.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:21::31) X-MS-Exchange-MessageSentRepresentingType: 1 Original-Received: from x201 (45.44.33.194) by MW4PR03CA0405.namprd03.prod.outlook.com (2603:10b6:303:115::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3721.22 via Frontend Transport; Tue, 5 Jan 2021 18:24:51 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 67066fd4-c493-491f-7655-08d8b1a731e5 X-MS-TrafficTypeDiagnostic: YT1PR01MB3244: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3968; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /nHkTHUKb2r64GJew/WPOOkqvRna2gqXKPmwTC0Q74XFw8y8m/yIxD6+Yp7wYAPeN6DGsKqSx00kpMVKNdLTD0cQ+gbn1EsV5zof9MHC1DjYMWiEcLl2B5Dm7tmt1tRMg3PZ0wZ7qEKUcUq7pbPUYgG6qK4YiJyV+zfHCBg2ioFoVIGcYLvX5mWRPDyaCWhtleqq+ilKCagdSi9D+EC+n0R9TITk0fE0yF0uka/fHQxwBzP4W9wKK7dpa2uiaiPHoHgNzOde8kQh+kAkknm4fgm2UPLpn7s8x2vG9ykUUcoYFZx8uO+1rrAcUgd5s3WMd9UeeWuzPZLGRDGP55jX8cNNKm56m6jF8rMpeATnS16v9HG9IiB/BC0VuARAp/FI X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:YTBPR01MB3053.CANPRD01.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(366004)(136003)(376002)(396003)(346002)(39860400002)(44832011)(478600001)(52116002)(316002)(83380400001)(786003)(16526019)(6486002)(86362001)(66476007)(66556008)(6666004)(66946007)(26005)(8936002)(6496006)(2906002)(8676002)(9686003)(5660300002)(6916009)(186003)(956004); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: =?us-ascii?Q?eV3JZKGP+mbOOpsWShuMGmCV2V1sj5Z/wrOktE3ASXpFJ49GgUawg9ju4Itf?= =?us-ascii?Q?gq0G+vPjNxe7y0YZ/lz8s9xoPPAn3T0/2FKVUACKEVqmq4V3qXblDPutcK9r?= =?us-ascii?Q?EmbTWRXTQNCJrFVrE3K1b9yXMDvN9eEqMH3L+SxDNY1kSfPAisdlchL9wkc7?= =?us-ascii?Q?ggEjEUdhPI0Q8uNbnYqPlysVPygAMRRQJznMjcgjfz3Hu7+MieV1pcTSJOR8?= =?us-ascii?Q?Nf/pEUmaXow28ZWB7UMYdkVKvib2HZsC9gZmTsLlIWiFqP7kELpZx5qlYTNP?= =?us-ascii?Q?LGFaanvhj1bqNv0eQkeIm9FbmUbIoVZFH4Z95WI3mKSc0hfRq3UQNr3J+Ix3?= =?us-ascii?Q?dqGCjX3CLGdpDtoVEonJiax20WSCEjGUD1OQbK8q2CNjwGVLCigHKXzxhijs?= =?us-ascii?Q?F8u2Wd7Nh/dgq96EcVLutnndkU1WKB3lwbmhsC4uv+tili+RRXXVB/W67n0W?= =?us-ascii?Q?MuSTjIlieOgMFTRA8OrprIsUpZK52ryebR9Y3is37DMwiUBYD7Y5evLtmayX?= =?us-ascii?Q?LODXURTB3Plhuv3i4MjBBkq/iFbY0mlcyGabrRHbFFAyql+XzvzQW/+Y08iw?= =?us-ascii?Q?9MFWCWZPlsvO5POhOdpKN2QM0yXRvzzrPHYpiyJKQ9CjKMbXuFNbIJP+JfMw?= =?us-ascii?Q?SIqg X-OriginatorOrg: umanitoba.ca X-MS-Exchange-CrossTenant-AuthSource: YTBPR01MB3053.CANPRD01.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2021 18:24:52.6262 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4f80dd0b-338c-4e4c-8a14-90446962f7b8 X-MS-Exchange-CrossTenant-Network-Message-Id: 67066fd4-c493-491f-7655-08d8b1a731e5 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: b8O1/4OmkEamMG5cJIz5f8I8cTsGeoFcG60ZnrVL4SJLT3ryCQqN2Sw7sMJ+FvJaeNIy3HUIbDFBbzDoRdkhSg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: YT1PR01MB3244 Received-SPF: pass client-ip=40.107.67.124; envelope-from=Leo.Butler@umanitoba.ca; helo=CAN01-TO1-obe.outbound.protection.outlook.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-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:126998 Archived-At: miles christopher writes: > I want to store some variables' value into another minor mode temporary variable > for later restore. > > Here is my Elisp code, I don't know how to implement it in FIXME and TODO. Hope > some Elisp master help me. > > #+begin_src emacs-lisp > (defvar mu4e-marker-icons-marker-list > '(mu4e-headers-seen-mark > mu4e-headers-new-mark > mu4e-headers-unread-mark > mu4e-headers-signed-mark > mu4e-headers-encrypted-mark > mu4e-headers-draft-mark > mu4e-headers-attach-mark > mu4e-headers-passed-mark > mu4e-headers-flagged-mark > mu4e-headers-replied-mark > mu4e-headers-trashed-mark > ;; thread prefix marks > mu4e-headers-default-prefix > mu4e-headers-has-child-prefix > mu4e-headers-empty-parent-prefix > mu4e-headers-first-child-prefix > mu4e-headers-duplicate-prefix) > "A list of markers used in mu4e.") > > (defun mu4e-marker-icons--store () > "Store user old config." > (mapcar > (lambda (marker-variable) > ;; FIXME: > `(setq > ,(intern (replace-regexp-in-string > "mu4e-headers-" "mu4e-marker-icons--" > (symbol-name marker-variable))) > ,(symbol-value marker-variable)) > ) > mu4e-marker-icons-marker-list)) > > (defun mu4e-marker-icons--restore () > "Restore user old config." > ;; TODO: > (mapcar > (lambda (marker-variable) > ;; FIXME: > `(setq > marker-variable > ,(symbol-value (intern (replace-regexp-in-string > "mu4e-headers-" "mu4e-marker-icons--" > (symbol-name marker-variable)))))) > mu4e-marker-icons-marker-list)) > #+end_src Since you are trying to rename the variables, why not start with a list of conses (old . new) rather than a list of variable names? #+begin_src emacs-lisp (defvar mu4e-marker-icons-marker-list '((mu4e-headers-seen-mark . mu4e-saved-headers-seen-mark) (mu4e-headers-new-mark . mu4e-saved-headers-new-mark) (mu4e-headers-unread-mark . mu4e-saved-headers-unread-mark) (mu4e-headers-signed-mark . mu4e-saved-headers-signed-mark) (mu4e-headers-encrypted-mark . mu4e-saved-headers-encrypted-mark) (mu4e-headers-draft-mark . mu4e-saved-headers-draft-mark) (mu4e-headers-attach-mark . mu4e-saved-headers-attach-mark) (mu4e-headers-passed-mark . mu4e-saved-headers-passed-mark) (mu4e-headers-flagged-mark . mu4e-saved-headers-flagged-mark) (mu4e-headers-replied-mark . mu4e-saved-headers-replied-mark) (mu4e-headers-trashed-mark . mu4e-saved-headers-trashed-mark) ;; thread prefix marks (mu4e-headers-default-prefix . mu4e-saved-headers-default-prefix) (mu4e-headers-has-child-prefix . mu4e-saved-headers-has-child-prefix) (mu4e-headers-empty-parent-prefix . mu4e-saved-headers-empty-parent-prefix) (mu4e-headers-first-child-prefix . mu4e-saved-headers-first-child-prefix) (mu4e-headers-duplicate-prefix . mu4e-saved-headers-duplicate-prefix)) "A list of markers used in mu4e.") #+end_src Your save and restore functions are then dead easy: #+begin_src emacs-lisp (defun mu4e-save (l) (mapcar (lambda(x) (set (cdr x) (symbol-value (car x)))) l)) (defun mu4e-restore (l) (let ((lrev (mapcar (lambda(x) (cons (cdr x) (car x))) l))) (mu4e-save lrev))) #+end_src Leo