[Emacs] Add swift to org-babel languages, neater noweb code

This commit is contained in:
Lucien Cartier-Tilet 2020-12-27 19:00:30 +01:00
parent 4ccab5440a
commit b9d4d6b180
Signed by: phundrak
GPG Key ID: BD7789E705CB8DCA

View File

@ -2082,19 +2082,22 @@ One of the amazing features of org-mode is its literary programming capacities b
| sass | | sass |
| scheme | | scheme |
| shell | | shell |
| swift |
#+NAME: org-babel-languages-gen #+NAME: org-babel-languages-gen
#+header: :cache yes :results replace #+header: :cache yes :results replace
#+header: :var languages=org-babel-languages-table[,0] #+header: :var languages=org-babel-languages-table[,0]
#+BEGIN_SRC emacs-lisp :exports none #+BEGIN_SRC emacs-lisp :exports none
(mapconcat (lambda ($language) (format "(%s . t)" $language)) (format "'(%s)"
(mapconcat (lambda ($language)
(format "(%s . t)" $language))
languages languages
"\n") "\n "))
#+END_SRC #+END_SRC
#+RESULTS[0e796575005954e09cc4c2ce54d4bbf93364e45d]: org-babel-languages-gen #+RESULTS[498fc46efb1de59954f758ca3d9869ea6a73dad9]: org-babel-languages-gen
#+begin_example #+begin_src emacs-lisp
(C . t) '((C . t)
(dot . t) (dot . t)
(emacs-lisp . t) (emacs-lisp . t)
(gnuplot . t) (gnuplot . t)
@ -2105,15 +2108,15 @@ One of the amazing features of org-mode is its literary programming capacities b
(sass . t) (sass . t)
(scheme . t) (scheme . t)
(shell . t) (shell . t)
#+end_example (swift . t))
#+end_src
The corresponding code is as follows: The corresponding code is as follows:
#+NAME: org-babel-load-languages #+NAME: org-babel-load-languages
#+BEGIN_SRC emacs-lisp :noweb yes #+BEGIN_SRC emacs-lisp :noweb yes
(org-babel-do-load-languages (org-babel-do-load-languages
'org-babel-load-languages 'org-babel-load-languages
'( <<org-babel-languages-gen()>>)
<<org-babel-languages-gen()>>))
#+END_SRC #+END_SRC
Scheme requires a default implementation for geiser: Scheme requires a default implementation for geiser:
@ -2458,6 +2461,7 @@ The following code snipped is not tangled into my configuration file, but instea
#+NAME: org-capture-shortcut-gen #+NAME: org-capture-shortcut-gen
#+header: :exports code :cache yes :results replace #+header: :exports code :cache yes :results replace
#+BEGIN_SRC emacs-lisp :var table=org-capture-shortcuts-table #+BEGIN_SRC emacs-lisp :var table=org-capture-shortcuts-table
(format "'(%s)"
(mapconcat (lambda (entry) (mapconcat (lambda (entry)
(let* ((shortcut (nth 0 entry)) (let* ((shortcut (nth 0 entry))
(name (nth 1 entry)) (name (nth 1 entry))
@ -2472,12 +2476,12 @@ The following code snipped is not tangled into my configuration file, but instea
(if (string= "file+datetree" insertmode) "" (if (string= "file+datetree" insertmode) ""
(format " \"%s\"" (if (string= "" title) name title)))) (format " \"%s\"" (if (string= "" title) name title))))
(format " (file \"~/org/capture/%s\"))" sourceorg)))) ) (format " (file \"~/org/capture/%s\"))" sourceorg)))) )
table "\n") table "\n "))
#+END_SRC #+END_SRC
#+RESULTS[5826faa0521c58664ddeedcf44b88910dbd344b6]: org-capture-shortcut-gen #+RESULTS[1fec26dc1d0158ebcaf9b282eb997901321593fa]: org-capture-shortcut-gen
#+begin_example #+begin_example
("e" "Email") '(("e" "Email")
("ew" "Write Email" entry ("ew" "Write Email" entry
(file+headline org-default-notes-file "Emails") (file+headline org-default-notes-file "Emails")
(file "~/org/capture/emails.orgcaptmpl")) (file "~/org/capture/emails.orgcaptmpl"))
@ -2545,7 +2549,7 @@ The following code snipped is not tangled into my configuration file, but instea
(file "~/org/capture/health.orgcaptmpl")) (file "~/org/capture/health.orgcaptmpl"))
("ti" "Informatique" entry ("ti" "Informatique" entry
(file+headline org-private-agenda-file "Informatique") (file+headline org-private-agenda-file "Informatique")
(file "~/org/capture/informatique.orgcaptmpl")) (file "~/org/capture/informatique.orgcaptmpl")))
#+end_example #+end_example
Below you can find the equivalent code as described above. Below you can find the equivalent code as described above.
@ -2553,9 +2557,7 @@ Below you can find the equivalent code as described above.
#+BEGIN_SRC emacs-lisp :noweb yes #+BEGIN_SRC emacs-lisp :noweb yes
(setq (setq
org-capture-templates org-capture-templates
'( <<org-capture-shortcut-gen()>>)
<<org-capture-shortcut-gen()>>
))
#+END_SRC #+END_SRC
You may notice a capture entry for my journal, and this is due to the fact I do not use ~org-journal~ anymore: it was too overpowered for me, and I prefer to keep it simple with a single file. And as you can see, and unlike a lot of other Emacs configurations, the content of the template is not set in the variable, but in external files which can be modified freely as actual Org buffers instead of trying to get a proper one with loads of ~\n~ characters and such. All these templates are declared below. You may notice a capture entry for my journal, and this is due to the fact I do not use ~org-journal~ anymore: it was too overpowered for me, and I prefer to keep it simple with a single file. And as you can see, and unlike a lot of other Emacs configurations, the content of the template is not set in the variable, but in external files which can be modified freely as actual Org buffers instead of trying to get a proper one with loads of ~\n~ characters and such. All these templates are declared below.