[Emacs] Cleaner init file export, fix some elisp code

However, I currently have the issue of the packages `org' having two
straight recipies and I cannot find the dependency that’s causing
this.
This commit is contained in:
Lucien Cartier-Tilet 2021-10-19 19:17:10 +02:00
parent 644f96305b
commit e30ca77fbe
Signed by: phundrak
GPG Key ID: BD7789E705CB8DCA

View File

@ -383,7 +383,7 @@ Doom-Emacs has some really nice macros that can come in really handy,
but since I prefer to rely on my own configuration, Ill instead just
copy their code here. First we get the ~after!~ macro:
#+begin_src emacs-lisp
(require 'cl)
(require 'cl-lib)
(defmacro after! (package &rest body)
"Evaluate BODY after PACKAGE have loaded.
@ -1403,7 +1403,7 @@ Paris 8 (my university).
Next I need an inbox dedicated to the association Im part of.
#+name: mu4e-bookmarks-filter-asso
#+headers: tangle no :cache yes
#+headers: :tangle no :cache yes
#+begin_src emacs-lisp
(let ((regex "/.*supran\\.fr/"))
<<mu4e-bookmarks-from-copy-to-gen>>)
@ -1637,7 +1637,7 @@ Lets enable them and set them:
#+end_src
#+name: mu4e-vertical-split
#+begin_src emacs-lisp
#+begin_src emacs-lisp :tangle no
(defun my/set-mu4e-headers-width ()
(let ((width (window-body-width))
(threshold (+ 120 80)))
@ -2276,6 +2276,7 @@ since been archived. New implementations then appeared, one of them is
#+begin_src emacs-lisp
(use-package parinfer-rust-mode
:defer t
:straight (:build t)
:diminish parinfer-rust-mode
:hook emacs-lisp-mode common-lisp-mode scheme-mode
:init
@ -2407,7 +2408,8 @@ display the latest commit message and its age about a file in the file
tree. And by default, I want ~dired-git-info~ to hide file details.
#+begin_src emacs-lisp
(use-package dired-git-info
:after dired
:after (dired)
:straight (:build t)
:hook (dired-after-reading . dired-git-info-auto-enable)
:general
(:keymaps 'dired-mode-map
@ -2420,8 +2422,8 @@ tree. And by default, I want ~dired-git-info~ to hide file details.
Diredfl makes dired colorful, and much more readable in my opinion.
#+begin_src emacs-lisp
(use-package diredfl
:after (dired all-the-icons)
:straight (:build t)
:after dired
:init
(diredfl-global-mode 1))
#+end_src
@ -2429,13 +2431,16 @@ Diredfl makes dired colorful, and much more readable in my opinion.
And lets add some fancy icons in dired!
#+begin_src emacs-lisp
(use-package all-the-icons-dired
:after (all-the-icons)
:straight (:build t)
:defer t
:hook (dired-mode . all-the-icons-dired-mode))
#+end_src
#+begin_src emacs-lisp
(use-package image-dired+
:after image-dired
:after (image-dired)
:straight (:build t)
:init (image-diredx-adjust-mode 1))
#+end_src
@ -2485,19 +2490,27 @@ Eshell is a built-in shell available from Emacs which I use almost as
often as fish. Some adjustments are necessary to make it fit my taste
though.
#+begin_src emacs-lisp
(general-define-key
:keymaps 'eshell-mode-map
(use-package eshell
:defer t
:straight (:type built-in :build t)
:general
(:keymaps 'eshell-mode-map
:states 'normal
"c" #'evil-backward-char
"t" #'evil-next-line
"s" #'evil-previous-line
"r" #'evil-forward-char)
(general-define-key
:keymaps 'eshell-mode-map
(:keymaps 'eshell-mode-map
:states 'insert
"C-a" #'eshell-bol
"C-e" #'end-of-line)
:config
<<eshell-alias-file>>
<<eshell-concat-shell-command>>
<<eshell-alias-open>>
<<eshell-alias-buffers>>
<<eshell-alias-emacs>>
<<eshell-alias-mkcd>>)
#+end_src
**** Aliases
@ -2506,14 +2519,16 @@ though.
:END:
First, lets declare our list of “dumb” aliases well use in
Eshell. You can find them here.
#+begin_src emacs-lisp
#+name: eshell-alias-file
#+begin_src emacs-lisp :tangle no
(setq eshell-aliases-file (expand-file-name "eshell-aliases" user-emacs-directory))
#+end_src
A couple of other aliases will be defined through custom Elisp
functions, but first Ill need a function for concatenating a shell
command into a single string:
#+begin_src emacs-lisp
#+name: eshell-concat-shell-command
#+begin_src emacs-lisp :tangle no
(defun phundrak/concatenate-shell-command (&rest command)
"Concatenate an eshell COMMAND into a single string.
All elements of COMMAND will be joined in a single
@ -2524,7 +2539,8 @@ space-separated string."
Ill also declare some aliases here, such as ~open~ and ~openo~ that
respectively allow me to open a file in Emacs, and same but in another
window.
#+begin_src emacs-lisp
#+name: eshell-alias-open
#+begin_src emacs-lisp :tangle no
(defalias 'open 'find-file)
(defalias 'openo 'find-file-other-window)
#+end_src
@ -2535,7 +2551,8 @@ my aliases file for stuff that could work too with other shells were
the syntax a bit different, and aliases related to Elisp are kept
programmatically. Ill also declare ~list-buffers~ an alias of ~ibuffer~
because naming it that way kind of makes more sense to me.
#+begin_src emacs-lisp
#+name: eshell-alias-buffers
#+begin_src emacs-lisp :tangle no
(defalias 'list-buffers 'ibuffer)
#+end_src
@ -2543,7 +2560,8 @@ I still have some stupid muscle memory telling me to open ~emacs~, ~vim~
or ~nano~ in Eshell, which is stupid: Im already inside Emacs and I
have all its power available instantly. So, lets open each file
passed to these commands.
#+begin_src emacs-lisp
#+name: eshell-alias-emacs
#+begin_src emacs-lisp :tangle no
(defun eshell/emacs (&rest file)
"Open each FILE and kill eshell.
Old habits die hard."
@ -2556,7 +2574,8 @@ Finally, Ill declare ~mkcd~ which allows the simultaneous creation of a
directory and moving into this newly created directory. And of course,
it will also work if the directory also exists or if parent
directories dont, similarly to the ~-p~ option passed to ~mkdir~.
#+begin_src emacs-lisp
#+name: eshell-alias-mkcd
#+begin_src emacs-lisp :tangle no
(defun eshell/mkcd (dir)
"Create the directory DIR and move there.
If the directory DIR doesnt exist, create it and its parents
@ -2651,6 +2670,7 @@ I fire up a terminal. I havent found anything that does that the way
I like it, so [[https://github.com/Phundrak/eshell-info-banner.el][Ive written a package]]!
#+begin_src emacs-lisp
(use-package eshell-info-banner
:after (eshell)
:defer t
:straight (eshell-info-banner :build t
:type git
@ -2666,8 +2686,9 @@ Another feature I like is fish-like syntax highlight, which brings
some more colors to Eshell.
#+begin_src emacs-lisp
(use-package eshell-syntax-highlighting
:after esh-mode
:after (esh-mode eshell)
:defer t
:straight (:build t)
:config
(eshell-syntax-highlighting-global-mode +1))
#+end_src
@ -2699,36 +2720,19 @@ a more human-readable name, see [[https://protesilaos.com/codelog/2021-10-15-ema
:PROPERTIES:
:CUSTOM_ID: Packages-Configuration-Emacs-built-ins-Info-r7x90j20c5j0
:END:
Something that irks me as I use evil and a leader key is that the
space bar is already bound to a function, ~Info-scroll-up~. Same goes
for my local leader ~,~ which is bound to ~Info-index-next~. I dont want
that, so lets unbind them:
Lets define some more intuitive keybinds for ~info-mode~.
#+begin_src emacs-lisp
(general-define-key
:keymaps '(Info-mode-map)
"SPC" nil
"," nil)
(general-define-key
:keymaps '(Info-mode-map)
:states 'normal
"SPC" nil
"," nil)
#+end_src
Alright, now that we correctly unbound them, my global leader key
works again, and Im free to use the comma as a local leader, so lets
do that:
#+begin_src emacs-lisp
(general-define-key
:keymaps 'Info-mode-map
(use-package info
:defer t
:straight (info :type built-in :build t)
:general
(:keymaps 'Info-mode-map
:states 'normal
"c" #'Info-prev
"t" #'evil-scroll-down
"s" #'evil-scroll-up
"r" #'Info-next)
(general-define-key
:keymaps 'Info-mode-map
(:keymaps 'Info-mode-map
:states 'normal
:prefix ","
"?" #'Info-toc
@ -2736,7 +2740,7 @@ do that:
"f" #'Info-history-forward
"m" #'Info-menu
"t" #'Info-top-node
"u" #'Info-up)
"u" #'Info-up))
#+end_src
*** Tramp
@ -2749,6 +2753,10 @@ various hosts using various protocols, such as ~ssh~ and
supported natively. I will describe them here.
#+begin_src emacs-lisp
(require 'tramp)
(use-package tramp
:straight (tramp :type built-in :build t)
:init
<<tramp-add-yadm>>)
#+end_src
**** Yadm
@ -2760,7 +2768,8 @@ loads of features I dont use (the main one I like but dont use is
its [[https://yadm.io/docs/templates][Jinja-like host and OS-aware syntax]]), but unfortunately Magit
doesnt play nice with it. Tramp to the rescue, and this page explains
how! Lets just insert in my config this code snippet:
#+begin_src emacs-lisp
#+name: tramp-add-yadm
#+begin_src emacs-lisp :tangle no
(add-to-list 'tramp-methods
'("yadm"
(tramp-login-program "yadm")
@ -2844,6 +2853,15 @@ enhances a couple of built-in functions from Emacs, namely:
:PROPERTIES:
:CUSTOM_ID: Packages-Configuration-Org-modedw35fl6184j0
:END:
Since recently, in order to make ~org-cite~ compile properly, we need
the ~citeproc~ package, a citation processor.
#+begin_src emacs-lisp
(use-package citeproc
:after (org)
:defer t
:straight (:build t))
#+end_src
Org is the main reason I am using Emacs. It is an extremely powerfu
tool when you want to write anything that is not necessarily primarily
programming-related, though it absolutely can be! Org can be a
@ -2906,7 +2924,9 @@ extended however we like!
<<org-latex-listings>>
<<org-latex-default-packages>>
<<org-export-latex-hyperref-format>>
<<org-export-latex-minted-options>>
<<org-latex-pdf-process>>
<<org-latex-logfiles-add-extensions>>
<<org-re-reveal-root>>
<<org-html-validation>>
<<org-latex-classes>>
@ -2941,7 +2961,7 @@ comfortable than the default ones you get with evil and org naked.
#+begin_src emacs-lisp
(use-package evil-org
:straight (:build t)
:after org
:after (org)
:hook (org-mode . evil-org-mode)
:config
(setq-default evil-org-movement-bindings
@ -2961,7 +2981,6 @@ trees, converting translitterated text to its native script, etc…
(use-package conlanging
:straight (conlanging :build t
:type git
:host nil
:repo "https://labs.phundrak.com/phundrak/conlanging.el")
:after org
:defer t)
@ -2974,6 +2993,8 @@ it. The main reason I want ~org-contrib~ is due to ~ox-extra~ that allow
the usage of the ~:ignore:~ tag in org.
#+begin_src emacs-lisp
(use-package org-contrib
:after (org)
:defer t
:straight (:build t)
:init
(require 'ox-extra)
@ -3011,7 +3032,7 @@ for org files that will be hosted and viewable on Github.
~electric-mode~ also bothers me a lot when editing org files, so lets deactivate it:
#+name: org-behavior-electric
#+begin_src emacs-lisp
#+begin_src emacs-lisp :tangle no
(add-hook 'org-mode-hook (lambda ()
(interactive)
(electric-indent-local-mode -1)))
@ -3046,6 +3067,7 @@ to easily convert a LaTeX snippet into a PNG, regardless of the
exporter I use afterwards. Its installation is pretty simple:
#+begin_src emacs-lisp
(use-package ob-latex-as-png
:after (org)
:straight (:build t)
:defer t)
#+end_src
@ -3075,7 +3097,7 @@ activated. Here are the languages I activated in my Org-mode configuration:
#+NAME: org-babel-languages-gen
#+header: :cache yes :results replace
#+header: :var languages=org-babel-languages-table[,0]
#+BEGIN_SRC emacs-lisp :exports none
#+BEGIN_SRC emacs-lisp :exports none :tangle no
(format "'(%s)"
(mapconcat (lambda ($language)
(format "(%s . t)" $language))
@ -3121,7 +3143,6 @@ describing phonetics evolution. So, lets disable it:
(setq org-use-sub-superscripts (quote {}))
#+END_SRC
**** Epub
:PROPERTIES:
:CUSTOM_ID: Packages-Configuration-Org-mode-File-export-Epub-w5ycfuz095j0
@ -3130,7 +3151,7 @@ A backend for exporting files through org I like is ~ox-epub~ which, as
you can guess, exports org files to the [[https://www.w3.org/publishing/epub32/][Epub format]].
#+begin_src emacs-lisp
(use-package ox-epub
:after ox
:after (org ox)
:straight (:build t))
#+end_src
@ -3141,20 +3162,21 @@ you can guess, exports org files to the [[https://www.w3.org/publishing/epub32/]
For Reveal.JS exports, I need to set where to find the framework by
default:
#+NAME: org-re-reveal-root
#+BEGIN_SRC emacs-lisp
#+BEGIN_SRC emacs-lisp :tangle no
(setq org-re-reveal-root "https://cdn.jsdelivr.net/npm/reveal.js")
#+END_SRC
On HTML exports, Org-mode tries to include a validation link for the
exported HTML. Lets disable that since I never use it.
#+NAME: org-html-validation
#+BEGIN_SRC emacs-lisp
#+BEGIN_SRC emacs-lisp :tangle no
(setq org-html-validation-link nil)
#+END_SRC
#+begin_src emacs-lisp
(use-package htmlize
:defer t)
;; (use-package htmlize
;; :defer t
;; :straight (:build t))
#+end_src
This package allows for live-previewing the HTML export of an org
@ -3164,7 +3186,7 @@ files.
#+begin_src emacs-lisp
(use-package preview-org-html-mode
:defer t
:after org
:after (org)
:straight (preview-org-html-mode :build t
:type git
:host github
@ -3189,14 +3211,14 @@ When it comes to exports, I want the LaTeX and PDF exports to be done
with XeLaTeX only. This implies the modification of the following
variable:
#+NAME: org-latex-compiler
#+BEGIN_SRC emacs-lisp
#+BEGIN_SRC emacs-lisp :tangle no
(setq org-latex-compiler "xelatex")
#+END_SRC
I also want to get by default ~minted~ for LaTeX listings so I can have
syntax highlights:
#+NAME: org-latex-listings
#+BEGIN_SRC emacs-lisp
#+BEGIN_SRC emacs-lisp :tangle no
(setq org-latex-listings 'minted)
#+END_SRC
@ -3211,7 +3233,7 @@ packages:
- ~booktabs~ for nicer tables
- and ~tabularx~ for tabulars with adjustable columns
#+NAME: org-latex-default-packages
#+BEGIN_SRC emacs-lisp
#+BEGIN_SRC emacs-lisp :tangle no
(dolist (package '(("AUTO" "inputenc" t ("pdflatex"))
("T1" "fontenc" t ("pdflatex"))
("" "grffile" t)))
@ -3230,13 +3252,13 @@ packages:
By the way, reference links in LaTeX should be written in this format,
since we are using ~cleveref~:
#+NAME: org-export-latex-hyperref-format
#+BEGIN_SRC emacs-lisp
#+BEGIN_SRC emacs-lisp :tangle no
(setq org-export-latex-hyperref-format "\\ref{%s}")
#+END_SRC
And Minted should be default break lines if a line is too long:
#+name: org-export-latex-minted-options
#+begin_src emacs-lisp
#+begin_src emacs-lisp :tangle no
(setq org-latex-minted-options '(("breaklines")
("tabsize" "2")
("frame" "single")
@ -3247,7 +3269,7 @@ When it comes to the export itself, the latex file needs to be
processed several times through XeLaTeX in order to get some
references right. Dont forget to also run bibtex!
#+NAME: org-latex-pdf-process
#+BEGIN_SRC emacs-lisp
#+BEGIN_SRC emacs-lisp :tangle no
(setq org-latex-pdf-process
'("xelatex -8bit -shell-escape -interaction nonstopmode -output-directory %o %f"
"bibtex %b"
@ -3258,7 +3280,8 @@ references right. Dont forget to also run bibtex!
Finally, org-mode is supposed to automatically clean logfiles after it
exports an org file to LaTeX. However, it misses a few, so I need to
add their extension like so:
#+begin_src emacs-lisp
#+name: org-latex-logfiles-add-extensions
#+begin_src emacs-lisp :tangle no
(dolist (ext '("bbl" "lot"))
(add-to-list 'org-latex-logfiles-extensions ext t))
#+end_src
@ -3275,7 +3298,7 @@ theres a package for exporting my org files to Github-flavored
Markdown!
#+begin_src emacs-lisp
(use-package ox-gfm
:after ox
:after (ox org)
:straight (:build t))
#+end_src
@ -3288,7 +3311,7 @@ Yet another exporter I enjoy is [[https://github.com/dantecatalfamo/ox-ssh][~ox-
servers on my repos though.
#+begin_src emacs-lisp
(use-package ox-ssh
:after ox
:after (ox org)
:straight (:build t))
#+end_src
@ -3658,8 +3681,8 @@ The project is then defined like so:
#+begin_src emacs-lisp
(use-package org-ref
:after (org ox-bibtex pdf-tools)
:straight (:build t)
:after (org ox-bibtex)
:demand t
:custom-face
(org-ref-cite-face ((t (:weight bold))))
@ -3746,7 +3769,7 @@ org-mode. ~mixed-pitch~ comes to the rescue!
#+begin_src emacs-lisp
(use-package mixed-pitch
:after org
:straight t
:straight (:build t)
:hook
(org-mode . mixed-pitch-mode)
:config
@ -3838,8 +3861,8 @@ icons!
/Org Outline Tree/ is a better way of managing my org files outline.
#+begin_src emacs-lisp
(use-package org-ol-tree
:after (org avy)
:defer t
:after org
:straight (org-ol-tree :build t
:host github
:type git
@ -4385,7 +4408,6 @@ comma.
:hook (lua-mode . lsp-deferred)
:config
(setq lsp-lua-emmy-jar-path (expand-file-name "EmmyLua-LS-all.jar" user-emacs-directory)))
#+end_src
**** Python
@ -4968,7 +4990,6 @@ either in Emacs or in an external web browser. I prefer the defaults.
:defer t
:straight (archwiki :build t
:type git
:host nil
:repo "https://labs.phundrak.com/phundrak/archwiki.el"))
#+end_src
@ -5085,7 +5106,6 @@ which resolution to play a YouTube video in an external video player.
:defer t
:straight (ytplay :build t
:type git
:host nil
:repo "https://labs.phundrak.com/phundrak/ytplay.el"))
#+end_src
@ -5097,6 +5117,7 @@ Undefining some stuff to make keybind prefixes work correctly.
#+begin_src emacs-lisp
(general-define-key
:keymaps '(Buffer-menu-mode-map
Info-mode-map
Man-mode-map
backtrace-mode-map
custom-mode-map
@ -5117,7 +5138,8 @@ Undefining some stuff to make keybind prefixes work correctly.
splash-screen-keymap
undo-tree-visualizer-mode-map)
:states '(emacs normal motion)
"SPC" nil)
"SPC" nil
"," nil)
(general-define-key
:keymaps 'global-map