Skip to content

Latest commit

 

History

History
243 lines (211 loc) · 7.79 KB

config.org

File metadata and controls

243 lines (211 loc) · 7.79 KB

Carlos’ Doom Emacs config

About

This is my Doom Emacs config. It requires src_emacs-lisp[:eval no :tangle no :exports code]{:config literate} to be enabled in init.el.

Remember that you don’t have to run src_sh[:tangle no :eval no :exports code]{doom sync} after modifying this file.

Emacs headers

First of all, we enable lexical binding. This is the default for Doom Emacs config files and you can see the differences with dynamic binding here.

;;; $DOOMDIR/config.el -*- lexical-binding: t; -*-

Personal information

Many packages require the full name and email address to be stored in these variables.

(setq user-full-name "Carlos José Ruiz-Henestrosa Ruiz"
      user-mail-address "ruizh.cj@gmail.com")

Fonts

Doom exposes five (optional) variables for controlling fonts in Doom. Here are the three important ones:

  • src_emacs-lisp[:eval no :tangle no :exports code]{doom-font}
  • src_emacs-lisp[:eval no :tangle no :exports code]{doom-variable-pitch-font}
  • src_emacs-lisp[:eval no :tangle no :exports code]{doom-big-font}, used for src_emacs-lisp[:eval no :tangle no :exports code]{doom-big-font-mode}; use this for presentations or streaming.

They all accept either a font-spec, font string (=”Input Mono-12”=), or xlfd font string.

(setq doom-font (font-spec :family "Fira Code" :size 16))

Theme

There are two ways to load a theme. Both assume the theme is installed and available. You can either set `doom-theme’ or manually load a theme with the `load-theme’ function. This is the default:

(setq doom-theme 'doom-dracula)

Org

(setq org-directory "~/org/")

(after! org
  (setq org-agenda-start-on-weekday 1)
  (setq calendar-week-start-day 1)
  (add-to-list 'org-latex-packages-alist '("AUTO" "babel"       t ("pdflatex")))
  (add-to-list 'org-latex-packages-alist '("AUTO" "polyglossia" t ("xelatex" "lualatex"))))

org-noter

(use-package! org-noter
  :after (:any org pdf-view)
  :config
  (setq
   org-noter-notes-window-location 'other-frame
   org-noter-always-create-frame nil
   org-noter-hide-other nil
   org-noter-notes-search-path (list "/home/cj/org/notes/")))

org-ref

org-ref is an org-mode module for citations and bibliographies en org-mode with bibtex support. It is not currently part of any Doom Emacs modules, so we have to install it separately:

(package! org-ref)

We only load the package after org and set the PDF opener to the default. There are more options in the README.

(use-package! org-ref
  :after org
  :config

Files

(setq org-ref-pdf-directory "~/Documentos/bibliography/bibtex-pdfs/"
      org-ref-default-bibliography "~/Documentos/bibliography/references.bib")

Bibtex

(setq bibtex-completion-bibliography org-ref-default-bibliography
      bibtex-completion-library-path "~/Documentos/bibliography/bibtex-pdfs")

Completion functions

;; (setq bibtex-completion-pdf-open-function 'org-open-file)

LaTeX export

(setq org-latex-pdf-process (list "latexmk -shell-escape -bibtex -f -pdf %f"))
)

HTML export

For HTML export I use ox-twbs.

(package! ox-twbs)

Appearance

;; This determines the style of line numbers in effect. If set to `nil', line
;; numbers are disabled. For relative line numbers, set this to `relative'.
(setq display-line-numbers-type 'relative)

LaTeX (auctex)

(after! latex

First, we set TeX-electric-math so that pressing $ writes $...$ in plain TeX files and \(...\) in LaTeX files.

(setq-hook! 'plain-tex-mode-hook
  TeX-electric-math (cons "$" ""))
(setq-hook! 'LaTeX-mode-hook
  TeX-electric-math (cons "\\(" ""))

Enable LaTeX-math-mode (for fast mathematical input)

(add-hook 'LaTeX-mode-hook 'LaTeX-math-mode)

LaTeX-math-abbrev-prefix needs to be set through customize. doom provides setq! to help with this, but I can’t seem to get it to work. See https://lists.gnu.org/archive/html/help-gnu-emacs/2008-06/msg00651.html for the suggestion and (defcustom LaTeX-math-abbrev-prefix "`"= near [[file://~/.emacs.d/.local/straight/repos/auctex/latex.el:4722][auctex/latex.el:4722]] for the explanation of what using =customize does.

If it did work, we could just do this:

(setq! LaTeX-math-abbrev-prefix "ç")
(add-hook 'LaTeX-math-mode-hook
          (customize-set-variable 'LaTeX-math-abbrev-prefix "ç"))

But instead we have to do everything manually.

(add-hook! 'LaTeX-math-mode-hook
  (define-key LaTeX-math-mode-map
    (LaTeX-math-abbrev-prefix) t)                  ; Unbind "`"
  (set-default 'LaTeX-math-abbrev-prefix "ç")      ; Set "ç" as new prefix
  (define-key LaTeX-math-mode-map
    (LaTeX-math-abbrev-prefix) LaTeX-math-keymap)) ; Bind "ç"

Finally we close the src_emacs-lisp[:eval no :tangle no :exports code]{after! latex} block:

)

Python (conda)

(after! conda
  (setq conda-anaconda-home "~/.conda"))

;; (after! python
;;   (setq python-shell-interpreter "ipython"))

Hideshow

(after! hideshow
  (add-to-list 'hs-special-modes-alist
               '(conf-mode "{{{" "}}}" "\"")))

Emacs-pGTK

I run emacs-pgtk, which doesn’t recognise some dead keys by default. Fortunately, we can fix that by running:

(when (eq window-system 'pgtk)
  (pgtk-use-im-context t))

R (ess)

(after! ess-r-mode
  (appendq! +pretty-code-symbols
            '(:assign ""
              :multiply "×"))
  (set-pretty-symbols! 'ess-r-mode
    ;; Functional
    :def "function"
    ;; Types
    :null "NULL"
    :true "TRUE"
    :false "FALSE"
    :int "int"
    :float "float"
    :bool "bool"
    ;; Flow
    :not "!"
    :and "&&" :or "||"
    :for "for"
    :in "%in%"
    :return "return"
    ;; Other
    :assign "<-"
    :multiply "%*%"))

Email (mu4e)

(after! mu4e
  (setq mu4e-view-use-gnus t)
  ;; Each path is relative to `+mu4e-mu4e-mail-path', which is ~/.mail by default
  (set-email-account! "GMail"
    '((mu4e-sent-folder       . "/gmail/[Gmail]/Enviados")
      (mu4e-drafts-folder     . "/gmail/[Gmail]/Borradores")
      (mu4e-trash-folder      . "/gmail/[Gmail]/Papelera")
      (mu4e-refile-folder     . "/gmail/[Gmail]/Todos")
      (smtpmail-smtp-user     . "ruizh.cj@gmail.com")
      (mu4e-compose-signature . "--\nCarlos José Ruiz-Henestrosa Ruiz")) t))

Other

(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(safe-local-variable-values '((TeX-engine . xelatex))))
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 )