[Desktop] Generate nicer Lisp and Elisp output

This commit is contained in:
Lucien Cartier-Tilet 2022-03-28 02:07:03 +02:00
parent d63da4af42
commit e6387f84c5
Signed by: phundrak
GPG Key ID: BD7789E705CB8DCA

View File

@ -153,37 +153,56 @@ not show up. Hopefully this can be implemented someday in StumpWM.
#+header: :var keymap=emacs-stumpwm-media-control keymap-name="my-mpd-add-map" prefix="m" #+header: :var keymap=emacs-stumpwm-media-control keymap-name="my-mpd-add-map" prefix="m"
#+begin_src emacs-lisp :exports none :tangle no :wrap "src lisp :tangle no" :noweb yes #+begin_src emacs-lisp :exports none :tangle no :wrap "src lisp :tangle no" :noweb yes
(require 'seq) (require 'seq)
(format "%S" (format "(defvar *%s*
`(defvar ,(intern (format "*%s*" keymap-name)) (let %S
(let ((m (make-sparse-keymap))) %s
,@(mapcar (lambda (keybind) m))"
(let ((keychord (replace-regexp-in-string (format "^%s" prefix) keymap-name
"" `((m (make-sparse-keymap)))
(car keybind))) (mapconcat (lambda (keybind)
(function (cdr keybind))) (let ((keychord (replace-regexp-in-string (format "^%s" prefix)
`(define-key m (kbd ,keychord) ,function))) ""
<<stumpwm-filter-keybinds>> (car keybind)))
) (function (cdr keybind)))
m))) (format "%S" `(define-key m (kbd ,keychord) ,function))))
<<stumpwm-filter-keybinds>>
"\n "))
#+end_src #+end_src
#+RESULTS: stumpwm-keybinds-gen #+RESULTS: stumpwm-keybinds-gen
#+begin_src lisp :tangle no #+begin_src lisp :tangle no
(defvar *my-mpd-add-map* (let ((m (make-sparse-keymap))) (define-key m (kbd ".") "media-interactive") (define-key m (kbd "«") "mpd-prev") (define-key m (kbd "»") "mpd-next") (define-key m (kbd "a") "'*my-mpd-add-keymap*") (define-key m (kbd "b") "'*my-mpd-browse-keymap*") (define-key m (kbd "c") "mpd-clear") (define-key m (kbd "p") "mpd-toggle-pause") m)) (defvar *my-mpd-add-map*
(let ((m (make-sparse-keymap)))
(define-key m (kbd ".") "media-interactive")
(define-key m (kbd "«") "mpd-prev")
(define-key m (kbd "»") "mpd-next")
(define-key m (kbd "a") "'*my-mpd-add-keymap*")
(define-key m (kbd "b") "'*my-mpd-browse-keymap*")
(define-key m (kbd "c") "mpd-clear")
(define-key m (kbd "p") "mpd-toggle-pause")
m))
#+end_src #+end_src
#+name: stumpwm-interactive-keybinds-gen #+name: stumpwm-interactive-keybinds-gen
#+header: :var keymap=emacs-stumpwm-resize-frame prefix="" #+header: :var keymap=emacs-stumpwm-resize-frame prefix=""
#+header: :wrap "src lisp :exports none"
#+begin_src emacs-lisp :noweb yes #+begin_src emacs-lisp :noweb yes
(format "%S" `,@(mapcar (lambda (keybind) (format "(%s)"
(let ((keychord (car keybind)) (mapconcat (lambda (keybind)
(function (cdr keybind))) (let ((keychord (car keybind))
`((kbd ,keychord) ,function))) (function (cdr keybind)))
<<stumpwm-filter-keybinds>>)) (format "%S" `((kbd ,keychord) ,function))))
<<stumpwm-filter-keybinds>>
"\n "))
#+end_src #+end_src
#+RESULTS: stumpwm-interactive-keybinds-gen #+RESULTS: stumpwm-interactive-keybinds-gen
: (((kbd "c") "resize-direction left") ((kbd "t") "resize-direction down") ((kbd "s") "resize-direction up") ((kbd "r") "resize-direction right")) #+begin_src lisp :exports none
(((kbd "c") "resize-direction left")
((kbd "t") "resize-direction down")
((kbd "s") "resize-direction up")
((kbd "r") "resize-direction right"))
#+end_src
#+name: stumpwm-interactive-gen #+name: stumpwm-interactive-gen
#+header: :var keymap=emacs-stumpwm-resize-frame keymap-name="my-mpd-add-map" prefix="" #+header: :var keymap=emacs-stumpwm-resize-frame keymap-name="my-mpd-add-map" prefix=""