Org mode Emacs Config

Table of Contents

Playing with Org mode. I realy should make some cool examples. Org is the greatest invention of humanity, realy.

1 Org sepcial blocks

I implement some js to enumarate in web blocks such as theorems, definitions, etc. It works for both: \(\LaTeX\) and html export

1.1 Examples

#+begin_theorem
Some realy cool theorem
#+end_theorem
#+begin_proof
The proof of some realy cool theorem
#+end_proof

#+begin_theorem
Some other cool theorem
#+end_theorem

Some realy cool theorem

The proof of some realy cool theorem

Some other cool theorem

2 Emacs config

Using emacs-native-comp-git from AUR for improving performance. Consider running in daemon mode, because the startup time stil not very good.

Speeding up 🐌

  • Enabling native compilation
  • This sets the garbage collector to invoke every 100Mb instead of default 800Kb
(setq comp-deferred-compilation t)
(setq gc-cons-threshold 100000000)

2.1 Main config

2.1.1 Repositories

There is initializes package mangers and initializing use-package
Package config – see https://melpa.org/#/getting-started

(require 'package)
(add-to-list
 'package-archives
 '("melpa" . "https://melpa.org/packages/")
 t)
(package-initialize)

(unless (package-installed-p 'use-package)
  (package-refresh-contents)
  (package-install 'use-package))

Adding folder with manually added packages, loading file private variables

  • store all backups in a single directory
(add-to-list 'load-path "~/.emacs.d/lisp/")
(load "~/.emacs.d/private.el")
(setq user-init-file "~/.emacs.d/init.el")
(setq backup-directory-alist
      `(("." . ,(concat user-emacs-directory "backups"))))

Extending executable path

(add-to-list 'exec-path "~/.local/bin")

2.2 Packages

Speeding up again 🦼

(use-package gcmh
  :ensure t
  :init
  (gcmh-mode 1))

2.2.1 Projects

Projects management with counsel completion

(use-package projectile
  :ensure t
  :config
  (projectile-mode))
(use-package counsel-projectile
  :ensure t)

Amazing git tool

(use-package magit
  :ensure t)

Project tree

(use-package treemacs
  :ensure t)
(use-package treemacs-evil
  :after evil
  :ensure t)
(use-package treemacs-projectile
  :after projectile
  :ensure t)

Settings fonts for treemacs

(dolist (face '(treemacs-root-face
                treemacs-git-unmodified-face
                treemacs-git-modified-face
                treemacs-git-renamed-face
                treemacs-git-ignored-face
                treemacs-git-untracked-face
                treemacs-git-added-face
                treemacs-git-conflict-face
                treemacs-directory-face
                treemacs-directory-collapsed-face
                treemacs-file-face
                treemacs-tags-face))
  (set-face-attribute face nil :family "Fira Code" :height 85))

2.2.2 Evil mode

Evil with dependecies

(setq evil-want-keybinding nil)
(use-package undo-tree
  :ensure t)
(use-package goto-chg
  :ensure t)
(use-package evil
  :ensure t
  :init
  (setq evil-want-integration t)
  :config
  (evil-mode 1))

Collection of evil keybindings

(use-package evil-collection
  :after evil
  :ensure t
  :config
  (evil-collection-init))

Fast search

(use-package evil-snipe
  :ensure t
  :config
  (evil-snipe-mode +1)
  (evil-snipe-override-mode +1))

Change brakets in evil mode

(use-package evil-surround
  :ensure t
  :config
  (global-evil-surround-mode 1))

Multicursor

(use-package evil-multiedit
  :ensure t)
(use-package evil-mc
  :ensure t
  :config
  (global-evil-mc-mode 1))
2.2.2.1 Settings

Disable Evil mode for some modes

(add-to-list 'evil-emacs-state-modes 'elfeed-search)
(cl-loop for (mode . state) in '((dired-mode . emacs) (elfeed-search . emacs))
         do (evil-set-initial-state mode state))

2.2.3 Visual

Icons

(use-package all-the-icons
 :ensure t)

HIghlight todo keywords

(use-package hl-todo
  :ensure t
  :config
  (global-hl-todo-mode t))

Colorize parenthesis

(use-package rainbow-delimiters
  :ensure t
  :hook (prog-mode . rainbow-delimiters-mode))

Searching

(use-package avy
  :ensure t)

Windows hoping

(use-package ace-window
  :ensure t)

Dashboard showing on startup

(use-package dashboard
  :ensure t
  :config
  (dashboard-setup-startup-hook))
2.2.3.1 Themes

Doom-modeline as modeline

(use-package doom-modeline
  :ensure t
  :init 
  (doom-modeline-mode 1)
  :config
  (setq doom-modeline-icon t))

Colors from pywal

(use-package ewal
  :ensure t
  :init (setq ewal-use-built-in-always nil
              ewal-use-built-in-on-failure-p t
              ewal-built-in-palette "doom-gruvbox"))
(use-package ewal-doom-themes
  :ensure t)

Or doom theme

(use-package doom-themes
  :ensure t
  :preface (defvar region-fg nil)
  (setq doom-themes-treemacs-theme "doom-colors")
  (doom-themes-treemacs-config)
  (doom-themes-org-config)
  :init (load-theme 'doom-molokai t))
2.2.3.2 Settings
  • Visual/behaviour
  • Dashboard
(defun init-hooks () (global-display-line-numbers-mode 1))
(scroll-bar-mode 0) ; no scroll bar
(tool-bar-mode 0) ; no tool bar
(menu-bar-mode 0) ; no menu bar
(show-paren-mode 1) ; visualize matching parenthesees
(global-hl-line-mode 1) ; highlight current line
(eldoc-mode 1) ; enable docs in minibuffer

(set-face-attribute 'default nil
                    :family "Fira Code"
                    :height 85)

(setq company-math-allow-latex-symbols-in-faces t)

(setq initial-buffer-choice (lambda () (get-buffer-create "*dashboard*")))
(setq dashboard-center-content t)
(setq dashboard-startup-banner "~/Themes/Neofetch.png")
(setq dashboard-set-heading-icons t)
(setq dashboard-set-file-icons t)

(setq dashboard-items '((recents  . 5)
                                        ;(bookmarks . 5)
                        (projects . 5)
                        (agenda . 5)
                        (registers . 5)))

(add-hook 'after-init-hook 'init-hooks)
  • y or n instead of yes-or no
  • no annoying bell!
  • setting ace-window keys
  • isearch
(fset 'yes-or-no-p 'y-or-n-p)
(setq ring-bell-function 'ignore)
(setq aw-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l))

(define-key isearch-mode-map (kbd "<down>") 'isearch-ring-advance)
(define-key isearch-mode-map (kbd "<up>") 'isearch-ring-retreat)
(setq case-fold-search t)

Treat _ as work(vim variant)

(modify-syntax-entry ?_ "w") 

2.2.4 Keybingings

Convenient keybindings

(use-package general
  :ensure t)

Constructing menus

(use-package hydra
  :ensure t)

Keys hints

(use-package which-key
  :ensure t
  :config
  (which-key-mode 1))

2.2.5 Programming

Code::stats

(use-package code-stats
  :ensure t)

Auto parenthesis

(use-package smartparens
  :ensure t
  :init
  (smartparens-global-mode))

Editconfig support

(use-package editorconfig
  :ensure t
  :config
  (editorconfig-mode 1))

Snippets

(use-package yasnippet
  :ensure t
  :init
  (yas-global-mode 1))
(use-package yasnippet-snippets
  :ensure t)

Code formatting

(use-package format-all
  :ensure t)

Dockerfile support

  (use-package dockerfile-mode
    :ensure t)

Package for html live view

(use-package impatient-mode
  :ensure t)

Cool web stuff

(use-package web-mode
  :ensure t)
2.2.5.1 Auto completion

Use company for autocompletion

(use-package company
  :ensure t
  :init
  (add-hook 'after-init-hook 'global-company-mode)
  :config
  (setq company-dabbrev-downcase 0)
  (setq company-idle-delay 0)
  (setq company-minimum-prefix-length 2)
  (setq company-tooltip-align-annotations t)
  (setq company-backends 
        '(company-capf 
          ;; company-bbdb 
          ;; company-clang 
          ;; company-keywords 
          company-yasnippet 
          ;; company-lsp 
          ;; company-files 
          ;; company-ctags
          ;; company-anaconda
          )))

Add snippets to company backends

(defun mars/company-backend-with-yas (backends)
  "Add :with company-yasnippet to company BACKENDS.
  Taken from https://github.com/syl20bnr/spacemacs/pull/179."
  (if (and (listp backends) (memq 'company-yasnippet backends))
      backends
    (append (if (consp backends)
                backends
              (list backends))
            '(:with company-yasnippet))))

(defun add-yas-in-company ()
  (setq company-backends
        (mapcar #'mars/company-backend-with-yas company-backends)))

(add-yas-in-company)

Lsp backend for company

(use-package company-lsp
  :after lsp-mode
  :ensure t
  :config
  (push 'company-lsp company-backends)
  (setq company-lsp-enable-snippet t)
  (setq lsp-enable-snippet t))

Completion for M-x commands

(use-package counsel
  :ensure t
  :init
  (ivy-mode 1))
2.2.5.2 Languages and lsp

Lsp client. Speeding up 🛹, adding folders to not track.
Add to hook (XXX-mode . lsp) for auto enabling lsp on XXX-mode

(use-package  lsp-mode
  :hook (
         (lsp-mode . lsp-enable-which-key-integration) 
         (c++-mode . lsp)
         )
  :config
  (setq read-process-output-max (* 4 (* 1024 1024)))
  (setq lsp-file-watch-ignored
        '("build"
          "out"
          "target"
          "release"
          ".git"
          ))
  (setq lsp-log-io nil)
  (setq lsp-idle-delay 0.500)
  :ensure t)

Lsp integration with several plugins

(use-package flycheck
  :ensure t)
(use-package lsp-treemacs
  :ensure t)
(use-package lsp-ivy
  :ensure t)

C++ lsp
In build directory run cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=YES ..

(use-package ccls
  :ensure t
  :config
  (setq ccls-executable "/usr/bin/ccls")
  (setq ccls-initialization-options
        '(:compilationDatabaseDirectory "build"
                                        :cache (:directory "build/.ccls-cache"))))

Haskell lsp

(use-package lsp-haskell
  :ensure t)

Python lsp

(use-package lsp-pyright
  :ensure t
  :hook (python-mode . (lambda ()
                         (require 'lsp-pyright)
                         (lsp))))  ; or lsp-deferred
(use-package anaconda-mode
  :ensure t)
(use-package company-anaconda
  :ensure t)

emacs ipython notebook

(use-package ein
  :ensure t)

Lsp for latex

(use-package lsp-latex
  :ensure t)

Rust mode

(use-package rustic
  :ensure t)

Go mode

(use-package go-mode
  :ensure t)

Haskell mode

(use-package haskell-mode
  :ensure t)

Yaml files

(use-package yaml-mode
  :ensure t)

Kotlin

(use-package kotlin-mode
  :ensure t)

Graphviz

(use-package graphviz-dot-mode
  :ensure t)

Ipython for org babel

(use-package ob-ipython
  :ensure t)

Java lsp

(use-package lsp-java
  :ensure t)
2.2.5.3 Settings

C style settings

(setq c-default-style "linux")

Code::stats

(add-hook 'prog-mode-hook #'code-stats-mode)
(add-hook 'org-mode-hook #'code-stats-mode)
(run-with-idle-timer 30 t #'code-stats-sync)
(add-hook 'kill-emacs-hook (lambda () (code-stats-sync :wait)))  

Scrool compilation buffer to the first error instead of end.

(setq compilation-scroll-output 'first-error)

Setting ivy

(setq projectile-completion-system 'ivy)
(setq ivy-use-selectable-prompt t)
(setq ivy-initial-inputs-alist nil)

2.2.6 Org-mode

theoremes in LaTeX with org syntax

(use-package org-special-block-extras
  :ensure t
  ;; :hook (org-mode . org-special-block-extras-mode)
  :config (org-special-block-extras-short-names))

Reveal.js for presentations

(use-package ox-reveal
  :ensure t)

Export Org mode to Json

(use-package ox-json
  :ensure t)

Org headers icons

(use-package org-bullets
  :ensure t)

Loading Export backends

(require 'ox-rss)
(eval-after-load "org"
  (progn
    '(require 'ox-md nil t)
    '(require 'ox-rss nil t)
    '(require 'ox-latex nil t)
    '(require 'ox-json nil t)
    '(require 'ox-reveal nil t)))

Org Roam

(use-package org-roam
  :ensure t
  :init
  (setq org-roam-v2-ack t)
  :custom
  (org-roam-directory "~/org/roam")
  :bind (("C-c n l" . org-roam-buffer-toggle)
         ("C-c n f" . org-roam-node-find)
         ("C-c n i" . org-roam-node-insert)
         :map org-mode-map
         ("C-M-i" . completion-at-point))
  :config
  (org-roam-setup))
;; (use-package websocket
;;   :ensure t)

;; (add-to-list 'load-path "~/.emacs.d/lisp/org-roam-ui")
;; (load-library "org-roam-ui")
2.2.6.1 Settings

Setting visual stuff

(setq-default prettify-symbols-alist '(("#+begin_src" . "↓")
                                       ("#+end_src" . "↑")
                                       ("#+BEGIN_SRC" . "↓")
                                       ("#+END_SRC" . "↑")
                                       ("#+end_proof" . "⬜")
                                       ("[ ]" . "")
                                       ("[X]" . "")
                                       ("[-]" . "")
                                       ))

(setq org-hide-emphasis-markers t
      org-fontify-done-headline t
      org-ellipsis "⤶"
      org-pretty-entities t
      prettify-symbols-unprettify-at-point 'right-edge
      org-directory "~/org"
      org-agenda-files '("~/org")
      org-default-notes-file (concat org-directory "/Notes.org")

      org-highlight-latex-and-related '(latex entities)
      org-todo-keywords '((sequence "TODO" "FIXME" "|" "DONE" ))
      org-src-preserve-indentation t)

(setq hl-todo-keyword-faces
      '(("TODO"   . "#fabd2f")
        ("FIXME"  . "#fb4934")))

(font-lock-add-keywords 'org-mode
                        '(("^ *\\([-]\\) "
                           (0 (prog1 () (compose-region (match-beginning 1) (match-end 1) "•"))))))

Defining action to execute at entering org-mode

(add-hook 'org-mode-hook 
          (lambda () 
            (org-bullets-mode 1)
            (org-indent-mode nil)
            (prettify-symbols-mode)
            (set-fontset-font t 'symbol "Noto Color Emoji")
            (progn
              (setq left-margin-width 5)
              (setq right-margin-width 5)
              (set-window-buffer nil (current-buffer)))))

Increse readability of latex preview in org-mode

(setq org-format-latex-options (plist-put org-format-latex-options :scale 2.0))

Org mode file associations

(setq org-file-apps
      (append '(
                ("\\.pdf\\'" . "zathura %s")
                ) org-file-apps ))
  • Add dot to org-babel
  • Enable redisplaying images after executing block
  • Auto confirm evaluating dot
(add-to-list 'org-src-lang-modes (quote ("dot" . graphviz-dot)))
(org-babel-do-load-languages
 'org-babel-load-languages
 '((dot . t)
   (gnuplot . t)
   (org . t)
   (python . t)
   (js . t)
   (shell . t)
   (ipython . t)))
(add-hook 'org-babel-after-execute-hook 'org-redisplay-inline-images)
(setq org-confirm-babel-evaluate nil)
(setq org-src-tab-acts-natively t)

Reveal.js presentations

(setq org-reveal-root (expand-file-name "~/.local/share/reveal.js-4.1.0"))

Export settings

(setq org-html-htmlize-output-type 'inline-css)
(setq org-html-head-include-default-style nil)

Setting up spell checking. Working for both laguages, but only one in one buffer.

(with-eval-after-load "ispell"
  (setq ispell-program-name "hunspell")
  (setq ispell-dictionary "ru_RU,en_US")
  (ispell-set-spellchecker-params)
  (ispell-hunspell-add-multi-dic "ru_RU,en_US"))

Inserting last screenshot

(defun my/org-insert-last-screenshot ()
  (interactive)
  (setq screenshots-dir "~/Pictures/screenshots/")
  (let ((cur-dir (read-directory-name "Copy screenshot to: "))
        (screenshot (car (last (directory-files screenshots-dir)))))
    (copy-file (concat screenshots-dir screenshot) (concat cur-dir screenshot) t)
    (org-insert-link nil (concat cur-dir screenshot)))
  (org-redisplay-inline-images))
2.2.6.2 Publishing

Publishing for:

  • Main site
  • University consepcts (exporting to pdf and uploading on server)
(defun my-conspects-header (arg)
  "<style>#forkongithub a{background:#000;color:#fff;text-decoration:none;font-family:arial,sans-serif;text-align:center;font-weight:bold;padding:5px 40px;font-size:1rem;line-height:2rem;position:relative;transition:0.5s;}#forkongithub a:hover{background:#c11;color:#fff;}#forkongithub a::before,#forkongithub a::after{content:\"\";width:100%;display:block;position:absolute;top:1px;left:0;height:1px;background:#fff;}#forkongithub a::after{bottom:1px;top:auto;}@media screen and (min-width:800px){#forkongithub{position:fixed;display:block;top:0;right:0;width:200px;overflow:hidden;height:200px;z-index:9999;}#forkongithub a{width:200px;position:absolute;top:60px;right:-60px;transform:rotate(45deg);-webkit-transform:rotate(45deg);-ms-transform:rotate(45deg);-moz-transform:rotate(45deg);-o-transform:rotate(45deg);box-shadow:4px 4px 10px rgba(0,0,0,0.8);}}</style><span id=\"forkongithub\"><a href=\"https://github.com/iliayar/ITMO\">Fork me on GitHub</a></span>")

(setq org-publish-project-alist
      '(
        ("org-mainsite"
         :base-directory "~/Documents/MainSite/public/notes"
         :base-extension "org"
         :exclude "level-[0-9]*.org"
         :publishing-directory "/ssh:iliayar@iliayar.ru:/var/www/mainsite/public/public-notes"
         :html-html5-fancy t
         ;; :html-link-home "https://iliayar.ru/public-notes/index.html"
         :html-validation-link nil
         :html-postamble "<hr><a href=\"/public-notes/index.html\">Home Page</a><span style=\"float: right\"><a href=\"/public-notes/blog.xml\"><i class=\"fas fa-rss\"></i></a> <a href=\"https://github.com/iliayar/iliayar\"><i class=\"fab fa-github\"></i></a></span>"
         :recursive t
         :publishing-function org-html-publish-to-html
         :headline-levels 4             ; Just the default for this project.
         :auto-preamble t
         )
        ("rss-mainsite"
         :base-directory "~/Documents/MainSite/public/notes"
         :base-extension "org"
         :exclude ".*"
         :include ("blog.org")
         :publishing-directory "/ssh:iliayar@iliayar.ru:/var/www/mainsite/public/public-notes"
         :rss-extension "xml"
         :section-numbers nil
         :html-link-home "https://iliayar.ru/public-notes/"
         :html-link-use-abs-url t
         :html-link-org-files-as-html t
         :output-file "rss"
         :recursive nil
         :publishing-function org-rss-publish-to-rss
         )
        ("static-mainsite"
         :base-directory "~/Documents/MainSite/public/notes"
         :base-extension "css\\|js\\|png\\|jpg\\|gif\\|pdf\\|mp3\\|ogg\\|swf\\|pdf"
         :publishing-directory "/ssh:iliayar@iliayar.ru:/var/www/mainsite/public/public-notes"
         :recursive t
         :publishing-function org-publish-attachment
         )
        ("mainsite" :components ("org-mainsite" "rss-mainsite" "static-mainsite"))

        ("org-conspects"
         :base-directory "~/Documents/ITMO"
         :exclude ".*[^E].org"
         :publishing-directory "/ssh:iliayar@iliayar.ru:/var/www/mainsite/public/public-notes/conspects"
         :recursive t
         :html-postamble "<hr><a href=\"/public-notes/index.html\">Home Page</a><span style=\"float: right\"><a href=\"https://t.me/iliayar\"><i class=\"fab fa-telegram-plane\"></i></a> <a href=\"https://github.com/iliayar/ITMO\"><i class=\"fab fa-github\"></i></a></span><br><a href=\"/public-notes/conspects/README.html\">Conspects Home Page</a>"
         :publishing-function org-html-publish-to-html
         :headline-levels 4             ; Just the default for this project.
         ;; :html-preamble my-conspects-header
         )
        ("pdfs-conspects"
         :base-directory "~/Documents/ITMO"
         :base-extension "org"
         :exclude "README.org\\|level-[0-9]*.org\\|level-subj.org"
         :publishing-directory "/ssh:iliayar@iliayar.ru:/var/www/mainsite/public/public-notes/conspects"
         :recursive t
         :publishing-function org-latex-publish-to-pdf
         )
        ("conspects" :components ("org-conspects" "pdfs-conspects"))
        ))
2.2.6.3 LaTeX

Org mode to LaTeX and pdf Setting packages

(setq org-latex-packages-alist '(
                                 ("T1, T2A" "fontenc" t)
                                 ("lutf8" "luainputenc" t)
                                 ("english,russian" "babel" t)
                                 ("" "minted" t)
                                 ("" "graphicx" t)
                                 ("" "longtable" t)
                                 ("" "hyperref" t)
                                 ("" "xcolor" t)
                                 ("" "natbib" t)
                                 ("" "amssymb" t)
                                 ("" "stmaryrd" t)
                                 ("" "amsmath" t)
                                 ("" "caption" t)
                                 ("" "mathtools" t)
                                 ("" "amsthm" t)
                                 ("" "tikz" t)
                                 ("" "fancyhdr" t)
                                 ("" "lastpage" t)
                                 ("" "titling" t)
                                 ("" "grffile" t)
                                 ("" "extarrows" t)
                                 ("" "wrapfig" t)
                                 ("" "algorithm" t)
                                 ("" "algorithmic" t)
                                 ("" "lipsum" t)
                                 ("" "rotating" t)
                                 ("" "placeins" t)
                                 ("normalem" "ulem" t)
                                 ("" "amsmath" t)
                                 ("" "textcomp" t)
                                 ("" "svg" t)
                                 ("" "capt-of" t)))
;; Reset default value. For debugging
(custom-reevaluate-setting 'org-latex-classes)
(with-eval-after-load 'ox-latex
  (progn 
    (add-to-list 'org-latex-classes
                 (list "general"
                       "
  \\documentclass[english]{article}
  [NO-DEFAULT-PACKAGES]
  [PACKAGES]
  [EXTRA]
  \\usepackage{geometry}
  \\geometry{a4paper,left=2.5cm,top=2cm,right=2.5cm,bottom=2cm,marginparsep=7pt, marginparwidth=.6in}
  \\input{~/.emacs.d/preamble.sty}
  "
                       '("\\section{%s}" . "\\section*{%s}")
                       '("\\subsection{%s}" . "\\subsection*{%s}")
                       '("\\subsubsection{%s}" . "\\subsubsection*{%s}")
                       '("\\paragraph{%s}" . "\\paragraph*{%s}")
                       '("\\subparagraph{%s}" . "\\subparagraph*{%s}")
                       ))
    (add-to-list 'org-latex-classes
                 (list "lectures"
                       "
  \\documentclass[oneside]{book}
  [NO-DEFAULT-PACKAGES]
  [PACKAGES]
  [EXTRA]
  \\addto\\captionsrussian{\\renewcommand{\\chaptername}{Лекция}}
  \\renewcommand{\\leftmark}{}
  \\usepackage[a4paper, total={6in, 8in}]{geometry}
  \\input{~/.emacs.d/preamble.sty}
  \\fancyhead[L]{\\leftmark}
  "
                       '("\\chapter*{%1$s}\\renewcommand{\\leftmark}{%1$s}\\addcontentsline{toc}{chapter}{%1$s}\\stepcounter{chapter}" . "\\chapter{%s}")
                       '("\\section{%s}" . "\\section*{%s}")
                       '("\\subsection{%s}" . "\\subsection*{%s}")
                       '("\\subsubsection{%s}" . "\\subsubsection*{%s}")
                       '("\\paragraph{%s}" . "\\paragraph*{%s}")
                       '("\\subparagraph{%s}" . "\\subparagraph*{%s}")
                       ))))
(setq org-latex-listings 'minted
      org-latex-pdf-process
      '("pdflatex -shell-escape --synctex=1 -interaction nonstopmode -output-directory %o %f"
        "pdflatex -shell-escape --synctex=1 -interaction nonstopmode -output-directory %o %f"
        "pdflatex -shell-escape --synctex=1 -interaction nonstopmode -output-directory %o %f"))
(setq org-latex-minted-options
      '(("frame" "lines") ("linenos=true") ("mathescape")))
(add-to-list 'org-latex-minted-langs '(ipython "python"))

2.2.7 Common

RSS reader

(use-package elfeed
  :ensure t
  :custom
  (rmh-elfeed-org-files (list "~/org/elfeed.org")))
(use-package elfeed-org
  :ensure t
  :init
  (elfeed-org))
(use-package elfeed-goodies
  :ensure t
  :init
  (elfeed-goodies/setup))

Settings colors for each tag.

(defface unread-tag-face '((t :foreground "light grey")) "Marks unread")
(defface news-tag-face '((t :foreground "light yellow")) "Mark news")
(defface ctf-tag-face '((t :foreground "red")) "Mark CTF events")
(defface blog-tag-face '((t :foreground "cyan")) "Mark posts")
(defface github-tag-face '((t :foreground "orange")) "Mark Github feed")
(defface starred-tag-face '((t :foreground "yellow")) "Mark favourite posts")
(setq elfeed-search-face-alist
      '(
        (starred starred-tag-face)
        (ctf ctf-tag-face)
        (blog blog-tag-face)
        (news news-tag-face)
        (github github-tag-face)
        (unread elfeed-search-unread-title-face)
        ))

(defalias 'elfeed-toggle-star
  (elfeed-expose #'elfeed-search-toggle-all 'starred))

Mail client

(use-package mu4e
  :ensure nil
  :config
  (setq user-full-name "Ilya Yaroshevskiy")
  
  (setq mu4e-change-filenames-when-moving t)
  (setq mu4e-update-interval (* 10 60))
  (setq mu4e-maildir "~/Mail")
  (setq mu4e-headers-skip-duplicates t)
  (setq mu4e-attachment-dir "~/Downloads")
  (setq mu4e-sent-messages-behavior 'delete)
  (setq mu4e-use-fancy-chars t)
  (setq message-send-mail-function 'smtpmail-send-it)

  (setq mu4e-contexts
        (list
         ;; Personal context
         (make-mu4e-context
          :name "personal"
          :match-func (lambda (msg) (when msg
                                      (string-prefix-p "/personal" (mu4e-message-field msg :maildir))))
          :vars '((mu4e-sent-folder . "/personal/[Gmail]/Sent Mail")
                  (mu4e-drafts-folder . "/personal/[Gmail]/Drafts")
                  ;; (mu4e-refile-folder . "/personal/[Gmail]/All Mail")
                  (mu4e-trash-folder . "/personal/[Gmail]/Trash")
                  (user-mail-address . "iliayar3@gmail.com")
                  (mu4e-get-mail-command . "mbsync personal")
                  (smtpmail-smtp-server . "smtp.gmail.com")
                  (smtpmail-smtp-service . 465)
                  (smtpmail-stream-type . ssl)
                  (smtpmail-smtp-user . "iliayar3@gmail.com")
                  (mu4e-bookmarks . (("maildir:/personal/Inbox" "Inbox" ?i)
                                     ("maildir:/personal/[Gmail]/Important" "Important" ?!)))
                  ))
         ;; Cock context
         (make-mu4e-context
          :name "cock"
          :match-func (lambda (msg) (when msg
                                      (string-prefix-p "/cock" (mu4e-message-field msg :maildir))))
          :vars '(
                  (mu4e-sent-folder . "/cock/Sent")
                  ;; (mu4e-drafts-folder . "/cock/Drafts")
                  (mu4e-refile-folder . "/cock/Junk")
                  (mu4e-trash-folder . "/cock/Trash")
                  (user-mail-address . "iliayar@cock.li")
                  (mu4e-get-mail-command . "mbsync cock")
                  (smtpmail-smtp-server . "mail.cock.li")
                  (smtpmail-smtp-service . 465)
                  (smtpmail-stream-type . ssl)
                  (smtpmail-smtp-user . "iliayar@cock.li")
                  (mu4e-bookmarks . (("maildir:/cock/Inbox" "Inbox" ?i)
                                     ;; ("maildir:/personal/[Gmail]/Important" "Important" ?!)
                                     ))
                  ))
         )))

2.3 Keybindings

Evil!

 (define-minor-mode my-override-mode
  "Overrides all major and minor mode keys" t)

(defvar my-override-map (make-sparse-keymap "my-override-map")
  "Override all major and minor mode keys")

(add-to-list 'emulation-mode-map-alists
  `((my-override-mode . ,my-override-map)))

(define-key my-override-map (kbd "<left>")
  (lambda ()
    (interactive)
    (message "Use Vim keys: h for Left")))

(define-key my-override-map (kbd "<right>")
  (lambda ()
    (interactive)
    (message "Use Vim keys: l for Right")))

(define-key my-override-map (kbd "<up>")
  (lambda ()
    (interactive)
    (message "Use Vim keys: k for Up")))

(define-key my-override-map (kbd "<down>")
  (lambda ()
    (interactive)
    (message "Use Vim keys: j for Down")))
(evil-make-intercept-map my-override-map) 
(general-define-key
 :keymaps 'company-active-map
 "<tab>"     'yas-expand
 "<backtab>" 'company-complete-selection)

(general-define-key
 "M-x" 'counsel-M-x)

(general-define-key
 :map 'org-mode-map
 "C-c C-x i" 'my/org-insert-last-screenshot)

Elfeed hydra binddings

(defhydra elfeed-search-view-hydra (:color blue :hint t)
  ("d" (elfeed-search-set-filter nil) "Default")
  ("f" (elfeed-search-set-filter "+starred") "Favourite")
  ("a" (elfeed-search-set-filter "-unread") "All"))

Bindings using general package

(general-define-key
 :states '(normal visual emacs insert treemacs)
 :prefix "SPC"
 :non-normal-prefix "M-SPC"
 :keymaps 'override
 "bb" 'ibuffer
 "ca" 'lsp-execute-code-action
 "cc" 'compile
 "cd" 'kill-compilation-buffer
 "cf" 'counsel-grep-or-swiper
 "cl" 'comment-or-uncomment-region
 "cr" 'lsp-rename
 "ff" 'counsel-find-file
 "gl" 'avy-goto-line
 "gr" 'revert-buffer
 "gs" 'avy-goto-char-timer
 "oa" 'org-agenda
 "og" 'magit
 "or" 'elfeed
 "op" 'treemacs
 "om" 'mu4e
 "pc" 'projectile-compile-project
 "pf" 'counsel-projectile-find-file
 "pp" 'projectile-switch-project
 "rr" 'rustic-cargo-run
 "sl" 'lsp
 "sr" 'lsp-workspace-restart
 "ss" 'lsp-workspace-shutdown
 "tt" 'treemacs-select-window
 "wd" 'delete-window
 "wk" 'kill-buffer-and-window
 "wr" 'hydra-window-resize-menu/body
 "ww" 'ace-window)

(general-define-key
 :states '(visual)
 :keymaps 'override
 "R"  'evil-multiedit-match-all
 )

(general-define-key
 :states '(normal visual insert)
 :prefix "SPC"
 :non-normal-prefix "M-SPC"
 :keymaps 'latex-mode-map
 "si" 'latex-insert-block
 )

(general-define-key
 :keymaps 'elfeed-search-mode-map
 "f" 'elfeed-toggle-star
 "v" 'elfeed-search-view-hydra/body)

Hydra

(defhydra hydra-window-resize-menu (:color red
                                           :hint nil)
  "
    Window Resize
    -------------
         /\\
          _k_
    < _h_     _l_ >
          _j_
          v
    "
  ("h" evil-window-decrease-width)
  ("l" evil-window-increase-width)
  ("k" evil-window-decrease-height)
  ("j" evil-window-increase-height)
  ("c" nil "Cancel"))

Home Page