Skip to main content

Questions tagged [alists]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
4 votes
1 answer
602 views

Is it possible to append to a list via .dir-locals.el?

So, I know that I can assign a variable via .dir-locals.el... ("thingy" (1 2 3 4)) but is there any way that I can append to an array, if at all? ("that" . "is correct") ...
Atlas Sullivan's user avatar
3 votes
3 answers
106 views

Retrieve alist from list of alists by value of specific key inside of it

I'm probably missing something simple here but... I've got a list of alists parsed from JSON using json-parse-string. The list of alists is like the following (details omitted for brevity): ( ((id . 1)...
Inops's user avatar
  • 333
3 votes
1 answer
94 views

How to match the car of alist elements with a regexp?

I've spent a good amount of hours trying to solve this one but without success. I have an alist with strings (setq trees '(("pine" . "cones") ("oak" . "acorns") ...
Ajned's user avatar
  • 764
3 votes
1 answer
114 views

Defcustom definition for plists

I want to write a defcustom definition for a variable my-var. my-var is an alist that maps strings to plists. Each such plists maps one of three keys (:x, :y, :z) to a list of strings. So, a member ...
efl's user avatar
  • 93
3 votes
1 answer
133 views

Emacs native database for fast key/value access?

I would like to do a key -> value lookup for data that may not fit into memory (or simply avoid the overhead of having to load it an keep it in memory). Does Emacs natively support any kind of ...
ideasman42's user avatar
  • 8,925
2 votes
2 answers
897 views

setf + alist-get but with "equal" instead of "eq"?

I got a suggestion to use setf to replace value in an alist: Replace element in a list / add in case of absence, with custom test/key functions The example was provided, but it doesn't work if key is ...
gavenkoa's user avatar
  • 3,462
2 votes
1 answer
96 views

add-to-list or push? Is there any disadvantage in using one over the other?

I've added a line in my early-init.el file that sets a background color to prevent the glare during startup. ;; Customize background color to prevent startup glare (add-to-list 'default-frame-alist ...
Zoli's user avatar
  • 451
1 vote
1 answer
129 views

Format alist into bullet points

I have this couple of alists: ((melpa . 49) (gnu . 14) (nongnu . 1)) ((nongnu (nongnu . markdown-mode)) (gnu (gnu . adaptive-wrap) (gnu . auctex) (gnu . company) (gnu . consult) (gnu . csv-mode) (gnu ...
Manuel Uberti's user avatar
1 vote
2 answers
144 views

How to randomize the order of elements in an alist?

I'm using ielm inside Emacs to randomize an associative list. I'm getting duplicate entries a lot of the time, not sure what I'm doing wrong? (defun q () "Q." (let ((alist)) (setf ...
gdonald's user avatar
  • 167
1 vote
1 answer
69 views

Append to a list inside an alist for custom find-file behaviour

cc-other-file-alist is part of find-file that looks something like this. (("\\.cc\\'" (".hh" ".h")) ("\\.hpp\\'" (".cpp")) ;; more such entries ) This is an alist where I'd like to append an ...
legends2k's user avatar
  • 207
0 votes
2 answers
60 views

How to make an alist without repeating key/values?

When writing an alist where all the key/value pairs have keys that are variables, is there a convenient way to write this in Elisp without repetition? eg: `((foo . ,foo) (long-variable-name . ,...
ideasman42's user avatar
  • 8,925
0 votes
2 answers
117 views

How to map/reduce a list into an alist?

Given a list of things, I want to create an alist by applying a function which creates elements of the alist. For example, what is the implementation of doit here: (doit '("a" "b" &...
Witek's user avatar
  • 375
0 votes
1 answer
254 views

Apply settings in .dir-locals.el to both c and c++ major modes

Is there a way to specify the same settings for c-mode and c++-mode without repeating the alist? I have: ((c-mode . ((comment-start . "/* ") (comment-end . " */") (comment-...
mcp's user avatar
  • 556
0 votes
1 answer
43 views

Working with a list of alists

I have a number of "alists". (defconst assoc-table-1 '( ("frantic" . "fN") ("authentic" . "atN") )) (defconst assoc-table-2 '( ("graphology&...
Dilna's user avatar
  • 1
0 votes
1 answer
116 views

Use regex as key/car in alist

I'd like to set up an alist (similar to auto-mode-alist), which is made up from regular expressions as key (AKA car) of the list. Next I'd like to be able, to match, say the major mode, against the ...
Jan's user avatar
  • 383
0 votes
1 answer
242 views

How to set up personal information alist with defcustom

I would like to have a variable, say my-info that would have an alist attached to it. In normal programming it would look like this: (setq my-info '((my-name . "Giuseppe Sextus-Packus") (my-email . "...
147pm's user avatar
  • 2,979
0 votes
1 answer
207 views

Using the push function to append a list to the default-frame-alist variable

I've noticed some people use this to disable the menu bar in the GUI: (push '(menu-bar-lines . 0) default-frame-alist) and some people use this: (menu-bar-mode -1) Both achieve the same. The first ...
Zoli's user avatar
  • 451
0 votes
1 answer
42 views

return full list of which element is a member

i know that member returns non-nil if the element is found in the list, but it only returns the tail of the list from element onwards. is there a way to return the full list it is a member of? my case:...
martian's user avatar
  • 558
0 votes
0 answers
24 views

How to programmatically set the same flag for multiple transient-values? [duplicate]

How can I programmatically set the same argument (e.g., --gpg-sign=abc123) for multiple transient-values? If I try the following, it seems that the value of adamliter/my-gpg-key-sign-git-arg does not ...
Adam Liter's user avatar
0 votes
1 answer
23 views

Reading the list produced by (mac-frame-geometry)

I just learned about the function (mac-frame-geometry). It produces a list in the form of: '((outer-position 0 . 25) (outer-size 1920 . 1055) (external-border-size 0 . 0) (title-bar-size 1920 . ...
ocodo's user avatar
  • 1,222
0 votes
0 answers
30 views

Passing many alists in a loop without actually listing them one by one

The following function add string associations if matches are found within a collection of alists. Currently I am listing the alists andromeda-assoc-tablet-N one by one. Can one manage to this ...
Dilna's user avatar
  • 1
0 votes
1 answer
24 views

Compact way that searches multiple alists

I have a collection of alists, ptc-1 through ptc-5. Would it be possible to make the following code more compact, rather having to add more sections if there are more alists? (let ( (v "") )...
Dilna's user avatar
  • 1
0 votes
1 answer
44 views

Evaluate elements in an alist? [duplicate]

I would like to evaluate an element in an alist, like dynamically generating an alist key for the current year: ((format-time-string "%Y") . ?y) => ("2022" . ?y) (In my case ...
holocronweaver's user avatar
-1 votes
1 answer
78 views

Print an alist in a named buffer

I want to print an alist in a specific named buffer, which I have to create if it does not exist. either by tabulated-list-format or using table-contents. How can I adapt these two functions to print ...
Dilna's user avatar
  • 1