Changing metaprogramming language to EmacsLisp

This commit is contained in:
Lucien Cartier-Tilet 2020-03-15 12:24:46 +01:00
parent 1eece7ed09
commit 979fd31fe4
Signed by: phundrak
GPG Key ID: BD7789E705CB8DCA
10 changed files with 147 additions and 88 deletions

View File

@ -5,6 +5,7 @@
#+HTML_HEAD_EXTRA: <meta property="og:title" content="Phundrak's i3 config" />
#+HTML_HEAD_EXTRA: <meta property="og:description" content="Description of the i3 config file of Phundrak" />
#+PROPERTY: header-args :exports code
#+STARTUP: content
* Table of Contents :TOC:noexport:
:PROPERTIES:

View File

@ -7,6 +7,7 @@
#+HTML_HEAD_EXTRA: <meta property="og:description" content="Description of the fish config file of Phundrak" />
#+PROPERTY: header-args:fish :tangle ~/.config/fish/config.fish :exports code :noweb yes
#+PROPERTY: header-args :exports code :tangle no
#+STARTUP: content
* Table of Contents :TOC:noexport:
:PROPERTIES:
@ -125,14 +126,12 @@
| $HOME/.gem/ruby/2.6.0/bin | Ruby binaries and executables |
#+NAME: generate-extra-paths
#+BEGIN_SRC python :var paths=extra-paths :exports none :cache yes
results = ''
for path in paths:
results += "{0} ".format(path[0])
return results.strip()
#+BEGIN_SRC emacs-lisp :var paths=extra-paths[,0] :exports none :cache yes
(mapconcat (lambda (x) x)
paths " ")
#+END_SRC
#+RESULTS[36e9cabf867423f29b621d8dac765fad154bd2b1]: generate-extra-paths
#+RESULTS[d6cf1e9d562d644db1bc6458eca1fc165b065f0c]: generate-extra-paths
: $HOME/.pub-cache/bin $HOME/.local/bin $HOME/go/bin $HOME/.cargo/bin $HOME/.gem/ruby/2.6.0/bin
#+BEGIN_SRC fish :noweb yes
@ -212,11 +211,13 @@
:CUSTOM_ID: h-740bd904-3e32-4c09-b0a4-bde16ae2e116
:END:
#+NAME: generate-abbr
#+BEGIN_SRC python :var table=[] :exports none
result = ''
for abbr in table:
result += "abbr {0} '{1}'\n".format(abbr[0], abbr[1])
return result.replace("\\vert{}", "|").replace("\\vert", "|")
#+BEGIN_SRC emacs-lisp :var table=[] :exports none :tangle no
(replace-regexp-in-string "\\\\vert[{}]*"
"|"
(mapconcat (lambda (x) (format "abbr %s '%s'" (car x) (cadr x)))
table
"\n")
t t)
#+END_SRC
** System monitoring

View File

@ -6,8 +6,8 @@
#+HTML_HEAD_EXTRA: <meta property="og:title" content="Phundrak's i3 config" />
#+HTML_HEAD_EXTRA: <meta property="og:description" content="Description of the i3 config file of Phundrak" />
#+PROPERTY: header-args :noweb yes :exports code :tangle ~/.config/i3/config :comments link
#+PROPERTY: header-args:python :exports none :tangle no
#+PROPERTY: header-args:emacs-lisp :exports code :tangle no
#+PROPERTY: header-args:emacs-lisp :exports none :tangle no
#+STARTUP: content
* Table of Contents :TOC:noexport:
:PROPERTIES:
@ -118,44 +118,42 @@
#+END_SRC
#+NAME: generate-variables
#+BEGIN_SRC python :var variables=variable-table :cache yes
result = ''
for line in variables:
result += "set {0} {1}\n".format(line[0], line[1])
return result
#+BEGIN_SRC emacs-lisp :var variables=variable-table :cache yes
(mapconcat (lambda (x) (format "set %s %s" (car x) (cadr x)))
variables
"\n")
#+END_SRC
#+RESULTS[187d9be7907abf05492d27a454685b424b933b7d]: generate-variables
: set $mod Mod4
: set $alt Mod1
: set $up Up
: set $down Down
: set $left Left
: set $right Right
: set $term st
#+RESULTS[2cd58c10c766632b4e8838fcb1b148d28a7daa60]: generate-variables
: set $mod Mod4
: set $alt Mod1
: set $up Up
: set $down Down
: set $left Left
: set $right Right
: set $term st
Finally, some variables hold some long strings for commands I dont want to
have to type multiple times.
#+NAME: generate-variables2
#+BEGIN_SRC python :var variables=variable-sh :cache yes
result = ''
for line in variables:
result += "set {0} \"{1}\"\n".format(line[0], line[1])
return result
#+BEGIN_SRC emacs-lisp :var variables=variable-sh :cache yes
(mapconcat (lambda (x) (format "set %s \"%s\"" (car x) (cadr x)))
variables
"\n")
#+END_SRC
#+RESULTS[13a3244099ec9233a8b7003c1874b3c92cb19e34]: generate-variables2
: set $exiti3 "i3-nagbar -t warning -m 'Leave i3?' -b 'Yes' 'i3-msg exit'"
: set $lockscreen "Lucien Cartier-Tilet\n(Phuntsok Drak-pa)\n+33 (0)6 83 90 56 89"
: set $rofiexec "rofi -combi-modi 'window,drun' -show combi -mohh combi -m -1 -show-icons"
: set $gnus "emacsclient --create-frame --eval '(gnus)' -n"
: set $ec "emacsclient --create-frame -n"
: set $walset "wal -i ~/Pictures/Wallpapers -o wal-set"
#+RESULTS[43d22c264f7972e7c2ab35ada0fb45aeb0bd17af]: generate-variables2
: set $exiti3 "i3-nagbar -t warning -m 'Leave i3?' -b 'Yes' 'i3-msg exit'"
: set $lockscreen "Lucien Cartier-Tilet\n(Phuntsok Drak-pa)\n+33 (0)6 83 90 56 89"
: set $rofiexec "rofi -combi-modi 'window,drun' -show combi -mohh combi -m -1 -show-icons"
: set $gnus "emacsclient --create-frame --eval '(gnus)' -n"
: set $ec "emacsclient --create-frame -n"
: set $walset "wal -i ~/Pictures/Wallpapers -o wal-set"
Here is the configuration:
#+BEGIN_SRC conf :noweb yes
<<generate-variables()>>
<<generate-variables2()>>
<<generate-variables()>>
<<generate-variables2()>>
#+END_SRC
Now comes the font for the window tiles. Honestly, this setting is useless
@ -313,14 +311,13 @@
#+END_SRC
#+NAME: generate-workspaces
#+BEGIN_SRC python :var workspaces=assignment-table :cache yes
results = ''
for line in workspaces:
results += 'assign [class="{0}"] {1}\n'.format(line[1],line[2])
return results
#+BEGIN_SRC emacs-lisp :var workspaces=assignment-table :cache yes
(mapconcat (lambda (x) (format "assign [class=\"%s\"] %s" (cadr x) (caddr x)))
workspaces
"\n")
#+END_SRC
#+RESULTS[bf7a728d0284d143edef023333680052cf1ff328]: generate-workspaces
#+RESULTS[0995341b013e50227edf78257ab502e46a30bc9a]: generate-workspaces
: assign [class="Emacs"] 2
: assign [class="Chromium"] 3
: assign [class="firefox"] 3
@ -368,11 +365,10 @@
#+END_SRC
#+NAME: generate-shortcuts
#+BEGIN_SRC python :exports none :var table=[] :eval yes :tangle no
results = ''
for line in table:
results += "bindsym {0} {1}\n".format(line[0], line[1])
return results
#+BEGIN_SRC emacs-lisp :exports none :var table=[] :tangle no
(mapconcat (lambda (x) (format "bindsym %s %s" (car x) (cadr x)))
table
"\n")
#+END_SRC
** Terminal shortcuts
@ -932,14 +928,35 @@
| no | redshift-gtk -O 3200 -t 1.0:0.8 | Blue light filter |
#+NAME: generate-autolaunch
#+BEGIN_SRC python :var table=autolaunch
results = ''
for line in table:
results += 'exec_always ' if line[0] == 'yes' else 'exec '
results += '--no-startup-id ' + line[1] + '\n'
return results
#+BEGIN_SRC emacs-lisp :exports none :cache yes :var table=autolaunch
(mapconcat (lambda (x)
(format (concat (if (string= (car x)
"yes")
"exec_always"
"exec")
" --no-startup-id %s")
(cadr x)))
table
"\n")
#+END_SRC
#+RESULTS[689797f24db25bc308e242006eacc1e1e6de6652]: generate-autolaunch
#+begin_example
exec_always --no-startup-id wal -i "$(< "${HOME}/.cache/wal/wal")"
exec --no-startup-id xss-lock -- i3lock -fol
exec --no-startup-id dunst -config ~/.config/dunst/dunstrc
exec --no-startup-id xrdb $HOME/.Xresources
exec --no-startup-id compton -F --opengl --config ~/.config/compton.conf -e 1
exec_always --no-startup-id polybar-launch
exec_always --no-startup-id enable_touch
exec --no-startup-id syndaemon -i 1.0 -t -k
exec --no-startup-id mpd
exec --no-startup-id mpc stop
exec --no-startup-id mpd_discord_richpresence --no-idle --fork
exec --no-startup-id nm-applet
exec --no-startup-id redshift-gtk -O 3200 -t 1.0:0.8
#+end_example
My travel laptop has a fingerprint reader which can be used as an
authentification method when the root password is asked. Lets launch our
policy kit manager if that is the case:

View File

@ -4,6 +4,7 @@
#+HTML_HEAD_EXTRA: <meta name="description" content="Phundrak's dotfiles" />
#+HTML_HEAD_EXTRA: <meta property="og:title" content="Phundrak's dotfiles" />
#+HTML_HEAD_EXTRA: <meta property="og:description" content="Description of the dotfiles of Phundrak" />
#+STARTUP: content
* Table of Contents :TOC:noexport:
:PROPERTIES:
@ -97,7 +98,7 @@
Emacs is a great operating system, it just lacks a good text editor.
#+end_quote
You can find my Emacs config, based on Spacemacs, in my [[https://labs.phundrak.com/phundrak/dotfiles/src/branch/master/.spacemacs][.spacemacs]] file, and
my user configuration in my [[file:~/org/config-website/spacemacs.org][spacemacs.org]] file.
my user configuration in my [[file:spacemacs.org][spacemacs.org]] file.
** Email signature
:PROPERTIES:

View File

@ -6,7 +6,8 @@
#+HTML_HEAD_EXTRA: <meta property="og:title" content="Phundrak-flavored Arch Linux" />
#+HTML_HEAD_EXTRA: <meta property="og:description" content="How to install a Phundrak-flavored Arch Linux" />
#+PROPERTY: header-args :exports code :comments link
#+PROPERTY: header-args:python :tangle no
#+PROPERTY: header-args:emacs-lisp :tangle no :exports none
#+STARTUP: content
* Table of Contents :TOC_4_gh:noexport:
:PROPERTIES:
@ -355,33 +356,66 @@
| tmux.org |
#+NAME: generate-tangle
#+BEGIN_SRC python :exports none :var files=tangled-files[,0] :cache yes
result = ''
commandPrintf = 'printf "\\n\\n==== Tangling {0}\\n\\n"\n'
commandEmacs = 'emacs -q --batch --eval "(require \'ob-tangle)" --eval "(setq org-confirm-babel-evaluate nil)" --eval "(org-babel-do-load-languages \'org-babel-load-languages \'((python . t)))" --eval "(org-babel-tangle-file \\"~/org/config/{0}\\")"\n'
for file in files:
result += commandPrintf.format(file) + commandEmacs.format(file)
return result
#+BEGIN_SRC emacs-lisp :exports none :var files=tangled-files[,0] :cache yes
(mapconcat (lambda (x) (concat
(format "printf '\\n\\n==== Tangling %s\\n\\n' && \\\n" x)
(concat "emacs -q --batch --eval '(require \\'ob-tangle)' \\\n"
"--eval '(setq org-confirm-babel-evaluate nil)' \\\n"
"--eval '(org-babel-do-load-languages \\'org-babel-load-languages \\'((python . t)))' \\\n"
(format "--eval '(org-babel-tangle-file \"~/org/config/%s\")'\n" x))))
files
"\n")
#+END_SRC
#+RESULTS[5f4c0ff55361ff7899541accb58b11496124e376]: generate-tangle
#+RESULTS[5a74a8854c2ed55bea68930073468d18d04bea08]: generate-tangle
#+begin_example
printf "\n\n==== Tangling bin.org\n\n"
emacs -q --batch --eval "(require 'ob-tangle)" --eval "(setq org-confirm-babel-evaluate nil)" --eval "(org-babel-do-load-languages 'org-babel-load-languages '((python . t)))" --eval "(org-babel-tangle-file \"~/org/config/bin.org\")"
printf "\n\n==== Tangling fish.org\n\n"
emacs -q --batch --eval "(require 'ob-tangle)" --eval "(setq org-confirm-babel-evaluate nil)" --eval "(org-babel-do-load-languages 'org-babel-load-languages '((python . t)))" --eval "(org-babel-tangle-file \"~/org/config/fish.org\")"
printf "\n\n==== Tangling i3.org\n\n"
emacs -q --batch --eval "(require 'ob-tangle)" --eval "(setq org-confirm-babel-evaluate nil)" --eval "(org-babel-do-load-languages 'org-babel-load-languages '((python . t)))" --eval "(org-babel-tangle-file \"~/org/config/i3.org\")"
printf "\n\n==== Tangling index.org\n\n"
emacs -q --batch --eval "(require 'ob-tangle)" --eval "(setq org-confirm-babel-evaluate nil)" --eval "(org-babel-do-load-languages 'org-babel-load-languages '((python . t)))" --eval "(org-babel-tangle-file \"~/org/config/index.org\")"
printf "\n\n==== Tangling nano.org\n\n"
emacs -q --batch --eval "(require 'ob-tangle)" --eval "(setq org-confirm-babel-evaluate nil)" --eval "(org-babel-do-load-languages 'org-babel-load-languages '((python . t)))" --eval "(org-babel-tangle-file \"~/org/config/nano.org\")"
printf "\n\n==== Tangling polybar.org\n\n"
emacs -q --batch --eval "(require 'ob-tangle)" --eval "(setq org-confirm-babel-evaluate nil)" --eval "(org-babel-do-load-languages 'org-babel-load-languages '((python . t)))" --eval "(org-babel-tangle-file \"~/org/config/polybar.org\")"
printf "\n\n==== Tangling spacemacs.org\n\n"
emacs -q --batch --eval "(require 'ob-tangle)" --eval "(setq org-confirm-babel-evaluate nil)" --eval "(org-babel-do-load-languages 'org-babel-load-languages '((python . t)))" --eval "(org-babel-tangle-file \"~/org/config/spacemacs.org\")"
printf "\n\n==== Tangling tmux.org\n\n"
emacs -q --batch --eval "(require 'ob-tangle)" --eval "(setq org-confirm-babel-evaluate nil)" --eval "(org-babel-do-load-languages 'org-babel-load-languages '((python . t)))" --eval "(org-babel-tangle-file \"~/org/config/tmux.org\")"
printf '\n\n==== Tangling bin.org\n\n' && \
emacs -q --batch --eval '(require \'ob-tangle)' \
--eval '(setq org-confirm-babel-evaluate nil)' \
--eval '(org-babel-do-load-languages \'org-babel-load-languages \'((python . t)))' \
--eval '(org-babel-tangle-file "~/org/config/bin.org")'
printf '\n\n==== Tangling fish.org\n\n' && \
emacs -q --batch --eval '(require \'ob-tangle)' \
--eval '(setq org-confirm-babel-evaluate nil)' \
--eval '(org-babel-do-load-languages \'org-babel-load-languages \'((python . t)))' \
--eval '(org-babel-tangle-file "~/org/config/fish.org")'
printf '\n\n==== Tangling i3.org\n\n' && \
emacs -q --batch --eval '(require \'ob-tangle)' \
--eval '(setq org-confirm-babel-evaluate nil)' \
--eval '(org-babel-do-load-languages \'org-babel-load-languages \'((python . t)))' \
--eval '(org-babel-tangle-file "~/org/config/i3.org")'
printf '\n\n==== Tangling index.org\n\n' && \
emacs -q --batch --eval '(require \'ob-tangle)' \
--eval '(setq org-confirm-babel-evaluate nil)' \
--eval '(org-babel-do-load-languages \'org-babel-load-languages \'((python . t)))' \
--eval '(org-babel-tangle-file "~/org/config/index.org")'
printf '\n\n==== Tangling nano.org\n\n' && \
emacs -q --batch --eval '(require \'ob-tangle)' \
--eval '(setq org-confirm-babel-evaluate nil)' \
--eval '(org-babel-do-load-languages \'org-babel-load-languages \'((python . t)))' \
--eval '(org-babel-tangle-file "~/org/config/nano.org")'
printf '\n\n==== Tangling polybar.org\n\n' && \
emacs -q --batch --eval '(require \'ob-tangle)' \
--eval '(setq org-confirm-babel-evaluate nil)' \
--eval '(org-babel-do-load-languages \'org-babel-load-languages \'((python . t)))' \
--eval '(org-babel-tangle-file "~/org/config/polybar.org")'
printf '\n\n==== Tangling spacemacs.org\n\n' && \
emacs -q --batch --eval '(require \'ob-tangle)' \
--eval '(setq org-confirm-babel-evaluate nil)' \
--eval '(org-babel-do-load-languages \'org-babel-load-languages \'((python . t)))' \
--eval '(org-babel-tangle-file "~/org/config/spacemacs.org")'
printf '\n\n==== Tangling tmux.org\n\n' && \
emacs -q --batch --eval '(require \'ob-tangle)' \
--eval '(setq org-confirm-babel-evaluate nil)' \
--eval '(org-babel-do-load-languages \'org-babel-load-languages \'((python . t)))' \
--eval '(org-babel-tangle-file "~/org/config/tmux.org")'
#+end_example
#+BEGIN_SRC fish :noweb yes
@ -816,11 +850,10 @@
| acomagu/fish-async-prompt | Make your prompt asynchronous to increase it reactivity |
#+NAME: fish-ext-py
#+BEGIN_SRC python :exports none :tangle no :var extensions=fish-extensions :cache yes
results = ''
for extension in extensions:
results += "fisher add {0}\n".format(extension[0])
return results
#+BEGIN_SRC emacs-lisp :exports none :tangle no :var extensions=fish-extensions[,0] :cache yes
(mapconcat (lambda (x) (format "fisher add %s" x))
extensions
"\n")
#+END_SRC
#+RESULTS[e82c7269c09b1d43a1a335a13c422b22b59079b1]: fish-ext-py

View File

@ -5,6 +5,7 @@
#+HTML_HEAD_EXTRA: <meta property="og:title" content="Phundrak's nano configuration" />
#+HTML_HEAD_EXTRA: <meta property="og:description" content="Description of the nano configuration of Phundrak" />
#+PROPERTY: header-args :tangle ~/.config/nano/nanorc
#+STARTUP: content
* Table of Contents :TOC_4_gh:noexport:
:PROPERTIES:

View File

@ -7,7 +7,9 @@
#+HTML_HEAD_EXTRA: <meta property="og:description" content="Description of the polybar config file of Phundrak" />
#+PROPERTY: header-args :exports none
#+PROPERTY: header-args:python :results output
#+PROPERTY: header-args:emacs-lisp :tangle no :exports none
#+PROPERTY: header-args:conf-windows :tangle ~/.config/polybar/config :noweb yes :exports code
#+STARTUP: content
* Table of Contents :TOC_4_gh:noexport:
:PROPERTIES:

View File

@ -5,6 +5,7 @@
#+HTML_HEAD_EXTRA: <meta property="og:title" content="Phundrak's Rust format config" />
#+HTML_HEAD_EXTRA: <meta property="og:description" content="Description of the Rust format config file of Phundrak" />
#+PROPERTY: header-args:toml :tangle ~/.rustfmt.toml :comments link
#+STARTUP: content
* Table of Contents :TOC:noexport:
:PROPERTIES:

View File

@ -6,6 +6,7 @@
#+HTML_HEAD_EXTRA: <meta property="og:title" content="Phundraks Spacemacs Configuration" />
#+HTML_HEAD_EXTRA: <meta property="og:description" content="Description of the Spacemacs configuration of Phundrak" />
#+PROPERTY: header-args: :mkdirp yes
#+STARTUP: content
* Table of Contents :TOC:noexport:
:PROPERTIES:

View File

@ -5,6 +5,7 @@
#+HTML_HEAD_EXTRA: <meta property="og:title" content="Phundrak's tmux config" />
#+HTML_HEAD_EXTRA: <meta property="og:description" content="Description of the tmux config file of Phundrak" />
#+PROPERTY: header-args :tangle ~/.tmux.conf.local
#+STARTUP: content
* Table of Contents :TOC_4_gh:noexport:
:PROPERTIES: