let-alist
- Description
- Easily let-bind values of an assoc-list by their names
- Latest
- let-alist-1.0.6.0.20240919.15459.tar (.sig), 2024-Sep-19, 10.0 KiB
- Maintainer
- Artur Malabarba <emacs@endlessparentheses.com>
- Website
- https://elpa.gnu.org/packages/let-alist.html
- Browse ELPA's repository
- CGit or Gitweb
- Badge
To install this package from Emacs, use list-packages
.
Full description
This package offers a single macro, `let-alist'. This macro takes a first argument (whose value must be an alist) and a body. The macro expands to a let form containing body, where each dotted symbol inside body is let-bound to their cdrs in the alist. Dotted symbol is any symbol starting with a `.'. Only those present in the body are let-bound and this search is done at compile time. A number will result in a list index. For instance, the following code (let-alist alist (if (and .title.0 .body) .body .site .site.contents)) essentially expands to (let ((.title.0 (nth 0 (cdr (assq 'title alist)))) (.body (cdr (assq 'body alist))) (.site (cdr (assq 'site alist))) (.site.contents (cdr (assq 'contents (cdr (assq 'site alist)))))) (if (and .title.0 .body) .body .site .site.contents)) If you nest `let-alist' invocations, the inner one can't access the variables of the outer one. You can, however, access alists inside the original alist by using dots inside the symbol, as displayed in the example above by the `.site.contents'.
Old versions
let-alist-1.0.6.0.20240102.14710.tar.lz | 2024-Mar-31 | 2.41 KiB |
let-alist-1.0.6.0.20230930.233523.tar.lz | 2023-Oct-07 | 2.41 KiB |
let-alist-1.0.6.0.20230101.53112.tar.lz | 2023-Jan-01 | 2.30 KiB |
let-alist-1.0.6.0.20220101.24551.tar.lz | 2022-Jan-01 | 2.26 KiB |
let-alist-1.0.6.0.20210914.55714.tar.lz | 2021-Sep-14 | 2.26 KiB |
let-alist-1.0.6.0.20210101.91356.tar.lz | 2021-Mar-09 | 2.26 KiB |
let-alist-1.0.6.0.20200101.5952.tar.lz | 2020-Dec-14 | 2.26 KiB |
let-alist-1.0.6.0.20200101.5952.tar.lz | 2020-Dec-14 | 2.26 KiB |