[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
triple-backquote (was: Re: transient questions)
From: |
Emanuel Berg |
Subject: |
triple-backquote (was: Re: transient questions) |
Date: |
Tue, 14 Mar 2023 02:15:46 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
Joost Kremers wrote:
> ```
> (transient-define-prefix jk-move-transient ()
> :transient-non-suffix #'transient--do-leave
> [:class transient-row
> ("SPC" "" scroll-up-command :transient t)
> ("C-v" "" scroll-up-command :transient t)
> ("<backspace>" "" scroll-down-command :transient t)
> ("M-v" "" scroll-down-command :transient t)
> ("<up>" "" scroll-up-line :transient t)
> ("<down>" "" scroll-down-line :transient t)
> ("<left>" "" scroll-right :transient t)
> ("<right>" "" scroll-left :transient t)
> ("b" "(Un)set bookmark" bm-toggle :transient t)
> ("g" "Top of buffer" beginning-of-buffer :transient t)
> ("G" "End of buffer" end-of-buffer :transient t)
> ("l" "Goto line" consult-goto-line)
> ("m" "Goto mark" consult-mark)
> ("n" "Next bookmark" bm-next)
> ("o" "Outline" consult-outline)
> ("t" "Previous bookmark" bm-previous)
> ("z" "Avy line" avy-goto-line)])
> ```
Alright, so what is this syntax/feature called, you put Elisp
between an opening/closing triplet backquote and you get font
lock with `gnus-article-mode'?
I like it, let's try it!
```
;;; -*- lexical-binding: t -*-
;;
;; this file:
;; https://dataswamp.org/~incal/emacs-init/abc.el
(require 'cl-lib)
(defun alphabet (&optional as-list)
(let ((abc "a b c d e f g h i j k l m n o p q r s t u v w x y z"))
(if as-list
(cl-remove ?\s (string-to-list abc))
abc) ))
;; (alphabet) ; a b c d e f g h i j k l m n o p q r s t u v w x y z
;; (alphabet t) ; (97 98 99 100 101 102 103 104 105 106 107 108 ...)
(defun echo-alphabet (&optional num)
(interactive "P")
(or num (setq num (length (alphabet t))))
(let*((part (cl-subseq (alphabet t) 0 num))
(str-list (cl-mapcar (lambda (c) (char-to-string c)) part))
(str-almost (format "%s" str-list))
(str (substring str-almost 1 (1- (length str-almost)))) )
(message str) ))
;; (echo-alphabet) ; a b c d e f g h i j k l m n o p q r s t u v w x y z
;; (echo-alphabet 10) ; a b c d e f g h i j
;; (echo-alphabet -10) ; a b c d e f g h i j k l m n o p
(defalias 'abc #'echo-alphabet)
(provide 'abc)
```
So did it work?
Maybe this will improve the level of the information
interchange, or what do you think?
Beautify the moment!
--
underground experts united
https://dataswamp.org/~incal
- transient questions, Joost Kremers, 2023/03/13
- triple-backquote (was: Re: transient questions),
Emanuel Berg <=