More readable Elisp code

This commit is contained in:
Lucien Cartier-Tilet 2021-07-12 12:52:40 +02:00
parent ff42cda756
commit e11c2701fb
Signed by: phundrak
GPG Key ID: BD7789E705CB8DCA
2 changed files with 31 additions and 23 deletions

View File

@ -833,27 +833,33 @@ Here is a description of the tables displayed below:
#+NAME: gen-sc-text #+NAME: gen-sc-text
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(lambda (x) (lambda (x)
(format "awful.key({%s},\"%s\",%s,\n\t{description=\"%s\",group=\"%s\"})" (let ((key (nth 0 x))
(nth 1 x) (nth 0 x) (modifiers (nth 1 x))
(cond (lambda-p (pcase (nth 2 x)
((string= "yes" (nth 2 x)) ("yes" 'lambda)
(format "function(%s) %s end" ("shell" 'shell)
(if (string= (nth 6 x) "yes") "c" "") ("terminal" 'terminal)
(nth 3 x))) ("spawn" 'spawn)
((string= "shell" (nth 2 x)) (otherwise nil)))
(format "function(%s) awful.spawn.with_shell(\"%s\") end" (action (nth 3 x))
(if (string= (nth 6 x) "yes") "c" "") (description (nth 4 x))
(nth 3 x))) (group (nth 5 x))
((string= "terminal" (nth 2 x)) (clientkey (if (string= (nth 6 x) "yes") "c" "")))
(format "function(%s) awful.spawn(terminal..\" -e %s\") end" (format "awful.key({%s},\"%s\",%s,\n\t{description=\"%s\",group=\"%s\"})"
(if (string= (nth 6 x) "yes") "c" "") modifiers
(nth 3 x))) key
((string= "spawn" (nth 2 x)) (pcase lambda-p
(format "function(%s) awful.spawn(\"%s\") end" ('lambda
(if (string= (nth 6 x) "yes") "c" "") (format "function(%s) %s end" clientkey action))
(nth 3 x))) ('shell
(t (nth 3 x))) (format "function(%s) awful.spawn.with_shell(\"%s\") end" clientkey action))
(nth 4 x) (nth 5 x))) ('terminal
(format "function(%s) awful.spawn(terminal..\" -e %s\" end" clientkey action))
('spawn
(format "function(%s) awful.spawn(\"%s\") end" clientkey action))
(otherwise action))
description
group)))
#+END_SRC #+END_SRC
#+NAME: gen-sc-glob #+NAME: gen-sc-glob
@ -861,8 +867,9 @@ Here is a description of the tables displayed below:
(mapconcat (mapconcat
<<gen-sc-text>> <<gen-sc-text>>
(seq-filter (lambda (x) (seq-filter (lambda (x)
(or (not (nth 6 x)) (let ((clientkey-p (nth 6 x)))
(string= "no" (nth 6 x)))) (or (not (nth 6 x))
(string= "no" (nth 6 x)))))
table) table)
",\n") ",\n")
#+END_SRC #+END_SRC

View File

@ -51,6 +51,7 @@ loaded, speeding Emacs up a bit.
(tooltip-mode -1) ; disable tooltips (tooltip-mode -1) ; disable tooltips
(set-fringe-mode 10) ; give some breathing room (set-fringe-mode 10) ; give some breathing room
(menu-bar-mode -1) ; disable menubar (menu-bar-mode -1) ; disable menubar
(blink-cursor-mode 0) ; disable blinking cursor
#+end_src #+end_src
** Emacs Behavior ** Emacs Behavior