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)
(let ((key (nth 0 x))
(modifiers (nth 1 x))
(lambda-p (pcase (nth 2 x)
("yes" 'lambda)
("shell" 'shell)
("terminal" 'terminal)
("spawn" 'spawn)
(otherwise nil)))
(action (nth 3 x))
(description (nth 4 x))
(group (nth 5 x))
(clientkey (if (string= (nth 6 x) "yes") "c" "")))
(format "awful.key({%s},\"%s\",%s,\n\t{description=\"%s\",group=\"%s\"})" (format "awful.key({%s},\"%s\",%s,\n\t{description=\"%s\",group=\"%s\"})"
(nth 1 x) (nth 0 x) modifiers
(cond key
((string= "yes" (nth 2 x)) (pcase lambda-p
(format "function(%s) %s end" ('lambda
(if (string= (nth 6 x) "yes") "c" "") (format "function(%s) %s end" clientkey action))
(nth 3 x))) ('shell
((string= "shell" (nth 2 x)) (format "function(%s) awful.spawn.with_shell(\"%s\") end" clientkey action))
(format "function(%s) awful.spawn.with_shell(\"%s\") end" ('terminal
(if (string= (nth 6 x) "yes") "c" "") (format "function(%s) awful.spawn(terminal..\" -e %s\" end" clientkey action))
(nth 3 x))) ('spawn
((string= "terminal" (nth 2 x)) (format "function(%s) awful.spawn(\"%s\") end" clientkey action))
(format "function(%s) awful.spawn(terminal..\" -e %s\") end" (otherwise action))
(if (string= (nth 6 x) "yes") "c" "") description
(nth 3 x))) group)))
((string= "spawn" (nth 2 x))
(format "function(%s) awful.spawn(\"%s\") end"
(if (string= (nth 6 x) "yes") "c" "")
(nth 3 x)))
(t (nth 3 x)))
(nth 4 x) (nth 5 x)))
#+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)
(let ((clientkey-p (nth 6 x)))
(or (not (nth 6 x)) (or (not (nth 6 x))
(string= "no" (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