From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eric Abrahamsen Newsgroups: gmane.emacs.help Subject: Re: Navigating Lisp data structures Date: Sun, 04 Dec 2022 18:05:13 -0800 Message-ID: <87a6421u7a.fsf@ericabrahamsen.net> References: <184de82cf09.eebfb5c8843687.6482234845227025147@excalamus.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="9126"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: "help-gnu-emacs" To: Matt Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Mon Dec 05 03:06:04 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 1p20rr-0002B1-Ji for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 05 Dec 2022 03:06:03 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p20rS-0004EW-0W; Sun, 04 Dec 2022 21:05:38 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p20rO-0004E0-Hr for help-gnu-emacs@gnu.org; Sun, 04 Dec 2022 21:05:34 -0500 Original-Received: from mail.ericabrahamsen.net ([52.70.2.18]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p20rL-0001yj-G9 for help-gnu-emacs@gnu.org; Sun, 04 Dec 2022 21:05:33 -0500 Original-Received: from localhost (c-71-197-232-41.hsd1.wa.comcast.net [71.197.232.41]) (Authenticated sender: eric@ericabrahamsen.net) by mail.ericabrahamsen.net (Postfix) with ESMTPSA id EEE0EFA095; Mon, 5 Dec 2022 02:05:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ericabrahamsen.net; s=mail; t=1670205915; bh=3ZPu6Ten5k7DuGHNub0vh47fi/HxqSJIwwoQsUEty3w=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=xTgKJqLEZeo04UPa04+ZIOPAU0bwBxEncUH1ojU173KhnK/TwkVd45XjJJ+MzqCEa kvvHDzHCrbqlGJsnDCXFkKcgBNR5iitMvPP3bQlQ60waO8hSFPhDHjYcx+gZdDWZm0 bTcuEefeyxJdQ9JhrDZLIc+7i/ISH/1LTwU4uPXY= In-Reply-To: <184de82cf09.eebfb5c8843687.6482234845227025147@excalamus.com> (Matt's message of "Sun, 04 Dec 2022 14:00:25 -0500") Received-SPF: pass client-ip=52.70.2.18; envelope-from=eric@ericabrahamsen.net; helo=mail.ericabrahamsen.net X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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, RCVD_IN_DNSWL_MED=-2.3, 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.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-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:141380 Archived-At: Matt writes: > I'm writing an Emacs package and struggling to figure out how to represent the data in a Lisp data structure. I'm getting lost in whether it should be an alist of alists, a plist of plists, an alist of plists, etc. Or maybe it would be better to use a cl-struct or a hash or a class or a vector or a record. Should I use keywords or not, etc. > > Here is a detailed explanation of my issue: > > My Emacs package manages my project workflows (e.g. Python or C). Each project has a name, associated files, one or more shell processes (comints), as well as commands for a specific shell and commands used across the shells. It also sets my window layout. > > In Python, I might structure the data something like this: > > projects = { > "my_c_project": { > 'shells': { > "*build*": {"root": "/path/to/build/directory/", "setup": ("export MYBUILDVAR1=1", "export MYBUILDVAR2=0")}, > "*run*": {"root": "/path/to/run/directory/", "setup": ("export MYRUNVAR=1")} > }, > 'commands': ("./build_my_project.sh", "./run_my_build"), > 'files': ("/path/to/entrypoint.c", "/path/to/other/file/I/care/about.c"), > 'window_split': ("quad", ), # C-x 3 C-x 2 other-window other-window C-x 2 > }, > "my_python_project": { > 'shells': {"*my_python_project*": {"root": "/path/to/my/python/project", "setup": ("source venv/bin/activate")}}, > 'commands': ("python3 -m my_python_project", > "python3 -m unittest discover tests/ --failfast --quiet", ), > 'files': ("/path/to/my_python_project/entry_point.py", ), > 'window_split': ("half", ), # C-x 3 > } > } Wow, it looks like you're recreating complete project management facilities from scratch! That's impressive, and also a bit terrifying. Your adventurous spirit is to be commended, but you might _also_ look into making use of more of Emacs' built-in facilities for this stuff. Emacs has projects, and projects have `project-compile', which calls `compile', and a bunch of the config above looks like it could be worked into existing facilities. There are/have been some truly monster discussion threads recently in emacs.devel and the bug tracker about how to expand and make use of projects, so that's very much in the process of evolution. I haven't seen anyone suggest incorporating window layout into projects, and I'll bet that some people would find that interesting. You might not want to wade into the midst of a firefight, but now is the right time to be asking these questions, and showing people how you use projects, and would like to use them. Just a suggestion! Eric