Skip to content

Personal GNU Emacs configuration

License

Notifications You must be signed in to change notification settings

fbertux/emacs.d

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Personal GNU Emacs configuration

Configurations

Move customization away from init.el

(setq custom-file "~/.emacs.d/custom.el")

Package Setup

Setup the package repositories.

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

Automatically install and then setup use-package

(eval-and-compile
  (setq use-package-always-ensure t)
  (setq use-package-expand-minimally t)
  (setq use-package-compute-statistics t)
  (setq use-package-enable-imenu-support t))

(eval-when-compile
  (require 'use-package)
  (require 'bind-key))

Custom function

(defun buffer-cleanup ()
  (interactive)
  (whitespace-cleanup)
  (untabify (point-min) (point-max)))

;; Copy to clipboard
(defun copy-to-clipboard ()
  "Copies selection to x-clipboard."
  (interactive)
  (if (display-graphic-p)
      (progn
        (message "Yanked region to x-clipboard!")
        (call-interactively 'clipboard-kill-ring-save)
        )
    (if (region-active-p)
        (progn
          (shell-command-on-region (region-beginning) (region-end) "xsel -i -b")
          (message "Yanked region to clipboard!")
          (deactivate-mark))
      (message "No region active; can't yank to clipboard!")))
  )

;; Paste from clipboard
(defun paste-from-clipboard ()
  (interactive)
  (if (display-graphic-p)
      (progn
        (clipboard-yank)
        (message "graphics active")
        )
    (insert (shell-command-to-string "xsel -o -b"))
    )
  )

(global-set-key (kbd "C-x c") 'copy-to-clipboard)
(global-set-key (kbd "C-x v") 'paste-from-clipboard)

;; Indent commit messages
(fset 'indent-commit
      (lambda (&optional arg) "Keyboard macro." (interactive "p")
        (kmacro-exec-ring-item (quote ([67108896 134217829 1 24 114 116 32 32 32 32 45 32 13] 0 "%d")) arg)))

;; Highlight tabs
(defun highlight-tabs ()
  (interactive)
  (hi-lock-face-buffer "\t"))
(defun unhighlight-tabs ()
  (interactive)
  (hi-lock-unface-buffer "\t"))

(global-set-key (kbd "C-x p")
                #'(lambda ()
                    (interactive)
                    (switch-to-buffer "*scratch*")))

;; Commit message for personal org file repository
(defalias 'fb/commit-massage-org
   (kmacro "U p d a t e SPC C-u M-x f b / i n <tab> RET 4 RET"))

Copy buffer name or full path with name

(defun fb/copy-buffer-name ()
  (interactive)
  (kill-new (buffer-name)))

(defun fb/copy-buffer-full-name ()
  (interactive)
  (kill-new (buffer-file-name)))

Insert date time

Use Xah Lee Insert Date Time function.

Get function from [1].

[1] - http://ergoemacs.org/emacs/elisp_insert-date-time.html

(defun fb/insert-date ()
  "Insert current date time.
Insert date in this format: yyyy-mm-dd.
If `universal-argument' is called first, prompt for a format to use.
If there's text selection, delete it first.

URL `http://ergoemacs.org/emacs/elisp_insert-date-time.html'
version 2020-09-07"
  (interactive)
  (let (($style
         (if current-prefix-arg
             (string-to-number
              (substring
               (ido-completing-read
                "Style:"
                '(
                  "1 → 2018-04-12 Thursday"
                  "2 → 20180412224611"
                  "3 → 2018-04-12T22:46:11-07:00"
                  "4 → 2018-04-12 22:46:11-07:00"
                  "5 → Thursday, April 12, 2018"
                  "6 → Thu, Apr 12, 2018"
                  "7 → April 12, 2018"
                  "8 → Apr 12, 2018"
                  )) 0 1))
           0
           )))
    (when (use-region-p) (delete-region (region-beginning) (region-end)))
    (insert
     (cond
      ((= $style 0)
       ;; "2016-10-10"
       (format-time-string "%Y-%m-%d"))
      ((= $style 1)
       ;; "2018-04-12 Thursday"

       (format-time-string "%Y-%m-%d %A"))
      ((= $style 2)
       ;; "20180412224015"
       (replace-regexp-in-string ":" "" (format-time-string "%Y%m%d%T")))
      ((= $style 3)
       (concat
        (format-time-string "%Y-%m-%dT%T")
        (funcall (lambda ($x) (format "%s:%s" (substring $x 0 3) (substring $x 3 5))) (format-time-string "%z")))
       ;; "2018-04-12T22:45:26-07:00"
       )
      ((= $style 4)
       (concat
        (format-time-string "%Y-%m-%d %T")
        (funcall (lambda ($x) (format "%s:%s" (substring $x 0 3) (substring $x 3 5))) (format-time-string "%z")))
       ;; "2018-04-12 22:46:11-07:00"
       )
      ((= $style 5)
       (format-time-string "%A, %B %d, %Y")
       ;; "Thursday, April 12, 2018"
       )
      ((= $style 6)
       (format-time-string "%a, %b %d, %Y")
       ;; "Thu, Apr 12, 2018"
       )
      ((= $style 7)
       (format-time-string "%B %d, %Y")
       ;; "April 12, 2018"
       )
      ((= $style 8)
       (format-time-string "%b %d, %Y")
       ;; "Apr 12, 2018"
       )
      (t
       (format-time-string "%Y-%m-%d"))))))

Smarter navigation to the beginning of a line

(defun smarter-move-beginning-of-line (arg)
  "Move point back to indentation of beginning of line.

Move point to the first non-whitespace character on this line.
If point is already there, move to the beginning of the line.
Effectively toggle between the first non-whitespace character and
the beginning of the line.

If ARG is not nil or 1, move forward ARG - 1 lines first.  If
point reaches the beginning or end of the buffer, stop there."
  (interactive "^p")
  (setq arg (or arg 1))

  ;; Move lines first
  (when (/= arg 1)
    (let ((line-move-visual nil))
      (forward-line (1- arg))))

  (let ((orig-point (point)))
    (back-to-indentation)
    (when (= orig-point (point))
      (move-beginning-of-line 1))))

;; remap C-a to `smarter-move-beginning-of-line'
(global-set-key [remap move-beginning-of-line]
                'smarter-move-beginning-of-line)

Diminish

(use-package diminish
  :diminish abbrev-mode
  :diminish auto-fill-function
  :diminish eldoc-mode
  :diminish visual-line-mode
  )

Theme

(use-package zenburn-theme
  :config
  (setq zenburn-use-variable-pitch t)
  (setq zenburn-scale-org-headlines t)
  (setq zenburn-scale-outline-headlines t)
  (load-theme 'zenburn t))
(set-frame-font "Source Code Pro-12" nil t)

General modifications

(use-package emacs
  :config
  ;;; Speed up
  (add-hook 'focus-out-hook 'garbage-collect)
  (run-with-idle-timer 5 t 'garbage-collect)

  ;;; UI tweaks
  (blink-cursor-mode -1)
  (setq-default cursor-type 'hbar)
  (setq ring-bell-function 'ignore)
  (setq scroll-conservatively 10)
  (setq scroll-margin 7)
  (setq column-number-mode t)
  (show-paren-mode 1)
  (pixel-scroll-precision-mode)

  (fset 'yes-or-no-p 'y-or-n-p)
  (setq confirm-kill-emacs 'yes-or-no-p)

  (require 'saveplace)
  (setq-default save-place t)
  (setq save-place-file (concat user-emacs-directory "places"))
  (setq backup-directory-alist `(("." . ,(concat user-emacs-directory
                                                 "backups"))))

  (setq auto-save-default t)
  (setq auto-save-visited-file-name t)

  (setq browse-url-browser-function 'browse-url-generic
        browse-url-generic-program "explorer.exe")

  (windmove-default-keybindings)

  (global-auto-revert-mode t)
  (setq auto-revert-remote-files t)

  (setq remote-file-name-inhibit-locks t)
  (setq remote-file-name-inhibit-cache nil)
  (setq vc-handled-backends '(Git))
  (setq vc-follow-symlinks nil)

  (setq load-prefer-newer t)
  (setq create-lockfiles nil)

  (set-default 'truncate-lines t)
  (setq truncate-partial-width-windows nil)

  (setq-default indent-tabs-mode nil
                tab-width 4)

  (setq require-final-newline t)
  (setq tab-always-indent 'complete)
  (setq completion-styles '(basic initials substring))

  (setq large-file-warning-threshold nil)

  (setq initial-major-mode 'fundamental-mode)

  (setq python-indent-guess-indent-offset t)
  (setq python-indent-guess-indent-offset-verbose nil)
  (setq python-shell-completion-native-enable nil)
  (setq backward-delete-char-untabify-method 'hungry)

  (setq bookmark-save-flag 1)

  (setq select-active-regions nil)

  (setq native-comp-async-report-warnings-errors nil)

  (global-set-key [remap dabbrev-expand] 'hippie-expand)
  (global-set-key (kbd "RET") 'newline-and-indent)

  (setq ispell-program-name "aspell")

  (define-key global-map (kbd "M-g l") 'goto-line)

  (setq major-mode-remap-alist
        '((yaml-mode . yaml-ts-mode)
          (bash-mode . bash-ts-mode)
          (js2-mode . js-ts-mode)
          (typescript-mode . typescript-ts-mode)
          (json-mode . json-ts-mode)
          (css-mode . css-ts-mode)
          (python-mode . python-ts-mode)))

  (keymap-set minibuffer-mode-map "TAB" 'minibuffer-complete)

  (setq switch-to-buffer-obey-display-actions t)

  ;;; Live reload of the settings, from inside of the Emacs
  (global-set-key (kbd "C-c i")
                  (lambda()(interactive)
                    (org-babel-load-file "~/.emacs.d/README.org"))))

Helm

(defun nm-around-helm-buffers-sort-transformer (candidates source)
  candidates)
(use-package vertico
  :init
  (vertico-mode))

(use-package vertico-directory
  :ensure nil
  :after vertico
  :bind (:map vertico-map
              ("M-DEL" . vertico-directory-delete-word)))

;; Marginalia: annotations for minibuffer
(use-package marginalia
  :config
  (marginalia-mode))

;; Popup completion-at-point
(use-package corfu
  :init
  (global-corfu-mode)
  :bind
  (:map corfu-map
        ("SPC" . corfu-insert-separator)
        ("C-n" . corfu-next)
        ("C-p" . corfu-previous)))

;; ;; Part of corfu
(use-package corfu-popupinfo
  :ensure nil
  :after corfu
  :hook (corfu-mode . corfu-popupinfo-mode)
  :custom
  (corfu-popupinfo-delay '(0.25 . 0.1))
  (corfu-popupinfo-hide nil)
  :config
  (corfu-popupinfo-mode))

;; Make corfu popup come up in terminal overlay
(use-package corfu-terminal
  :if (not (display-graphic-p))
  :config
  (corfu-terminal-mode))

;; Orderless: powerful completion style
(use-package orderless
  :config
  (setq completion-styles '(orderless)))

Dired

(use-package dired
  :ensure nil
  :commands (dired)
  :custom
  ;; Always delete and copy recursively
  (dired-recursive-deletes 'always)
  (dired-recursive-copies 'always)
  ;; Auto refresh Dired, but be quiet about it
  (global-auto-revert-non-file-buffers t)
  (auto-revert-verbose nil)
  ;; Quickly copy/move file in Dired
  (dired-dwim-target t)
  ;; Move files to trash when deleting
  (delete-by-moving-to-trash t)
  :config
  ;; Reuse same dired buffer, to prevent numerous buffers while navigating in dired
  (put 'dired-find-alternate-file 'disabled nil)
  :hook
  (dired-mode . (lambda ()
                  (local-set-key (kbd "<mouse-2>") #'dired-find-alternate-file)
                  (local-set-key (kbd "RET") #'dired-find-alternate-file)
                  (local-set-key (kbd "^")
                                 (lambda () (interactive) (find-alternate-file ".."))))))

(use-package dired-x
  :ensure nil
  :after dired
  :hook (dired-mode . dired-omit-mode)
  :config
  (setq dired-omit-files
        (concat dired-omit-files "\\|^\\..+$")))

Ibuffer

General modifications

(use-package ibuffer-sidebar
  :bind (("C-x C-b" . ibuffer))
  :ensure nil
  :commands (ibuffer)
  :config
  (setq ibuffer-expert t)
  (setq ibuffer-show-empty-filter-groups nil)

  (require 'ibuf-ext)
  (add-to-list 'ibuffer-never-show-predicates "^\\*")

  (setq ibuffer-saved-filter-groups
        '(("default"
           ("Bitbake"
            (or
             (filename . "\\.bb$")
             (filename . "\\.bbappend$")
             (filename . "\\.bbclass$")
             (filename . "\\.inc$")
             (filename . "\\.wic$")
             (filename . "\\.wks$")))
           ("Shell scripts"
            (or
             (mode . sh-mode)
             (mode . shell-mode)
             (mode . makefile-bsdmake-mode)
             (mode . makefile-imake-mode)
             (mode . makefile-automake-mode)
             (mode . makefile-gmake-mode)
             (mode . makefile-makeapp-mode)))
           ("Git" (or
                   (derived-mode . magit-mode)
                   (mode . diff-mode)))
           ("Org"
            (or (mode . org-mode)
                (filename . "OrgMode")))
           ("Markup"
            (or
             (mode . tex-mode)
             (mode . latex-mode)
             (mode . tex-fold-mode)
             (mode . tex-doctex-mode)
             (mode . context-mode)
             (mode . bibtex-style-mode)
             (mode . sgml-mode)
             (mode . css-mode)
             (mode . nxml-mode)
             (mode . html-mode)))
           ("Dired" (mode . dired-mode))
           ("Man pages"
            (mode . Man-mode))
           ("Shells"
            (or
             (mode . ansi-term-mode)
             (mode . term-mode)
             (mode . eshell-mode)
             (mode . shell-mode)))
           )))

  (add-hook 'ibuffer-mode-hook
            #'(lambda ()
                (ibuffer-auto-mode 1)
                (ibuffer-switch-to-saved-filter-groups "default"))))

Group tramp buffers

(use-package ibuffer-tramp
  :after (tramp)
  :config
  (progn
    (add-hook 'ibuffer-hook
              (lambda ()
                (ibuffer-tramp-set-filter-groups-by-tramp-connection)
                (ibuffer-do-sort-by-alphabetic))))
  (add-to-list 'tramp-remote-path 'tramp-own-remote-path))

Tramp

(use-package tramp
  :config
  (setq vc-ignore-dir-regexp
      (format "\\(%s\\)\\|\\(%s\\)"
              vc-ignore-dir-regexp
              tramp-file-name-regexp))
  (add-to-list 'tramp-connection-properties
               (list "/ssh:" "direct-async-process" t))
  (setq tramp-persistency-file-name "~/.emacs.d/tramp")
  (setq tramp-default-method "ssh")
  (setq tramp-auto-save-directory "/tmp/tramp/")
  (setq tramp-verbose 0)
  (setq tramp-chunksize 2000)
  ;; use the settings in ~/.ssh/config instead of Tramp's
  (setq tramp-ssh-controlmaster-options nil)
  (setq remote-file-name-inhibit-locks t))

Spelling

(use-package flyspell
  :diminish flyspell-mode
  :hook
  (text-mode . flyspell-mode)
  (prog-mode . flyspell-prog-mode))
(use-package languagetool
  :commands (languagetool-check
             languagetool-clear-suggestions
             languagetool-correct-at-point
             languagetool-correct-buffer
             languagetool-set-language
             languagetool-server-mode
             languagetool-server-start
             languagetool-server-stop)
  :config
  (setq languagetool-java-arguments '("-Dfile.encoding=UTF-8")
        languagetool-console-command "~/.local/share/LanguageTool/languagetool-commandline.jar"
        languagetool-server-command "~/.local/share/LanguageTool/languagetool-server.jar"))

Tree-sitter

(use-package treesit
  :ensure nil
  :config
  (setq treesit-font-lock-level 4)
  (setq c-ts-mode-indent-offset 4))
(use-package treesit-auto
  :config
  (setq treesit-auto-install 'prompt)
  (global-treesit-auto-mode))
(use-package tree-sitter
  :config
  (add-hook 'tree-sitter-after-on-hook #'tree-sitter-hl-mode))

Authentication

(use-package auth-source
  :config
  (setq auth-sources '("~/.authinfo")))

Projectile

Custom functions

Override root project: Link

(defun project-root-override (dir)
  (let ((root (locate-dominating-file dir ".projectile"))
        (backend (ignore-errors (vc-responsible-backend dir))))
    (when root (if (version<= emacs-version "28")
                   (cons 'vc root)
                 (list 'vc backend root)))))

Package configuration

(use-package projectile
  :diminish projectile-mode
  :bind-keymap ("C-c p" . projectile-command-map)
  :hook (after-init . projectile-mode)
  :config
  (add-hook 'project-find-functions #'project-root-override)
  (setq projectile-enable-caching t))

Projectile Ripgrep

(use-package projectile-ripgrep
  :after projectile)

Editing

(use-package whitespace
  :diminish global-whitespace-mode
  :hook
  (after-init . global-whitespace-mode)
  :config
  (setq whitespace-style
        '(face newline tab-mark trailing space-before-tab space-after-tab)))

(use-package expand-region
  :bind
  ("M-=" . er/expand-region))

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

(use-package smartparens
  :diminish smartparens-mode
  :hook
  (after-init . smartparens-global-mode)
  :config
  (require 'smartparens-config))

(use-package ws-butler
  :diminish ws-butler-mode
  :hook
  (after-init . ws-butler-global-mode))

(use-package undo-tree
  :diminish undo-tree-mode
  :bind ("C-x u" . 'undo-tree-redo)
  :config
  (progn
    (global-undo-tree-mode)
    (setq undo-tree-visualizer-timestamps t)
    (setq undo-tree-visualizer-diff t)
    (setq undo-tree-history-directory-alist '(("." . "~/.emacs.d/undo")))))

Company

(use-package company
  :diminish company-mode
  :hook (after-init . global-company-mode)
  :bind
  (:map prog-mode-map
        ("<tab>" . company-indent-or-complete-common))
  :config
  (setq company-idle-delay                nil
        company-dabbrev-downcase          nil
        company-minimum-prefix-length     2
        company-show-numbers              t
        company-tooltip-limit             10
        company-tooltip-align-annotations t
        company-lsp-enable-snippet        t)
  (define-key company-mode-map [remap indent-for-tab-command] #'company-indent-or-complete-common)
  (delete 'company-clang company-backends))

Flymake

(use-package flymake
  :diminish flymake-mode
  :hook
  (prog-mode . (lambda () (flymake-mode t)))
  (text-mode . (lambda () (flymake-mode t))))

Eglot

(use-package eglot
  :ensure nil
  :commands (eglot eglot-ensure eglot-server-programs)
  :hook ((c-ts-mode . eglot-ensure)
         (markdown-mode . eglot-ensure)
         (sh-mode . eglot-ensure)
         (python-mode . eglot-ensure))
  :config
  (add-to-list 'eglot-server-programs '((c-ts-mode)
                                        . ("clangd"
                                           "-j=8"
                                           "--log=error"
                                           "--malloc-trim"
                                           "--background-index"
                                           "--clang-tidy"
                                           "--cross-file-rename"
                                           "--completion-style=detailed"
                                           "--pch-storage=memory"
                                           "--header-insertion=never"
                                           "--header-insertion-decorators=0")))
  (add-to-list 'eglot-server-programs '((sh-mode) . ("bash-language-server" "start")))
  (add-to-list 'eglot-server-programs '(markdown-mode . ("marksman")))
  (add-to-list 'eglot-server-programs '(rust-mode . ("rust-analyzer")))
  (setq-default eglot-workspace-configuration
                '((:pylsp . (:configurationSources ["flake8"]
                                                   :plugins (
                                                             :pycodestyle (:enabled :json-false)
                                                             :mccabe (:enabled :json-false)
                                                             :pyflakes (:enabled :json-false)
                                                             :flake8 (:enabled :json-false
                                                                               :maxLineLength 88)
                                                             :ruff (:enabled t
                                                                             :lineLength 88)
                                                             :pydocstyle (:enabled t
                                                                                   :convention "numpy")
                                                             :yapf (:enabled :json-false)
                                                             :autopep8 (:enabled :json-false)
                                                             :black (:enabled t
                                                                              :line_length 88
                                                                              :cache_config t)))))))

Eldoc

(use-package eldoc
  :ensure nil
  :custom
  (eldoc-documentation-strategy 'eldoc-documentation-compose-eagerly)
  (eldoc-echo-area-display-truncation-message nil)
  (eldoc-echo-area-prefer-doc-buffer t)
  (eldoc-idle-delay 0.1)
  (eldoc-echo-area-use-multiline-p nil))

Git configuration

(use-package magit
  :config
  (require 'git-commit)
  (add-hook 'git-commit-mode-hook 'flyspell-mode)
  (add-hook 'git-commit-setup-hook 'git-commit-turn-on-flyspell)
  (add-hook 'git-commit-mode-hook (lambda () (setq fill-column 72)))
  (setq magit-diff-refine-hunk t)
  :bind ((("C-c g" . magit-file-dispatch))))

Configuration in private file

;; (use-package forge
;;   :after magit)
(use-package diff-hl
  :hook ((after-init         . global-diff-hl-mode)
         (dired-mode         . diff-hl-dired-mode-unless-remote)
         (magit-pre-refresh  . diff-hl-magit-pre-refresh)
         (magit-post-refresh . diff-hl-magit-post-refresh))
  :config
  ;; When Emacs runs in terminal, show the indicators in margin instead.
  (unless (display-graphic-p)
    (diff-hl-margin-mode)))

Misc

(use-package cmake-mode
  :mode ("CmakeLists\\.txt'" "\\.cmake\\'"))

(use-package dockerfile-mode
  :mode ("/Dockerfile\\'"))

(use-package dts-mode
  :mode ("\\.dts\\'" "\\.dtsi\\'"))

(use-package json-mode
  :mode ("\\.uhupkg.config\\'" "\\.json\\'"))

(use-package pkgbuild-mode
  :mode ("PKGBUILD\\'"))

(use-package systemd
  :mode ("\\.automount\\'\\|\\.busname\\'\\|\\.mount\\'\\|\\.service\\'\\|\\.slice\\'\\|\\.socket\\'\\|\\.target\\'\\|\\.timer\\'\\|\\.link\\'\\|\\.netdev\\'\\|\\.network\\'\\|\\.override\\.conf.*\\'" . systemd-mode))

(use-package yaml-mode
  :mode ("\\.yaml\\'" "\\.yml\\'"))

(use-package qml-mode
  :mode ("\\.qml\\'" ))

(use-package qt-pro-mode
  :mode ("\\.pro\\'" "\\.pri\\'"))

Org Mode

Org Mode settings

(use-package org
  :preface
  (defun endless/org-ispell ()
    "Configure `ispell-skip-region-alist' for `org-mode'."
    (make-local-variable 'ispell-skip-region-alist)
    (add-to-list 'ispell-skip-region-alist '(org-property-drawer-re))
    (add-to-list 'ispell-skip-region-alist '("~" "~"))
    (add-to-list 'ispell-skip-region-alist '("=" "="))
    (add-to-list 'ispell-skip-region-alist '("^#\\+BEGIN_SRC" . "^#\\+END_SRC")))

  :mode ("\\.org$" . org-mode)
  :bind (("C-c l" . org-store-link)
         ("C-c c" . org-capture)
         ("C-c a" . org-agenda)
         ("C-c b" . org-switchb))
  :hook ((org-mode . org-indent-mode)
         (org-indent-mode . (lambda() (diminish 'org-indent-mode))))
  :config
  (add-hook 'org-mode-hook 'turn-on-flyspell)
  (add-hook 'org-mode-hook #'endless/org-ispell)
  (setq org-confirm-babel-evaluate nil
        org-export-babel-evaluate 'inline-only)
  (setq org-src-tab-acts-natively t)
  (setq org-startup-with-inline-images t)
  (setq org-startup-indented t)
  (setq org-startup-folded t)
  (setq org-return-follows-link t)
  (setq org-image-actual-width 600)
  (setq org-format-latex-options (plist-put org-format-latex-options :scale 2.0))
  (setq org-src-fontify-natively t)
  (setq org-src-preserve-indentation t)
  (setq org-use-speed-commands t)
  (setq org-archive-all-done t)
  (setq org-deadline-warning-days 30)
  (setq org-agenda-tags-column 75)
  (setq org-export-with-sub-superscripts nil)
  (setq org-latex-listings 'minted
        org-latex-packages-alist '(("" "minted"))
        org-latex-pdf-process
        '("pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"
          "pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f"
          "pdflatex -shell-escape -interaction nonstopmode -output-directory %o %f")
        org-latex-minted-options '(("breaklines" "true")
                                   ("breakanywhere" "true")
                                   ("fontsize" "\\footnotesize")
                                   ("bgcolor" "white")
                                   ("obeytabs" "true")))

  (org-babel-do-load-languages
   'org-babel-load-languages
   '((emacs-lisp . t)
     (gnuplot . t)
     (latex . t)
     (makefile . t)
     (org . t)
     (python . t)
     (shell . t)
     (C . t)
     (awk . t)
     (lisp . t)
     (matlab . t)
     (sed . t))))

(setq org-hide-emphasis-markers t)

(setq org-todo-keywords
      (quote ((sequence "TODO(t)" "NEXT(n)" "|" "DONE(d!)")
              (sequence "WAITING(w@/!)" "HOLD(h@/!)" "|" "CANCELLED(c@/!)"))))

(setq org-todo-keyword-faces
      (quote (("TODO" :foreground "crimson" :weight bold)
              ("NEXT" :foreground "yellow" :weight bold)
              ("DONE" :foreground "forest green" :weight bold)
              ("WAITING" :foreground "cyan" :weight bold)
              ("HOLD" :foreground "orange" :weight bold)
              ("CANCELLED" :foreground "forest red" :weight bold))))

(setq org-todo-state-tags-triggers
      (quote (("CANCELLED" ("CANCELLED" . t))
              ("WAITING" ("WAITING" . t))
              ("NEXT" ("NEXT" . t))
              ("HOLD" ("WAITING") ("HOLD" . t))
              (done ("WAITING") ("HOLD") ("NEXT"))
              ("TODO" ("WAITING") ("CANCELLED") ("HOLD") ("NEXT"))
              ("DONE" ("WAITING") ("CANCELLED") ("HOLD") ("NEXT")))))

(setq org-agenda-files '("~/org/inbox.org"
                         "~/org/repeaters.org"))

(setq org-capture-templates
      '(("b" "Bookmark" entry (file "~/org/bookmarks.org")
         "* %?\n:PROPERTIES:\n:CREATED: %U\n:END:\n\n" :empty-lines 1)
        ("B" "Bookmark with Cliplink" entry (file "~/org/bookmarks.org")
         "* %(org-cliplink-capture)\n:PROPERTIES:\n:CREATED: %U\n:END:\n\n" :empty-lines 1)
        ("t" "Todo" entry (file "~/org/inbox.org")
         "* TODO %?\n%U" :empty-lines 1)
        ("n" "Note" entry (file "~/org/inbox.org")
         "* TODO %?\n%U" :empty-lines 1)
        ("w" "CTW Work" entry (file "~/ctw/ctw-notes/inbox.org")
         "* TODO %?\n%U" :empty-lines 1)))

(setq org-agenda-custom-commands
      '(("d" "Agenda Dashboard"
         ((agenda ""
                  ((org-agenda-span 'week)))
          (todo "TODO"
                ((org-agenda-overriding-header "Unscheduled tasks")
                 (org-agenda-files '("~/org/todo.org"))
                 (org-agenda-skip-function '(org-agenda-skip-entry-if 'scheduled 'deadline))
                 ))
          (todo "TODO"
                ((org-agenda-overriding-header "Inbox tasks")
                 (org-agenda-files '("~/org/inbox.org"))
                 (org-agenda-skip-function '(org-agenda-skip-entry-if 'scheduled 'deadline))))))))

(setq org-default-notes-file (concat org-directory "~/org/inbox.org"))

(setq org-refile-targets '(("~/org/inbox.org" :level . 1)))

Org Mode extra settings

Handle bookmark capture links.

(use-package org-cliplink
  :commands (org-cliplink))

Add languages to org-structure-template-alist

(use-package org-tempo
  :ensure nil
  :after org
  :config
  (add-to-list 'org-structure-template-alist '("se" . "src emacs-lisp"))
  (add-to-list 'org-structure-template-alist '("sm" . "src markdown"))
  (add-to-list 'org-structure-template-alist '("sp" . "src python"))
  (add-to-list 'org-structure-template-alist '("ss" . "src sh")))

Org Contrib

(use-package org-contrib
  :after org
  :config
  (require 'ox-confluence))

Org Babel

(use-package ob-async
  :after org
  :config (require 'ob-async))

Org Export Engines

HTML back-End

(use-package htmlize
  :after org
  :config (require 'htmlize))

Beamer back-End

(use-package ox-beamer
  :ensure org
  :after ox
  :config
  (add-to-list 'org-latex-classes
               '("beamer"
                 "\\documentclass\[presentation\]\{beamer\}"
                 ("\\section\{%s\}" . "\\section*\{%s\}")
                 ("\\subsection\{%s\}" . "\\subsection*\{%s\}")
                 ("\\subsubsection\{%s\}" . "\\subsubsection*\{%s\}"))))

GitHub back-end

(use-package ox-gfm
  :after ox
  :config (require 'ox-gfm nil t))

Jira back-end

(use-package ox-jira
  :after ox)

References:

Shell

(use-package vterm
  :bind
  ("C-x t" . vterm))

Bitbake

bitbake-modes

(use-package mmm-mode
  :defer t
  :diminish mmm-mode)

(use-package bitbake-modes
  :load-path "~/src/bitbake-modes/")

Reference:

https://bitbucket.org/olanilsson/bitbake-modes/src/master/ http://xemacs.sourceforge.net/Documentation/packages/html/mmm_toc.html#SEC_Contents

Python

(use-package python
  :ensure nil
  :config
  (setq python-ts-mode-hook python-mode-hook))

Shell Script

(use-package sh-script
  :ensure nil
  :config
  (setq bash-ts-mode-hook sh-mode-hook))

PDF

(use-package pdf-tools
  :magic ("%PDF" . pdf-view-mode)
  :if window-system
  :config
  (pdf-tools-install :no-query)
  (setq-default pdf-view-display-size 'fit-page)
  (setq pdf-annot-activate-created-annotations t)
  (define-key pdf-view-mode-map (kbd "C-s") 'isearch-forward)
  (add-hook 'pdf-view-mode-hook (lambda () (cua-mode 0)))
  (setq pdf-view-resize-factor 1.1)
  (define-key pdf-view-mode-map (kbd "h") 'pdf-annot-add-highlight-markup-annotation)
  (define-key pdf-view-mode-map (kbd "t") 'pdf-annot-add-text-annotation)
  (define-key pdf-view-mode-map (kbd "D") 'pdf-annot-delete))

Markdown

(use-package markdown-mode
  :mode
  (("README\\.md\\'" . gfm-mode)
   ("\\.md\\'" . markdown-mode)
   ("\\.markdown\\'" . markdown-mode))
  :config
  (setq markdown-ts-mode-hook markdown-mode-hook)
  (setq markdown-command "multimarkdown")
  (setq-default fill-column 80))
(use-package yafolding
  :hook ((prog-mode . yafolding-mode)
         (conf-mode . yafolding-mode))
  :bind ("C-<tab>" . yafolding-toggle-element))

Ripgrep - Rg

(use-package rg)