unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Eric Abrahamsen <eric@ericabrahamsen.net>
To: Matt <matt@excalamus.com>
Cc: "help-gnu-emacs" <help-gnu-emacs@gnu.org>
Subject: Re: Navigating Lisp data structures
Date: Sun, 04 Dec 2022 18:05:13 -0800	[thread overview]
Message-ID: <87a6421u7a.fsf@ericabrahamsen.net> (raw)
In-Reply-To: <184de82cf09.eebfb5c8843687.6482234845227025147@excalamus.com> (Matt's message of "Sun, 04 Dec 2022 14:00:25 -0500")

Matt <matt@excalamus.com> 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



  parent reply	other threads:[~2022-12-05  2:05 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-04 19:00 Navigating Lisp data structures Matt
2022-12-05  0:46 ` Joost Kremers
2022-12-06 15:36   ` Matt
2022-12-05  2:05 ` Eric Abrahamsen [this message]
2022-12-07  4:06   ` Matt
2022-12-07 18:01     ` Eric Abrahamsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87a6421u7a.fsf@ericabrahamsen.net \
    --to=eric@ericabrahamsen.net \
    --cc=help-gnu-emacs@gnu.org \
    --cc=matt@excalamus.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).