-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace with-plist-vars
#7
Comments
Hi, Thanks for the kind words. Glad you've found it useful. This is a really great idea. In fact, it's so good that I think it would be a good addition to Emacs itself. Have you considered proposing that? Maybe you could post it to /r/emacs first to get feedback, and then propose it on emacs-devel. I'll be glad to add it to the handbook in the meantime. |
I hadn't considered proposing it. Posting it sounds like a great idea. I think then it'd be best to wait until I post it onto /r/emacs to get feedback before adding it to the handbook. Testing it, I've found some improvements I'd like to make. One, for example, is both Example:
As for proposing it on emacs-devel, I'm not sure. Perhaps would it be better off as part of a package? I'm conservative about adding stuff to emacs itself because I think something that might seem very useful to me (or even most emacs users) might not be wanted for some. But with a package those who want it can install it; and those who don't can leave it. I don't want to force anything on anyone. Then again though, |
Sounds good. Please post an update here when you think it's ready, in case I miss the Reddit thread.
That's interesting. In my limited experiments with rewriting backquoted and unquoted lists, I found that it's very confusing, and I was unsuccessful. It seems to be a bit of a "black art". I suppose if one studied the relevant Emacs source code that already does this, one might eventually come to understand it--maybe someday... :)
That's a good point. AFAIK
It's also strange that |
I just posted the latest code for it on reddit. I hope it will be received well as it was my first reddit post. I made an account just to post this :) |
For my latest version of The stackoverflow answer only worked on plists whose keys are keywords (I know you mentioned you didn't like this and neither do I) so I have it work for both symbols and keywords. One big difference I made is I abstracted the prefix symbol into a variable. This way, if you prefer the I am considering adding an option for shorthand syntax when accessing plist values that are keys (something shorter than As it stands
|
First, thanks for this handbook. I haven't developed any emacs packages (yet), but even for my own init.el customizations this has been invaluable.
I was using the
with-plist-vars
macro and I liked it. However, I found that it had some significant shortcomings.One is that it requires a raw plist and will not work with a variable which contains a plist.
For instance
(progn (setq plist '(:hi 1 :ho 2)) (with-plist-vars plist (+ hi ho))
does not work.Equally problematic was the fact that it used variables with the same name as
the keys. These variables are likely to clobber other variables because they're
not prefixed by anything. Additionally, often times I want to try to get a value
from a key that I don't know is in the plist. Since there is no special notation
between a variable that refers to a key and any other variable I
have no way of doing this.
I would recommend adding this macro instead to your handbook:
This macro addresses both these misgivings and is consistent with the
let-alist
macro already built-in to 26.1. It useslet-alist--deep-dot-search-body
to get the variables which are prefixed by a.
.EDIT: fixed leak with
plist
var. Before the edit, if you passed in some expression which would evaluate to a plist, the expression would be evaluated one time for every unique dot variable. If the expression had side-effects or if it was computationally expensive, this could lead to unexpected results. Also I check to see if plist is an unquoted list and if it is I quote it. This is for convenience so that(let-plist (:hi 1 :ho 2) ...)
will work even though the raw plist isn't quoted.EDIT: Add
(require 'let-alist)
.The text was updated successfully, but these errors were encountered: