From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jean Louis Newsgroups: gmane.emacs.help Subject: Re: How to save custom variable programmatically? Date: Tue, 10 Nov 2020 22:19:20 +0300 Message-ID: References: <87blg5e9re.fsf@web.de> <87o8k5b7oq.fsf@web.de> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5462"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mutt/2.0 (3d08634) (2020-11-07) Cc: help-gnu-emacs@gnu.org To: Michael Heerdegen Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Tue Nov 10 20:21:35 2020 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 1kcZCx-0001KJ-He for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 10 Nov 2020 20:21:35 +0100 Original-Received: from localhost ([::1]:41288 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kcZCw-0000t9-Jr for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 10 Nov 2020 14:21:34 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49364) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kcZBj-0000rL-HU for help-gnu-emacs@gnu.org; Tue, 10 Nov 2020 14:20:19 -0500 Original-Received: from static.rcdrun.com ([95.85.24.50]:47953) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kcZBh-00076z-T6 for help-gnu-emacs@gnu.org; Tue, 10 Nov 2020 14:20:19 -0500 Original-Received: from localhost ([::ffff:197.157.34.177]) (AUTH: PLAIN admin, TLS: TLS1.2,256bits,ECDHE_RSA_AES_256_GCM_SHA384) by static.rcdrun.com with ESMTPSA id 00000000002C000C.000000005FAAE7EF.00000551; Tue, 10 Nov 2020 19:20:15 +0000 Content-Disposition: inline In-Reply-To: <87o8k5b7oq.fsf@web.de> Received-SPF: pass client-ip=95.85.24.50; envelope-from=bugs@gnu.support; helo=static.rcdrun.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/10 14:03:25 X-ACL-Warn: Detected OS = Linux 3.11 and newer [fuzzy] 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, 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:125206 Archived-At: * Michael Heerdegen [2020-11-10 17:36]: > Jean Louis writes: > > > If there is anyway of storing data from Emacs that is standard I do > > not know about it. Welcoming tips. > > The eieio-persistent class is made for that purpose. > > You make your data/database/whatever an object of a class you define as > you like, and make that class inherit from eieio-persistent. Then your > data is savable out of the box. > > (info "(eieio) eieio-persistent") > > Do you need an example? Thank you. If you have ready simplest example it may be useful for review. My strategy is to minimize number of packages used as dependencies so I try to use what is built in or to re-use what is inside of Emacs. For simplest database with hundreds of entries file locking and Lisp data can be enough. For larger database I would prefer GDBM bindings built-in, but life is not a dream. Personally I am using PostgreSQL. Then I just define the table definition and that may be similar to eieio.