[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
new `pcase-let' syntax hotter than TikTok girls?
From: |
Emanuel Berg |
Subject: |
new `pcase-let' syntax hotter than TikTok girls? |
Date: |
Wed, 23 Nov 2022 11:26:49 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
Check out this syntax with `pcase-let'! :O
(pcase-let ((`(,up ,down) (if button
`(,#'backward-button ,#'forward-button)
`(,#'previous-line ,#'forward-line) ))) ... )
Advantage: A single test (here, `if') but without the bulky
and ugly combo with `let*' and `car'/`cadr' ...
Here is an example how it can be used, and actually is used already [1]
(defun set-vertical-keys (kmap &optional button np tab)
(pcase-let ((`(,up ,down) (if button
`(,#'backward-button ,#'forward-button)
`(,#'previous-line ,#'forward-line) )))
(define-key kmap "i" up)
(define-key kmap "k" down)
(when np
(define-key kmap "p" up)
(define-key kmap "n" down) )
(when tab
(define-key kmap [backtab] up)
(define-key kmap "\t" down) )))
and then for example [2]
(let ((kmap Buffer-menu-mode-map))
(set-vertical-keys kmap nil nil t)
;; ...
)
Too sexy for its shirt!
[1] https://dataswamp.org/~incal/emacs-init/scroll.el
[2] https://dataswamp.org/~incal/emacs-init/buffer-menu.el
--
underground experts united
https://dataswamp.org/~incal
- new `pcase-let' syntax hotter than TikTok girls?,
Emanuel Berg <=