Skip to content

Latest commit

 

History

History
executable file
·
4275 lines (3838 loc) · 134 KB

dots.org

File metadata and controls

executable file
·
4275 lines (3838 loc) · 134 KB

Emacs

Better defaults

Set better default for a better emacs start up

(setq default-directory user-emacs-directory
      gc-cons-percentage .6
      gc-cons-threshold most-positive-fixnum
      read-process-output-max (* 1024 1024))
;; Profile emacs startup
;; (add-hook 'emacs-startup-hook
;;           (lambda ()
;;             (message "*** Emacs loaded in %s with %d garbage collections."
;;                      (format "%.2f seconds"
;;                              (float-time
;;                               (time-subtract after-init-time before-init-time)))
;;                      gcs-done)))

Start server

(server-start)

Hide menu, tool-bar, scroll-bar

(menu-bar-mode -1)
(tool-bar-mode -1)
(scroll-bar-mode -1)
(tooltip-mode -1)

Default utf-8 encoding

(set-default-coding-systems 'utf-8)

Start in a blank page

This allow to start emacs in a blank page

(setq inhibit-startup-message t)
(setq initial-scratch-message "")

Disable custom file

I choose to lay out my configurations and customizations in this very Org document for better visibility and maintainability through time and various upgrades. Albeit useful, the customize-* routines go against that strategy by writing directly at the end of the user-init-file or into a dedicated file when set accordingly.

To fight the littering I’ve decided to completely disable this feature and redirect the writing to /dev/null.

(setq-default custom-file null-device)

Set font

(add-to-list 'default-frame-alist
             '(font . "IBM Plex Mono 12"))
;; (set-frame-font "IBM Plex Mono-12" nil t)
;; (set-frame-font "SF Mono-12" nil t)
;; (set-frame-font "Go Mono-12" nil t)
;; (set-frame-font "Noto Sans Mono SemiCondensed-12" nil t)
;; (set-frame-font "Cascadia Mono-12" nil t)
;; (set-face-attribute 'default nil
;;                     :family "IBM Plex Mono"
;;                     :height 130
;;                     :weight 'normal
;;                     :width 'normal)

Better scrolling

(setq scroll-margin 3
      scroll-conservatively 101
      scroll-up-aggressively 0.01
      scroll-down-aggressively 0.01
      scroll-preserve-screen-position t
      auto-window-vscroll nil)

Open buffer vertically (help buffer, pdf, etc)

(setq split-height-threshold nil)
(setq split-width-threshold 0)

Stop emacs from asking me if I want to load a large file

(setq large-file-warning-threshold nil)

Hide tabs

(setq tab-bar-show nil)

Convert tabs to white spaces

(setq-default indent-tabs-mode nil)

Make tabs to be 2 whitespaces width

(setq-default tab-width 2)

Delete trailing whitespace

This always creates unnecessary diffs in git. Just delete it upon saving.

(add-hook 'before-save-hook #'delete-trailing-whitespace)
(add-hook 'before-save-hook 'whitespace-cleanup)

Show trailing white spaces and empty lines

(setq-default show-trailing-whitespace nil)
(setq-default indicate-empty-lines t)

Configure compile command

;; use make as default command when M-x compile
(setq compile-command "make")
;; don't ask for confirmation to run make command
;; just run it
(setq compilation-read-command nil)

Preserve contents of system clipboard

Say you copied a link from your web browser, then switched to Emacs to paste it somewhere. Before you do that, you notice something you want to kill. Doing that will place the last kill to the clipboard, thus overriding the thing you copied earlier. We can have a kill ring solution to this with the following:

(setq save-interprogram-paste-before-kill t)

Now the contents of the clipboard are stored in the kill ring and can be retrieved from there (e.g. with M-y).

Update file whenever the file change

This mode ensures that the buffer is updated whenever the file changes. A change can happen externally or by some other tool inside of Emacs (e.g. kill a Magit diff).

(setq auto-revert-verbose t)
(add-hook 'after-init-hook 'global-auto-revert-mode)

Does anyone type yes anymore?

(fset 'yes-or-no-p 'y-or-n-p)

Do not display buffers with the name *Async Shell Command*

It is annoying when exactracting files with the UI program.

(add-to-list 'display-buffer-alist
             (cons "\\*Async Shell Command\\*.*" (cons #'display-buffer-no-window nil)))

Stop blinking cursor

Turn off the blinking cursor

(blink-cursor-mode -1)

Show-paren-mode

Highlight the the matching (){}[]

(show-paren-mode t)

Highlight current line

;; (global-hl-line-mode t)
;; (add-hook 'prog-mode-hook #'hl-line-mode)
(add-hook 'org-mode-hook #'hl-line-mode)

Stop asking to kill the process when exit emacs

(setq confirm-kill-processes nil)

Open help buffers in the current window

(add-to-list 'display-buffer-alist
             '("*Help*" display-buffer-same-window))

Backups and autosaves

(setq backup-directory-alist
      '(("." . "~/.emacs.d/backup/")))
(setq backup-by-copying t)
(setq version-control t)
(setq delete-old-versions t)
(setq kept-new-versions 6)
(setq kept-old-versions 2)
(setq create-lockfiles nil)
;; (setq make-backup-files nil)
(setq auto-save-default nil)
(setq auto-save-list-file-prefix nil)

Position register

(setq register-alist
  `((115 . ,(with-current-buffer "*scratch*" (point-marker)))
    (109 . ,(with-current-buffer "*Messages*" (point-marker)))
    (114 file . "~/.emacs.d/notes")
    (100 file . "~/Projects/dots/dots.org")))

Prettify Symbols

(global-prettify-symbols-mode 1)
(defun add-pretty-lambda ()
  "Make some word or string show as pretty Unicode symbols.  See https://unicodelookup.com for more."
  (setq prettify-symbols-alist
        '(
          ("lambda" . 955)
          ("delta" . 120517)
          ("epsilon" . 120518)
          ("->" . 8594)
          ("<=" . 8804)
          (">=" . 8805))))
(add-hook 'prog-mode-hook 'add-pretty-lambda)
(add-hook 'org-mode-hook 'add-pretty-lambda)

Enable recursive minibuffers

(setq enable-recursive-minibuffers t)

Do not allow the cursor in the minibuffer prompt

(setq minibuffer-prompt-properties
        '(read-only t cursor-intangible t face minibuffer-prompt))
(add-hook 'minibuffer-setup-hook #'cursor-intangible-mode)

Packages

straight.el

(defvar bootstrap-version)
(setq straight-repository-branch "develop")
(let ((bootstrap-file
       (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
      (bootstrap-version 5))
  (unless (file-exists-p bootstrap-file)
    (with-current-buffer
        (url-retrieve-synchronously
         "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
         'silent 'inhibit-cookies)
      (goto-char (point-max))
      (eval-print-last-sexp)))
  (load bootstrap-file nil 'nomessage))

(setq straight-use-package-by-default t)

use-package

(straight-use-package 'use-package)
;; (setq use-package-verbose t)

exec-path-from-shell

(use-package exec-path-from-shell
  :config
  (when (daemonp)
  (exec-path-from-shell-copy-env "LD_LIBRARY_PATH")
  (exec-path-from-shell-initialize)))

all-the-icons

(use-package all-the-icons)

doom-modeline

(use-package doom-modeline
  :hook (after-init . doom-modeline-mode)
  :custom
  (doom-modeline-modal-icon nil)
  (doom-modeline-lsp t)
  (doom-modeline-buffer-state-icon t)
  (doom-modeline-major-mode-icon nil)
  (doom-modeline-buffer-file-name-style 'file-name)
  ;; Whether display buffer encoding.
  (doom-modeline-buffer-encoding nil)
  (doom-modeline-icon (display-graphic-p)))

doom themes

(use-package doom-themes
  :custom
  (doom-themes-enable-bold t)    ; if nil, bold is universally disabled
  (doom-themes-enable-italic t)  ; if nil, italics is universally disabled
  (doom-themes-treemacs-theme "doom-colors") ; use the colorful treemacs theme
  :config
  ;; Load the theme (doom-one, doom-molokai, etc); keep in mind that each theme
  ;; may have their own settings.
  (load-theme 'doom-one t)
  ;; (load-theme 'doom-solarized-dark t)

  ;; Enable flashing mode-line on errors
  (doom-themes-visual-bell-config)

  ;; or for treemacs users
  (doom-themes-treemacs-config)

  ;; Corrects (and improves) org-mode's native fontification.
  (doom-themes-org-config))

general.el

(use-package general
  :config
  (general-evil-setup))

windmove

(use-package windmove
  :straight (:type built-in)
  :config
  (general-define-key
   :states '(normal insert motion emacs)
   "s-l" 'windmove-right
   "s-h" 'windmove-left
   "s-k" 'windmove-up
   "s-j" 'windmove-down)

  (general-define-key
   :states 'normal
   :prefix "C-c"
   "r l" 'windmove-delete-right
   "r h" 'windmove-delete-left
   "r j" 'windmove-delete-down
   "r k" 'windmove-delete-up))

winner-mode

(use-package winner
  :straight (:type built-in)
  :hook
  (after-init . winner-mode)
  :general
  (:states '(normal insert motion emacs)
           "s-n" 'winner-undo
           "s-m" 'winner-redo))

org

(use-package org
  :custom
  (org-startup-folded t)
  ;; (org-hide-emphasis-markers t)
  (org-agenda-files '("~/org/tasks.org"))
  ;; to be able to use #+attr_org: :width
  (org-image-actual-width nil)
  (org-startup-with-inline-images t)
  (org-display-remote-inline-images 'download)
  ;; inline latex like $y=mx+c$ will appear in a different colour in
  ;; an org-mode file to help it stand out
  (org-highlight-latex-and-related '(latex))
  (org-ellipsis "")
  ;; syntax highlight
  (org-src-fontify-natively t)
  (org-src-tab-acts-natively t)
  (org-src-window-setup 'current-window)
  (org-edit-src-content-indentation 0)
  (org-src-preserve-indentation nil)
  (org-imenu-depth 7)
  ;; Don't ask for confirm when evaluating a source block
  (org-confirm-babel-evaluate nil)
  ;; RETURN will follow links in org-mode files
  (org-return-follows-link  t)
  (org-export-backends '(ascii beamer html latex md))
  ;; (org-image-actual-width '(300))
  :config
  ;; To Github Flavored Markdown
  (eval-after-load "org"
    '(require 'ox-gfm nil t))

  ;; The defaults use an old MathJax version
  (setf org-html-mathjax-options
        '((path "https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML")
          (scale "100")
          (align "center")
          (indent "2em")
          (mathml nil)))
  (setf org-html-mathjax-template
        "<script type=\"text/javascript\" src=\"%PATH\"></script>")

  ;; Font size control of LateX previews in Org files
  (setq org-format-latex-options (plist-put org-format-latex-options :scale 1.5))

  ;; https://emacs.stackexchange.com/questions/29902/more-detailed-description-of-how-to-set-up-org-file-apps-for-orgmode-9-0
  ;; how to open attach files in an org file
  (setq org-file-apps
        '(("\\.docx\\'" . default)
          ("\\.mm\\'" . default)
          ("\\.pdf::\\([0-9]+\\)?\\'" . "zathura %s -P %1")
          ("\\.x?html?\\'" . default)
          ("\\.pdf\\'" . "zathura \"%s\"")
          (auto-mode . emacs)))
  ;; open org-links with a specific program.
  ;; in this case open pdf files with zathura
  ;; (add-hook 'org-mode-hook
  ;;           '(lambda ()
  ;;              (setq org-file-apps
  ;;                    '((auto-mode . emacs)
  ;;                      ("\\.pdf::\\([0-9]+\\)?\\'" . "zathura %s -P %1")
  ;;                      ("\\.pdf\\'" . "zathura %s")
  ;;                      (directory . emacs)))))

  (add-hook 'org-mode-hook (lambda () (setq fill-column 80)))
  ;; This break the line but only when editing
  (add-hook 'org-mode-hook 'auto-fill-mode)
  ;; Visualy break the line of the frame size
  (add-hook 'org-mode-hook 'visual-line-mode)

  ;; puts the cursor in the right position
  ;; when hitting enter
  (add-hook 'org-mode-hook 'org-indent-mode)
  (add-hook 'org-babel-after-execute-hook 'org-redisplay-inline-images)
  (org-babel-do-load-languages
   'org-babel-load-languages
   '((dot . t)
     (js . t)
     (latex . t)
     (calc . t)
     (shell . t)
     (scheme . t)
     (sql . t)
     (lisp . t)
     (C . t)
     (python . t)
     (emacs-lisp . t)))
  :general
  (:states '(normal)
           :keymaps 'org-mode-map
           "<tab>" 'org-cycle
           "C-c c o n" 'org-toggle-narrow-to-subtree
           "C-c c o t" 'ram/org-set-tags
           "h" 'left-char)
  (:states 'insert
           :keymaps 'org-mode-map
           "C-c c o i" 'indent-relative
           "<tab>" 'org-cycle
           ))

;; (straight-use-package '(org :source gnu-elpa-mirror))

org-contrib

https://git.sr.ht/~bzg/org-contrib https://orgmode.org/Changes.html https://elpa.nongnu.org/nongnu/ radian-software/straight.el#762

(use-package org-contrib)
(straight-use-package '(setup :type git :host nil :repo "https://git.sr.ht/~pkal/setup"))

org-appear

(use-package org-appear
  :custom
  (org-appear-autolinks t)
  (org-appear-submarkers t)
  :hook (org-mode . org-appear-mode))

ox-publish

(use-package ox-publish
  :straight (:type built-in)
  :config
  (setq org-publish-use-timestamps-flag nil)
  (setq org-export-with-broken-links t)
  (setq org-publish-project-alist
        '(("blog"
           :base-directory "/home/last/Documents/org"
           :base-extension "org"
           :publishing-directory "/home/last/Documents/org/public"
           :recursive nil
           :publishing-function org-org-publish-to-org
           :htmlized-source t
           ;; HTML5
           :html-doctype
           "html5"
           :html-html5-fancy t
           ;; Disable some Org's HTML defaults
           :html-head-include-scripts nil
           :html-head-include-default-style nil
           :auto-sitemap t
           :sitemap-title "Ram's Blog"
           :sitemap-filename "index.org"
           :sitemap-style list)
          ("all" :components ("blog"))
          )))

org-html-themify

(use-package org-html-themify
  :straight
  (org-html-themify
   :type git
   :host github
   :repo "DogLooksGood/org-html-themify"
   :files ("*.el" "*.js" "*.css"))
  :hook (org-mode . org-html-themify-mode)
  :custom
  (org-html-themify-themes
   '((dark . doom-one)
     (light . doom-one))))

htmlize

(use-package htmlize)

spell checking

From stackexchange, ispell can be configured to skip over regions that match regexes. For example, to skip over :PROPERTIES: and :LOGBOOK: drawers as well as SRC AND EXAMPLE blocks:

(add-to-list 'ispell-skip-region-alist '(":\\(PROPERTIES\\|LOGBOOK\\):" . ":END:"))
(add-to-list 'ispell-skip-region-alist '("#\\+BEGIN_SRC" . "#\\+END_SRC"))
(add-to-list 'ispell-skip-region-alist '("#\\+BEGIN_EXAMPLE" . "#\\+END_EXAMPLE"))

evil

(use-package evil
  :hook (after-init . evil-mode)
  :custom
  (evil-undo-system 'undo-fu)
  ;; change the color of the cursor
  (evil-normal-state-cursor '("gray" box))
  (evil-visual-state-cursor '("orange" box))
  (evil-insert-state-cursor '("dodger blue" bar))
  (evil-replace-state-cursor '("red" bar))
  ;; use emacs bindings in insert-mode
  (evil-disable-insert-state-bindings t)
  (evil-want-keybinding nil)
  :config
  (evil-set-initial-state 'dired-mode 'normal)
  (evil-set-initial-state 'wdired-mode 'normal)
  (evil-set-initial-state 'org-mode 'normal)
  (evil-set-initial-state 'vterm-mode 'insert)
  (evil-set-initial-state 'prog-mode 'normal)
  (evil-set-initial-state 'ebib-index-mode 'emacs)
  (evil-set-initial-state 'org-fc-dashboard-mode 'emacs)
  (evil-set-initial-state 'org-fc-flip-mode 'emacs)
  (evil-set-initial-state 'org-fc-rate-mode 'emacs)
  (evil-set-initial-state 'Info-mode 'emacs)
  (evil-set-initial-state 'org-fc-review-rate-mode 'emacs)
  (evil-set-initial-state 'org-fc-review-flip 'emacs)
  (evil-set-initial-state 'calibredb-search-mode 'emacs)
  (evil-set-initial-state 'exwm-mode 'emacs)
  (evil-set-initial-state 'rg-mode 'emacs)
  ;; (evil-set-initial-state 'nov-mode 'emacs)
  (evil-set-initial-state 'image-mode 'emacs)
  (evil-set-initial-state 'eshell-mode 'normal)
  (evil-set-initial-state 'pdf-view-mode 'emacs)
  (evil-set-initial-state 'pdf-annot-list-mode 'emacs)
  (evil-set-initial-state 'pdf-outline-buffer-mode 'emacs)
  :general
  (:states '(emacs normal motion insert visual)
           "C-c c r k" '(lambda () (interactive) (kill-line 0))
           "C-c c v u" 'evil-scroll-up
           "C-c c v d" 'evil-scroll-down
           "C-c c e ," 'mode-line-other-buffer
           "C-c c e t" 'ram/switch-recent-tab
           "C-c c d d" '(lambda() (interactive) (dired default-directory))
           )
  (:states '(normal motion)
           "C-p" 'previous-line
           "C-n" 'next-line
           "C-a" 'evil-first-non-blank
           "C-e" 'evil-last-non-blank
           "C-f" 'forward-char
           "C-b" 'backward-char
           "j" 'evil-next-visual-line
           "k" 'evil-previous-visual-line
           "m" 'point-to-register
           "'" 'jump-to-register
           "gp" 'ram/evil-select-pasted)
  (:states 'normal
           :keymaps 'messages-buffer-mode-map
           "q" 'quit-window))

evil-commentary

(use-package evil-commentary
  :after evil)

evil-surround

(use-package evil-surround
  :after evil
  :config
  (setq-default evil-surround-pairs-alist
                (append '((?p . ("(" . ")"))
                          (?s . ("*" . "*"))
                          (?w . ("%" . "%"))
                          (?x . ("$" . "$"))
                          (?q . ("@" . "@")))
                        evil-surround-pairs-alist))
  (global-evil-surround-mode 1))

dired

(use-package dired
  ;;:commands (dired dired-jump)
  :straight (:type built-in)
  :hook ((dired-mode . hl-line-mode)
         (dired-mode . dired-hide-details-mode))
  :custom
  (dired-recursive-copies 'always)
  (dired-recursive-deletes 'always)
  (dired-dwim-target t) ;;use to copy to the next buffer visible
  ;; Auto refresh Dired, but be quiet about it
  (global-auto-revert-non-file-buffers t)
  (auto-revert-verbose nil)
  (image-dired-external-viewer (executable-find "sxiv"))
  :config
  ;; Enable global auto-revert
  (global-auto-revert-mode t)
  ;; Reuse same dired buffer, to prevent numerous buffers while navigating in dired
  (put 'dired-find-alternate-file 'disabled nil)

  (setq dired-listing-switches "-Bhl --group-directories-first -v")
  (set-face-attribute 'dired-header nil
                      :foreground "#282c34"
                      :weight 'bold)

  (defcustom list-of-dired-switches
    '(("-Bhl --group-directories-first -v" . "")
      ("-ahl -v --group-directories-first -v" . "everything")
      ;; ("-BhlAL --group-directories-first -v" . "no . & ..")
      )
    "List of ls switches (together with a name to display in the mode-line) for dired to cycle among.")


  (defun cycle-dired-switches ()
    "Cycle through the list `list-of-dired-switches' of switches for ls"
    (interactive)
    (setq list-of-dired-switches
          (append (cdr list-of-dired-switches)
                  (list (car list-of-dired-switches))))
    (dired-sort-other (caar list-of-dired-switches))
    (setq mode-name (concat "Dired " (cdar list-of-dired-switches)))
    (force-mode-line-update))

  ;; remove buffers before delete the file
  (defun ram/dired-kill-before-delete (file &rest rest)
    (when-let ((buf (get-file-buffer file)))
      (kill-buffer buf)))

  (advice-add 'dired-delete-file :before 'ram/dired-kill-before-delete)

  :general
  (:states 'normal
           :keymaps 'dired-mode-map
           "j" 'dired-next-line
           "k" 'dired-previous-line
           "l" 'ram/dired-open
           "h" 'dired-up-directory
           "yy" 'dired-do-copy
           "yn" 'dired-copy-filename-as-kill
           "yp" (lambda() (interactive) (dired-copy-filename-as-kill 0))
           "gk" (lambda() (interactive) (dired "~/Documents"))
           "gn" (lambda() (interactive) (dired "~/Documents/notes"))
           "gd" (lambda() (interactive) (dired "~/Downloads"))
           "gp" (lambda() (interactive) (dired "~/Projects"))
           "gk" (lambda() (interactive) (dired "~/Projects/katas"))
           "ge" (lambda() (interactive) (dired "~/.emacs.d"))
           "gc" (lambda() (interactive) (dired "~/.config"))
           "gs" (lambda() (interactive) (dired "~/bin/scripts"))
           "gy" (lambda() (interactive) (dired "~/Projects/playground"))
           "gb" (lambda() (interactive) (dired "~/bin"))
           "gm" (lambda() (interactive) (dired "/media"))
           "gh" (lambda() (interactive) (dired "~"))
           "m" 'dired-mark
           "u" 'dired-unmark
           "t" 'dired-toggle-marks
           "cw" 'dired-do-rename
           "r" 'revert-buffer
           "nd" 'dired-create-directory
           "nf" 'dired-create-empty-file
           "np" 'ram/create-project
           "nk" 'ram/create-kata
           "s" 'dired-do-async-shell-command
           "q" 'quit-window
           "w" 'dired-toggle-read-only
           "W" 'wdired-finish-edit
           "x" 'dired-do-compress
           "za" 'cycle-dired-switches
           "zd" 'dired-hide-details-mode
           "M" 'point-to-register
           "'" 'jump-to-register
           "fz" 'dired-narrow-fuzzy
           "fe" 'dired-filter-by-extension
           "fc" 'dired-filter-pop-all
           "ff" 'dired-narrow-regexp
           "d" 'dired-hide-details-mode
           "i" 'image-dired-show-all-from-dir
           "I" (lambda() (interactive) (find-file (dired-get-filename)))
           "D" 'dired-do-delete)
  (:states 'normal
           :keymaps 'image-dired-thumbnail-mode-map
           "l" 'image-dired-forward-image
           "h" 'image-dired-backward-image
           "k" 'image-dired-previous-line
           "j" 'image-dired-next-line
           "m" 'image-dired-toggle-mark-thumb-original-file
           "s" 'image-dired-display-thumbnail-original-image
           "q" 'quit-window
           "SPC" 'image-dired-thumbnail-display-external)
  (:states 'normal
           :keymaps 'image-dired-display-image-mode-map
           "q" 'quit-window))

dired-hacks-utils

(use-package dired-hacks-utils
  :after dired)

dired-narrow

(use-package dired-narrow
  :after dired)

dired-filter

(use-package dired-filter
  :after dired)

dired-avfs

(use-package dired-avfs
  :after dired)

selectrum

(use-package selectrum
  :straight (selectrum :host github :repo "raxod502/selectrum")
  :hook
  (after-init . selectrum-mode)
  :config
  ;; (setq selectrum-prescient-enable-filtering nil)

  (setq orderless-skip-highlighting (lambda () selectrum-is-active))

  ;; Completing variable names from `M-:`
  (setq enable-recursive-minibuffers t)

  (setq selectrum-refine-candidates-function #'orderless-filter)
  (setq selectrum-highlight-candidates-function #'orderless-highlight-matches))

(use-package selectrum-prescient
  :after selectrum
  :straight (selectrum-prescient :host github :repo "raxod502/prescient.el"
                                 :files ("selectrum-prescient.el"))
  :config
  (selectrum-prescient-mode +1)
  ;; to save your command history on disk, so the sorting gets more
  ;; intelligent over time
  (prescient-persist-mode +1))

vertico

(use-package vertico
  :init
  (vertico-mode))

savehist

Persist history over Emacs restarts. Vertico sorts by history position.

(use-package savehist
  :init
  (savehist-mode))

orderless

(use-package orderless
  :init (icomplete-mode)                ; optional but recommended!
  :config
  (setq completion-styles '(substring orderless)
        completion-category-defaults nil
        completion-category-overrides '((file (styles . (partial-completion))))))

consult

(use-package consult
  :straight (consult :type git
                     :host github
                     :repo "minad/consult")
  :general
  (:states '(normal insert emacs)
           "M-y" 'consult-yank-pop
           "C-x b" 'consult-buffer
           "C-c c c r" 'consult-ripgrep
           "C-c c n o" 'consult-outline))

marginalia

;; Enable richer annotations using the Marginalia package
(use-package marginalia
  :after consult
  :bind (:map minibuffer-local-map
              ("C-M-a" . marginalia-cycle)
              ;; When using the Embark package, you can bind `marginalia-cycle' as an Embark action!
              ;;:map embark-general-map
              ;;     ("A" . marginalia-cycle)
              )

  ;; The :init configuration is always executed (Not lazy!)
  :init

  ;; Must be in the :init section of use-package such that the mode gets
  ;; enabled right away. Note that this forces loading the package.
  (marginalia-mode)

  ;; When using Selectrum, ensure that Selectrum is refreshed when cycling annotations.
  (advice-add #'marginalia-cycle :after
              (lambda () (when (bound-and-true-p selectrum-mode) (selectrum-exhibit))))

  ;; Prefer richer, more heavy, annotations over the lighter default variant.
  ;; E.g. M-x will show the documentation string additional to the keybinding.
  ;; By default only the keybinding is shown as annotation.
  ;; Note that there is the command `marginalia-cycle' to
  ;; switch between the annotators.
  (setq marginalia-annotators '(marginalia-annotators-heavy marginalia-annotators-light nil)))

embark

(use-package embark
  :general
  (:states '(normal insert)
           "C-c c k d" 'embark-dwim
           "C-c c k a" 'embark-act))

consult-projectile

(use-package consult-projectile
  :straight (consult-projectile
             :type git
             :host gitlab
             :repo "OlMon/consult-projectile"
             :branch "master")
  :after (consult projectile))

vterm

Install cmake to be able to install vterm

(use-package vterm
  :general
  (:states 'insert
           :keymaps 'vterm-mode-map
           "C-c c r k" 'vterm-send-C-u
           "M-y" 'ram/vterm-consult-yank-pop
           "<tab> f" 'ram/vterm-completion-file-dir))

vterm-toggle

(use-package vterm-toggle
  :init
  :general
  (:states '(emacs normal insert visual)
           "C-c c v v" '(lambda () (interactive)
                          (if (string-equal (buffer-name) "*vterm*")
                              (vterm-toggle-cd)
                            ;; open vterm in full-screen
                            ;; 4 -> C-u
                            (vterm-toggle-cd 4)))))

Undo Fu

(use-package undo-fu
  :general
  (:states '(normal)
           "u" 'undo-fu-only-undo
           "C-r" 'undo-fu-only-redo)
  (:states '(insert emacs)
           "C-/" 'undo-fu-only-undo))

company

(use-package company
  :custom
  (company-idle-delay 0)
  :config
  (setq company-capf t)
  ;; (push 'company-capf company-backends)
  ;; (add-to-list 'company-backends '(company-capf company-dabbrev))
  ;; (global-company-mode t)

  (define-key company-active-map (kbd "<tab>") nil)
  :general
  (:states '(emacs insert)
           "C-j" 'company-complete)
  (:states '(normal insert)
           :keymaps 'company-active-map
           "C-n" 'company-select-next-or-abort
           "C-p" 'company-select-previous-or-abort))

fancy-dabbrev

(use-package fancy-dabbrev
  :init
  (global-fancy-dabbrev-mode t)
  :config
  ;; Let dabbrev searches ignore case and expansions preserve case:
  (setq dabbrev-case-distinction nil)
  (setq dabbrev-case-fold-search t)
  (setq dabbrev-case-replace nil)

  (setq fancy-dabbrev-preview-delay 0.1)
  (setq fancy-dabbrev-preview-context 'before-non-word)

  (setq fancy-dabbrev-expansion-on-preview-only t)
  (setq fancy-dabbrev-indent-command 'tab-to-tab-stop)
  :general
  (:states '(emacs insert)
           "C-c c f d" 'fancy-dabbrev-expand-or-indent))

corfu

(use-package corfu
  :init
  (corfu-global-mode)
  :custom
  (corfu-cycle t)                ;; Enable cycling for `corfu-next/previous'
  :general
  (:states 'insert
           :keymaps 'corfu-mode-map
           "C-n" 'corfu-next)
  (:states 'insert
           "C-." 'completion-at-point))

projectile

(use-package projectile
  :custom
  (projectile-completion-system 'default)
  (projectile-create-missing-test-files t)
  :config
  ;; (setq projectile-project-search-path '("~/Projects/"))
  (setq projectile-switch-project-action #'projectile-dired)

  (projectile-mode +1)
  (add-to-list 'projectile-project-root-files-bottom-up "pubspec.yaml")
  (add-to-list 'projectile-project-root-files-bottom-up "pyproject.toml")
  (add-to-list 'projectile-project-root-files-bottom-up "package.json")
  (add-to-list 'projectile-project-root-files-bottom-up "Makefile")
  (add-to-list 'projectile-project-root-files-bottom-up "Eldev")
  (add-to-list 'projectile-project-root-files-bottom-up "lisp.org")
  (add-to-list 'projectile-project-root-files-bottom-up "dev_deps.ts")

  (projectile-register-project-type 'lisp '("lisp.org" "README.markdown")
                                    :src-dir "src/"
                                    :related-files-fn (list
                                                       (projectile-related-files-fn-groups
                                                        :test
                                                        '(("src/main.lisp"
                                                           "test/main.lisp"))))

                                    :test (format "sbcl --noinform --non-interactive --eval '(ql:quickload \"%s/tests\")' --eval '(asdf:test-system :%s)'" (projectile-project-name) (projectile-project-name))
                                    :test-dir "tests/"
                                    :test-suffix "")

  (projectile-register-project-type 'dart '("pubspec.yaml")
                                    :test "dart run test"
                                    :configure "dart pub get"
                                    :run "webdev serve"
                                    :test-dir "test/"
                                    :test-suffix "_test")

  (projectile-register-project-type 'deno '("dev_deps.ts")
                                    :run "deno run"
                                    :test "deno test test/"
                                    :test-dir "test/"
                                    :test-suffix "_test")

  (projectile-register-project-type 'python '("pyproject.toml")
                                    :project-file "pyproject.toml"
                                    :test "poetry run pytest"
                                    :test-dir "tests/"
                                    :test-suffix "_test")

  (projectile-register-project-type 'npm '("package.json")
                                    :project-file "package.json"
                                    :configure "npm install"
                                    :test "npm test"
                                    :run "npm start"
                                    :test-dir "__tests__"
                                    :test-suffix ".test")

  (projectile-register-project-type 'cpp '("Makefile")
                                    :project-file "Makefile"
                                    :compile "make"
                                    :run "make run"
                                    :test "make test"
                                    :test-dir "tests/"
                                    :test-suffix "_test")

  (projectile-register-project-type 'elisp '("Eldev")
                                    :project-file "Eldev"
                                    :test "eldev test"
                                    :test-dir "tests/"
                                    :test-suffix "-test")

  :general
  (:states '(normal insert emacs motion)
           "<f7>" 'projectile-configure-project)
  (:states 'normal
           :prefix ","
           "t" 'projectile-toggle-between-implementation-and-test)

  (:prefix "C-c p"
           :states '(normal insert emacs motion)
           "f" 'projectile-find-file
           "d" 'projectile-dired
           "r" 'projectile-run-project
           "c" 'projectile-compile-project
           "t" 'projectile-test-project
           "g" 'projectile-ripgrep
           "p" 'projectile-switch-project
           "b" 'projectile-switch-to-buffer
           "v" 'projectile-run-vterm))

ansi-color

This fix the problem with the compilation buffer. The poblem was that when doing projectile-test-project the compilation buffer add many characters making it difficult to read.

(use-package ansi-color
  :init
  ;; (defun my-colorize-compilation-buffer ()
  ;;   (when (eq major-mode 'compilation-mode)
  ;;     (ansi-color-apply-on-region compilation-filter-start (point))))
  (defun my-colorize-compilation-buffer ()
    (toggle-read-only)
    (ansi-color-apply-on-region (point-min) (point-max))
    (toggle-read-only))
  ;; (defun my-colorize-compilation-buffer ()
  ;;   (when (eq major-mode 'compilation-mode)
  ;;     (ansi-color-apply-on-region compilation-filter-start (point-max))))
  :hook (compilation-filter . my-colorize-compilation-buffer)
  :config
  (add-hook 'compilation-filter-hook 'ansi-color-for-comint-mode-on))

magit

(use-package magit
  :commands magit-status
  :custom
  ;; When maintaining a number of projects, it sometimes is necessary
  ;; to produce a full list of them with their corresponding Magit
  ;; status. That way you can determine very quickly which repositories
  ;; need to be examined further. (magit-list-repositories)
  (magit-repository-directories
   '(("~/Projects" . 1))))

evil-magit

(use-package evil-magit
  :after (magit))

forge

(use-package forge
  :after magit)

git-timemachine

(use-package git-timemachine
  :after magit
  :general
  (:states 'normal
           :keymaps 'git-timemachine-mode-map
           "p" 'git-timemachine-show-previous-revision
           "n" 'git-timemachine-show-next-revision
           "g" 'git-timemachine-show-nth-revision
           "t" 'git-timemachine-show-revision-fuzzy
           "q" 'git-timemachine-quit
           "w" 'git-timemachine-kill-abbreviated-revision
           "W" 'git-timemachine-kill-revision
           "b" 'git-timemachine-blame
           "c" 'git-timemachine-show-commit
           "?" 'git-timemachine-help))

git-link

(use-package git-link
  :after magit)

yaml-mode

(use-package yaml-mode
  :mode ("\\.yaml\\'")
  :hook (yaml-mode . lsp-deferred))

prog-mode

(use-package prog-mode
  :straight (:type built-in)
  :general
  (:states 'normal
           :keymaps 'prog-mode-map
           "<f6>" 'async-shell-command
           "gc" 'evil-commentary
           "gb" 'evil-jump-backward))

c-mode and c++-mode

(use-package cc-mode
  :straight (:type built-in)
  :init
  (add-to-list 'auto-mode-alist '("\\.cppm\\'" . c++-mode))
  (add-to-list 'auto-mode-alist '("\\.cxx\\'" . c++-mode))
  (add-to-list 'auto-mode-alist '("\\.mxx\\'" . c++-mode))
  (defun remove-electric-indent-mode ()
    (electric-indent-local-mode -1))
  :hook
  (c++-mode . remove-electric-indent-mode)
  (c-mode . remove-electric-indent-mode)
  :general
  (:states '(emacs normal insert visual)
           :keymaps '(c++-mode-map c-mode-map)
           "C-;" 'ram/insertSemicolon))

make-mode

(use-package make-mode
  :straight (:type built-in)
  :config
  (add-hook 'makefile-mode-hook
            (lambda ()
              (setq indent-tabs-mode t)
              (setq-default indent-tabs-mode t)
              (setq tab-width 8))))

js-mode

The actual problem is that you passed the wrong library name to use-package. You used js-mode, but there is no js-mode.el on the load-path. The filename is js.el, thus you should pass js to use-package. This is independent of straight.el.

(use-package js
  :defer 3
  :config
  (add-hook 'js-mode-hook (lambda () (setq js-indent-level 2
                                           tab-width 2)))
  (general-define-key
   :states '(emacs normal insert visual)
   :keymaps 'js-mode-map
   "<f5>" (lambda()
            (interactive)
            (async-shell-command
             (concat "node " (buffer-file-name)) "*javascript output*"))
   "C-;" 'ram/insertSemicolon))

python-mode

;; The package is "python" but the mode is "python-mode":
(use-package python
  :straight (:type built-in)
  :mode ("\\.py\\'" . python-mode)
  :interpreter ("python" . python-mode)
  :config
  (general-define-key
   :states 'normal
   :keymaps 'python-mode-map
   "<f5>" (lambda()
            (interactive)
            (async-shell-command
             (concat "python " (buffer-file-name)) "*python output*"))))

pyvenv

(use-package pyenv-mode
  :defer 5
  :init
  (add-to-list 'exec-path "~/bin/pyenv/shims")
  (setq pyenv-installation-dir "~/bin/pyenv/bin")
  :config
  (pyenv-mode))

lisp-interaction-mode

(use-package elisp-mode
  :straight nil
  :general
  (:states 'normal
           :keymaps 'lisp-interaction-mode-map
           "gr" 'eval-defun))

go-mode

(use-package go-mode
  :mode "\\.go\\'"
  :general
  (:states 'normal
           :keymaps 'go-mode-map
           "<f5>" (lambda()
                    (interactive)
                    (async-shell-command
                     (concat "go run " (buffer-file-name)) "*go output*"))))

json-mode

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

dart-mode

(use-package dart-mode
  :general
  (:states '(emacs normal insert visual)
           :keymaps 'dart-mode-map
           "<f5>" (lambda()
                    (interactive)
                    (async-shell-command
                     (concat "dart --enable-experiment=non-nullable " (buffer-file-name)) "*dart output*"))
           "C-;" 'ram/insertSemicolon))

haskell-mode

(use-package haskell-mode
  :mode ("\\.hs\\'")
  :general
  (:states '(emacs normal insert visual)
           :keymaps 'haskell-mode-map
           "<f5>" (lambda()
                    (interactive)
                    (async-shell-command
                     (concat "ghc -e main " (buffer-name)) "*haskell output*"))))

typescript-mode

(use-package typescript-mode
  :mode ("\\.ts\\'"))

sly (common-lisp)

(use-package sly
  :straight (sly :type git :host github :repo "joaotavora/sly")
  :custom (inferior-lisp-program "~/bin/sbcl/bin/sbcl --noinform")
  :commands sly
  :init
  ;; Activate common lisp highlight syntax to SBCL configuration file
  (add-to-list 'auto-mode-alist '("\\.sbclrc\\'" . lisp-mode))
  ;; Activate common lisp highlight syntax to Stumpwm configuration file
  (add-to-list 'auto-mode-alist '("\\.stumpwmrc\\'" . lisp-mode))
  :general
  (:states 'normal
           :keymaps 'sly-mode-map
           "K" 'sly-documentation-lookup
           "g i" 'sly-autodoc-manually
           "g d" 'sly-edit-definition))

geiser (guile, racket)

(use-package geiser
  :straight (geiser :type git :host gitlab :repo "emacs-geiser/geiser")
  :commands geiser
  :general
  (:states '(normal insert)
           :keymaps 'geiser-repl-mode-map
           "C-l" 'geiser-repl-clear-buffer)
  (:states 'normal
           :keymaps 'geiser-debug-mode-map
           "q" 'View-quit)
  :init
  (add-hook 'scheme-mode-hook 'geiser-mode)
  (setq geiser-default-implementation 'guile)
  (setq geiser-active-implementations '(guile))
  (setq geiser-guile-binary (executable-find "guile"))
  (setq geiser-racket-binary (executable-find "racket"))
  ;; the value matches comments starting with three semicolons and opening parens on the first column
  (add-hook 'scheme-mode-hook
            (lambda ()
              (outline-minor-mode 1)
              (set (make-local-variable 'outline-regexp) ";;\\(?:;[^#]\\|\\*+\\)\\|(define")
              (outline-hide-body))))

(use-package geiser-guile
  :straight (geiser-guile :type git :host gitlab :repo "emacs-geiser/guile")
  :after geiser)

(use-package geiser-racket
  :straight (geiser-racket :type git :host gitlab :repo "emacs-geiser/racket")
  :after geiser)

ob-racket

(use-package ob-racket
  :after org
  :straight (ob-racket
	           :type git :host github :repo "hasu/emacs-ob-racket"
	           :files ("*.el" "*.rkt"))
  :config
  (add-hook 'ob-racket-pre-runtime-library-load-hook
	          #'ob-racket-raco-make-runtime-library)
  (append '((racket . t) (scribble . t)) org-babel-load-languages))

racket-mode

(use-package racket-mode
:hook (racket-mode . racket-xp-mode))

lsp-mode

Before installing lsp-mode, set LSP_USE_PLISTS=true enviroment variable. Otherwise clangd will complain. If you install lsp-mode without setting LSP_USE_PLISTS, you need to remove lsp-mode repo and install it again.

(use-package lsp-mode
  :straight (lsp-mode :type git :host github :repo "emacs-lsp/lsp-mode")
  :hook
  ((go-mode . lsp-deferred)
   (python-mode . lsp-deferred)
   (js-mode . lsp-deferred)
   (c++-mode . lsp-deferred)
   (c-mode . lsp-deferred)
   (before-save . lsp-format-buffer)
   (before-save . lsp-organize-imports))
  :custom
  (lsp-clients-clangd-executable (concat (getenv "HOME") "/bin/clang/bin/clangd"))
  (lsp-clients-clangd-args '("--header-insertion-decorators=0" "-j=4" "--suggest-missing-includes" "-background-index" "-log=error" "--clang-tidy"))
  :init
  (setq lsp-use-plists t))
(use-package lsp-mode
  :straight (lsp-mode :type git :host github :repo "emacs-lsp/lsp-mode")
  :hook
  ((lsp-completion-mode . ram/lsp-mode-setup-completion)
   (go-mode . lsp-deferred)
   (python-mode . lsp-deferred)
   (js-mode . lsp-deferred)
   (c++-mode . lsp-deferred)
   (c-mode . lsp-deferred)
   (before-save . lsp-format-buffer)
   (before-save . lsp-organize-imports))
  :custom
  (lsp-completion-provider :none) ;; we use Corfu!
  (lsp-auto-guess-root t)                ;; auto guess root
  ;; disable showing documentation in the minibuffer
  ;; (lsp-eldoc-hook t)
  ;; (lsp-signature-auto-activate nil)
  ;; (lsp-signature-doc-lines 1)
  ;; (lsp-signature-render-documentation nil)
  (lsp-gopls-complete-unimported t)
  (lsp-prefer-capf t)                    ;; using `company-capf' by default
  (lsp-signature-auto-activate nil)
  (lsp-lens-enable nil)
  (lsp-ui-doc-enable nil)
  (lsp-semantic-highlighting 'immediate)
  (lsp-headerline-breadcrumb-enable nil)
  (lsp-clients-clangd-executable (concat (getenv "HOME") "/bin/clang/bin/clangd"))
  ;; (lsp-clients-clangd-args '("--header-insertion-decorators=0" "-j=4" "-background-index" "-log=error" "--clang-tidy"))
  :init
  ;; https://twitter.com/yonchovski/status/1384899744670093315
  (setq lsp-use-plists t)
  (defun ram/lsp-mode-setup-completion ()
    (setf (alist-get 'styles (alist-get 'lsp-capf completion-category-defaults))
          '(orderless))) ;; Configure orderless
  :general
  (:states 'normal
           :keymaps 'lsp-mode-map
           "<f9>" 'lsp-ui-imenu
           "gd" 'lsp-find-definition
           "gp" 'lsp-ui-peek-find-references
           "K" 'lsp-ui-doc-mode))

lsp-ui

(use-package lsp-ui
  :hook (lsp-mode . lsp-ui-mode)
  :custom
  ;; (lsp-ui-doc-header t)
  (lsp-ui-doc-include-signature t)
  (lsp-ui-doc-position 'bottom) ;; top, bottom, or at-point
  ;; (lsp-ui-doc-max-width 120)
  ;; (lsp-ui-doc-max-height 30)
  ;; (lsp-ui-doc-use-childframe t)
  ;; (lsp-ui-doc-use-webkit t)
  ;; (lsp-ui-doc-enable t)
  (lsp-ui-sideline-enable nil)
  (lsp-ui-sideline-show-code-actions nil)
  (lsp-ui-sideline-show-symbol t)
  (lsp-ui-sideline-show-hover t)
  (lsp-ui-sideline-show-diagnostics nil)
  ;; lsp-ui-imenu
  (lsp-ui-imenu-enable t)
  (lsp-ui-imenu-kind-position 'top))

lsp-dart

(use-package lsp-dart
  :straight (lsp-dart :type git :host github :repo "emacs-lsp/lsp-dart")
  :custom
  (lsp-dart-sdk-dir "~/bin/flutter/bin/cache/dart-sdk")
  :hook (dart-mode . lsp-deferred))

lsp-pyright

(use-package lsp-pyright
  :after lsp
  :straight (lsp-pyright :type git :host github :repo "emacs-lsp/lsp-pyright")
  :hook (python-mode . (lambda ()
                         (require 'lsp-pyright)
                         (lsp))))  ; or lsp-deferred

treemacs

(use-package treemacs
  :defer 3)

lsp-treemacs

(use-package lsp-treemacs
  :after (lsp-mode treemacs)
  :config
  (lsp-treemacs-sync-mode 1))

consult-lsp

(use-package consult-lsp
  :straight (consult-lsp :type git :host github :repo "gagbo/consult-lsp")
  :after (consult lsp-mode selectrum))

dap-mode

(use-package dap-mode
  :config
  (setq dap-auto-configure-features '(sessions locals controls tooltip))
  (require 'dap-cpptools)
  (require 'dap-gdb-lldb)
  (require 'dap-lldb)
  (require 'dap-python)
  (require 'dap-chrome)
  (setq dap-print-io t)
  :bind
  (:map dap-mode-map
        (("<f12>" . dap-debug)
         ("<f8>" . dap-continue)
         ("<f9>" . dap-next)
         ("<M-f11>" . dap-step-in)
         ("C-M-<f11>" . dap-step-out)
         ("<f7>" . dap-breakpoint-toggle))))

flycheck

(use-package flycheck
  :hook
  ((go-mode . flycheck-mode)
   (python-mode . flycheck-mode)
   (dart-mode . flycheck-mode)
   (js-mode . flycheck-mode))
  :custom
  (lsp-prefer-flymake nil))

aggressive-indent

(use-package aggressive-indent
  :hook
  ((web-mode . aggressive-indent-mode)
   (json-mode . aggressive-indent-mode)
   (lisp-mode . aggressive-indent-mode)
   (scheme-mode . aggressive-indent-mode)
   (emacs-lisp-mode . aggressive-indent-mode)))

avy

Search for character

(use-package avy
  :general
  (:states '(normal emacs insert motion)
           "C-c c a f" 'avy-goto-char-timer
           ;; goto "("
           "C-c c a p" (lambda() (interactive) (avy-goto-char 40))))

smartparens

(use-package smartparens
  :hook
  ((js-mode . smartparens-mode)
   (c++-mode . smartparens-mode)
   (dart-mode . smartparens-mode)
   (go-mode . smartparens-mode)
   (sly-mrepl-mode . smartparens-mode)
   (geiser-repl-mode . smartparens-mode))
  :config
  (require 'smartparens-config)

  (with-eval-after-load 'smartparens
    (sp-with-modes
        '(c++-mode dart-mode go-mode js-mode)
      (sp-local-pair "{" nil :post-handlers '(:add ("||\n[i]" "RET")))))

  (with-eval-after-load 'smartparens
    (sp-with-modes
        '(c++-mode dart-mode go-mode js-mode)
      (sp-local-pair "(" nil :post-handlers '(:add ("||\n[i]" "RET")))))

  (sp-local-pair '(sly-mrepl-mode) "'" "'" :actions nil)
  ;; (add-hook 'js-mode-hook #'smartparens-mode)
  ;; (add-hook 'c++-mode-hook #'smartparens-mode)
  ;; (add-hook 'dart-mode-hook #'smartparens-mode)
  ;; (add-hook 'go-mode-hook #'smartparens-mode)
  ;; Activate smartparens in minibuffer
  (add-hook 'eval-expression-minibuffer-setup-hook #'smartparens-mode)

  ;; (smartparens-global-mode t)
  )

evil-smartparens

(use-package evil-smartparens
  :after smartparens
  :config
  (add-hook 'smartparens-enabled-hook #'evil-smartparens-mode))

whitespace

(use-package whitespace
  :straight (:type built-in)
  :hook
  (prog-mode . whitespace-mode)
  (text-mode . whitespace-mode)
  :custom
  (whitespace-style '(face empty indentation::space tab trailing)))

ctrlf

(use-package ctrlf
  :straight (ctrlf :host github :repo "raxod502/ctrlf")
  :bind ("C-s" . ctrlf-forward-literal)
  :config
  (ctrlf-mode +1))

expand-region

(use-package expand-region
  :general
  (:states '(normal motion)
           "SPC" 'er/expand-region))

lispy

(use-package lispy
  :defer 10
  :hook ((common-lisp-mode . lispy-mode)
         (emacs-lisp-mode . lispy-mode)
         (lisp-mode . lispy-mode)
         (scheme-mode . lispy-mode)
         (racket-mode . lispy-mode)
         (hy-mode . lispy-mode)
         (lfe-mode . lispy-mode)
         (clojure-mode . lispy-mode))
  :general
  (:states '(emacs insert)
           :keymaps 'lispy-mode-map
           "C-c p w" 'lispy-wrap-round
           "C-c p k" 'lispy-delete
           "C-c p m" 'lispy-multiline
           "C-c p o" 'lispy-oneline
           ))

lispyville

(use-package lispyville
  :after lispy
  :hook ((lispy-mode . lispyville-mode))
  ;; :init
  ;; (general-add-hook '(lisp-interaction-mode-hook emacs-lisp-mode-hook lisp-mode-hook) #'lispyville-mode)
  :config
  (lispyville-set-key-theme '(operators
                              additional-insert
                              c-w additional
                              text-objects
                              atom-motions
                              additional-motions
                              wrap
                              slurp/barf-lispy)))

hydra

(use-package hydra
  :defer 5)

org-fc

sudo apt install gawk

(use-package org-fc
  :defer 5
  :straight
  (org-fc
   :type git
   :host github
   :repo "l3kn/org-fc"
   :files (:defaults "awk" "demo.org"))
  :custom
  (org-fc-directories '("~/org/roams"))
  :config
  (require 'org-fc-keymap-hint)
  (require 'org-fc-hydra)
  (setq org-tag-alist '(("dart")
                        ("fundamentals")
                        ("algorithms")
                        ("C")
                        ("cpp")
                        ("emacs")
                        ("javascript")
                        ("lisp")
                        ("linux")
                        ("fp")
                        ("bash")
                        ("englishVoc")
                        ("orgmode")
                        ("chess")
                        ("math")))

  ;; (setq org-tag-alist '(dart
  ;;                       fundamentals
  ;;                       algorithms
  ;;                       cpp
  ;;                       javascript
  ;;                       linux
  ;;                       fp
  ;;                       bash
  ;;                       englishVoc
  ;;                       math
  ;;                       ))
  (add-to-list 'org-fc-custom-contexts
               '(dart-cards . (:filter (tag "dart"))))

  (add-to-list 'org-fc-custom-contexts
               '(fundamentals-cards . (:filter (tag "fundamentals"))))

  (add-to-list 'org-fc-custom-contexts
               '(algorithms-cards . (:filter (tag "algorithms"))))

  (add-to-list 'org-fc-custom-contexts
               '(cpp-cards . (:filter (tag "cpp"))))

  (add-to-list 'org-fc-custom-contexts
               '(cpp-cards . (:filter (tag "C"))))

  (add-to-list 'org-fc-custom-contexts
               '(emacs-cards . (:filter (tag "emacs"))))

  (add-to-list 'org-fc-custom-contexts
               '(javascript-cards . (:filter (tag "javascript"))))

  (add-to-list 'org-fc-custom-contexts
               '(linux-cards . (:filter (tag "linux"))))

  (add-to-list 'org-fc-custom-contexts
               '(lisp-cards . (:filter (tag "lisp"))))

  (add-to-list 'org-fc-custom-contexts
               '(fp-cards . (:filter (tag "fp"))))

  (add-to-list 'org-fc-custom-contexts
               '(bash-cards . (:filter (tag "bash"))))

  (add-to-list 'org-fc-custom-contexts
               '(chess-cards . (:filter (tag "chess"))))

  (add-to-list 'org-fc-custom-contexts
               '(orgmode-cards . (:filter (tag "orgmode"))))

  (add-to-list 'org-fc-custom-contexts
               '(englishVoc-cards . (:filter (tag "englishVoc"))))

  (add-to-list 'org-fc-custom-contexts
               '(math-cards . (:filter (tag "math"))))

  (general-define-key
   :states 'normal
   "C-c f" 'org-fc-hydra/body)

  (general-define-key
   :definer 'minor-mode
   :states 'normal
   :keymaps 'org-fc-review-flip-mode
   "RET" 'org-fc-review-flip
   "n" 'org-fc-review-flip
   "s" 'org-fc-review-suspend-card
   "p" 'org-fc-review-edit
   "q" 'org-fc-review-quit)

  (general-define-key
   :definer 'minor-mode
   :states 'normal
   :keymaps 'org-fc-review-rate-mode
   "a" 'org-fc-review-rate-again
   "h" 'org-fc-review-rate-hard
   "g" 'org-fc-review-rate-good
   "e" 'org-fc-review-rate-easy
   "p" 'org-fc-review-edit
   "s" 'org-fc-review-suspend-card
   "q" 'org-fc-review-quit)

  (general-define-key
   :definer 'minor-mode
   :states 'normal
   :keymaps 'org-fc-review-edit-mode
   "C-c C-c" 'org-fc-review-resume
   "C-c C-k" 'org-fc-review-quit))

org-protocol

Create the file ~/.local/share/applications/org-protocol.desktop containing:

[Desktop Entry]
Name=org-protocol
Exec=emacsclient %u
Type=Application
Terminal=false
Categories=System;
MimeType=x-scheme-handler/org-protocol;
(use-package org-protocol
  :straight (:type built-in)
  )

org-protocol-capture-html

(use-package org-protocol-capture-html
  :straight (org-protocol-capture-html
             :type git
             :host github
             :repo "alphapapa/org-protocol-capture-html"
             )
  :after org-protocol
  :config
  (setq org-capture-templates
        `(("w" "Web site" entry
           (file "")
           "* %a :website:\n\n%U %?\n\n%:initial"))))

org-roam

https://github.com/org-roam/org-roam#configuration

(use-package org-roam
  :straight (org-roam
             :type git
             :host github
             :repo "org-roam/org-roam")
  :init
  (setq org-roam-v2-ack t)
  (setq org-roam-directory "~/org/roams")
  :config
  ;; If you're using a vertical completion framework, you might want a more informative completion interface
  (setq org-roam-node-display-template (concat "${title:*} " (propertize "${tags:10}" 'face 'org-tag)))
  (org-roam-db-autosync-mode)
  :general
  (:prefix "C-c c"
           :states '(normal motion insert emacs)
           "r n" 'org-roam-node-find
           "r l" 'org-roam-buffer-toggle
           "r i" 'org-roam-node-insert
           "r d" 'org-id-get-create
           "r t" 'org-roam-tag-add
           "r a" 'org-roam-alias-add))

rg

(use-package rg
  :config
  (rg-define-search ram/search-everything-at-roams
    :query ask
    :format regexp
    :dir "/home/last/org/roams/"
    :files "*.org"
    :confirm prefix)

  (rg-define-search ram/grep-vc-or-dir
    :query ask
    :format regexp
    :files "everything"
    :dir (let ((vc (vc-root-dir)))
           (if vc
               vc                         ; search root project dir
             default-directory))          ; or from the current dir
    :confirm prefix
    :flags ("--hidden -g !.git"))


  :general
  (:states '(normal motion)
           :prefix "M-s"
           "g" 'ram/grep-vc-or-dir
           "r" 'ram/search-everything-at-roams))

yasnippet

(use-package yasnippet
  :bind
  (:map yas-minor-mode-map
        ("TAB" . nil)
        ([tab] . nil))
  :hook
  (prog-mode . yas-minor-mode)
  (text-mode . yas-minor-mode)
  :custom
  (yas-snippet-dirs
   '("~/Projects/dots/snips/yasnippet"))
  :config
  (yas-reload-all)
  :general
  (:states 'visual
           :prefix ","
           "y" 'yas-insert-snippet)
  (:states 'insert
           "C-c c y i" 'yas-expand)
  (:states 'insert
           :keymaps 'yas-minor-mode-map
           "M-l" 'yas-next-field
           "M-h" 'yas-prev-field))

web-mode

(use-package web-mode
  :mode "\\.html\\'"
  :custom
  (web-mode-enable-auto-expanding t)
  (web-mode-markup-indent-offset 2)
  (web-mode-css-indent-offset 2)
  (web-mode-code-indent-offset 2)
  (web-mode-enable-auto-pairing t)
  (web-mode-enable-css-colorization t)
  (web-mode-enable-current-element-highlight t)
  :config
  (set-face-background 'web-mode-current-element-highlight-face "#ff6c6b")
  (add-to-list 'auto-mode-alist '("\\.html?\\'" . web-mode))
  (add-to-list 'auto-mode-alist '("\\.css?\\'" . web-mode)))

org-cliplink

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

calibredb.el

(use-package calibredb
  :commands calibredb
  :init
  (autoload 'calibredb "calibredb")
  :config
  (setq calibredb-author-width 0)
  (setq calibredb-id-width 0)
  (setq calibredb-comment-width 0)
  (setq sql-sqlite-program "~/bin/sqlite/sqlite3")
  (setq calibredb-root-dir "~/Documents/books")
  (setq calibredb-db-dir (expand-file-name "metadata.db" calibredb-root-dir))
  (setq calibredb-program "/usr/bin/calibredb")
  (setq calibredb-library-alist '(("~/Documents/books")
                                  ("~/Documents/articles"))))

sudo-edit

(use-package sudo-edit
  :commands sudo-edit)

cmake-mode

;; (straight-use-package '(cmake-mode :local-repo "/home/last/.emacs.d/local-packages/cmake-mode.el" :type nil))
;;(straight-use-package '(cmake-mode :local-repo "/home/last/.emacs.d/local-packages/cmake-mode/cmake-mode.el"))
(use-package cmake-mode
  ;; :type nil disable all git operations. For example straight-pull-all will not throw an error.
  :straight (cmake-mode :local-repo "~/.emacs.d/lisp/cmake-mode" :type nil)
  :mode "\\CMakeLists.txt\\'")
;;(straight-use-package '(cmake-mode :local-repo "~/.emacs.d/local-packages/cmake-mode" :source nil))

skeletor

(use-package skeletor
  :commands (skeletor-create-project skeletor-create-project-at ram/create-kata ram/create-project)
  :custom
  (skeletor-user-directory "~/Projects/dots/project-skeletons")
  :init
  (skeletor-define-template "c-make-munit"
    :no-license? t
    :no-git? t
    :title "C Make Munit Kata")

  (skeletor-define-template "cpp-hello-world"
    :no-license? t
    :no-git? t
    :title "Cpp Hellow World")

  (skeletor-define-template "cpp-make-fmt-ut-as-headers"
    :no-license? t
    :no-git? t
    :title "Cpp Make Fmt Ut Kata")

  (skeletor-define-template "elisp"
    :no-git? t
    :no-license? t
    :title "Elisp Kata")

  (skeletor-define-template "lisp-fiveam"
    :no-git? t
    :no-license? t
    :title "Lisp Fiveam Kata")

  (skeletor-define-template "lisp"
    :no-git? t
    :no-license? t
    :title "Lisp Kata"
    :after-creation
    (lambda (dir)
      (skeletor-async-shell-command (format "ln -s %s ~/Projects/lisp/katas" dir))))

  (skeletor-define-template "js"
    :no-git? t
    :no-license? t
    :title "Javascript Kata"
    :after-creation
    (lambda (dir)
      (skeletor-async-shell-command "npm install")))

  (skeletor-define-template "typescript"
    :no-git? t
    :no-license? t
    :title "Typescript Kata")

  (skeletor-define-constructor "Dart Project"
    :no-license? t
    :no-git? t
    :initialise
    (lambda (spec)
      (let-alist spec
        (skeletor-shell-command
         (format "dart create -t %s %s" (ram/get-dart-template) (shell-quote-argument .project-name))
         .project-dir))))

  (skeletor-define-constructor "Dart Kata"
    :no-license? t
    :no-git? t
    :initialise
    (lambda (spec)
      (let-alist spec
        (skeletor-shell-command
         (format "dart create -t package-simple %s" (shell-quote-argument .project-name))
         .project-dir))))

  (skeletor-define-constructor "Dcli Script"
    :no-license? t
    :no-git? t
    :initialise
    (lambda (spec)
      (let-alist spec
        (skeletor-shell-command
         (format "dcli create %s" (shell-quote-argument .project-name))
         .project-dir))))

  (skeletor-define-constructor "Flutter Project"
    :no-license? t
    :no-git? t
    :initialise
    (lambda (spec)
      (let-alist spec
        (skeletor-shell-command
         (format "flutter create -t %s %s" (ram/get-flutter-template) (shell-quote-argument .project-name))
         .project-dir))))

  (skeletor-define-constructor "Python Project"
    :no-license? t
    :no-git? t
    :initialise
    (lambda (spec)
      (let-alist spec
        (skeletor-shell-command
         (format "poetry new %s" (shell-quote-argument .project-name))
         .project-dir)))
    :after-creation
    (lambda (dir)
      (skeletor-async-shell-command "poetry install")))

  (skeletor-define-constructor "Python Kata"
    :no-license? t
    :no-git? t
    :initialise
    (lambda (spec)
      (let-alist spec
        (skeletor-shell-command
         (format "poetry new %s" (shell-quote-argument .project-name))
         .project-dir)))))

helpful

(use-package helpful
  :general
  (:states '(normal visual emacs motion)
           :prefix "C-h"
           "v" 'helpful-variable
           "f" 'helpful-callable
           "k" 'helpful-key)
  (:states 'normal
           :keymaps 'helpful-mode-map
           "q" 'helpful-kill-buffers))

elfeed

(use-package elfeed
  :config
  (load-file "~/.emacs.d/feeds.el")
  (setq elfeed-feeds (ram/feeds))
  :general
  (:states 'normal
           :keymaps 'elfeed-search-mode-map
           "r" 'elfeed-update
           "l" 'elfeed-search-show-entry
           "s" 'elfeed-search-live-filter
           "c" 'elfeed-search-clear-filter
           "q" 'elfeed-search-quit-window)
  (:states 'normal
           :keymaps 'elfeed-show-mode-map
           "b" 'elfeed-search-browse-url
           "q" 'elfeed-kill-buffer))

proced

Build-in package. Think htop but for emacs.

(use-package proced
  :straight (:type built-in)
  :commands proced
  :config
  ;; makes it auto-update
  (setq proced-auto-update-interval 1)
  (add-hook 'proced-mode-hook
            (lambda ()
              (proced-toggle-auto-update 1))))

languagetool

(use-package languagetool
  :defer t
  :commands (languagetool-check
             languagetool-clear-buffer
             languagetool-correct-at-point
             languagetool-correct-buffer
             languagetool-set-language)
  :config
  (setq languagetool-language-tool-jar "~/bin/languagetool/languagetool-commandline.jar"
        languagetool-server-language-tool-jar "~/bin/languagetool/languagetool-server.jar"
        languagetool-java-arguments '("-Dfile.encoding=UTF-8")
        languagetool-default-language "en-GB"))

ace-window

(use-package ace-window
  :general
  (:states 'normal
           "M-o" 'ace-window))

org-download

(use-package org-download
  :commands org-download-clipboard
  :config
  (setq-default org-download-image-dir "~/org/roams/img"))

pocket-reader

(use-package pocket-reader)

emacs-test-simple

(use-package test-simple)

prodigy

(use-package prodigy
  :config
  (prodigy-define-service
    :name "Kmonad"
    :command "kmonad"
    :args '("/home/last/.config/kmonad/config.kbd")
    :stop-signal 'sigkill
    :tags '(hobby)
    :kill-process-buffer-on-stop t)
  :general
  (:states 'normal
           :keymaps 'prodigy-mode-map
           "j" 'prodigy-next
           "k" 'prodigy-prev
           "gg" 'prodigy-start
           "G" 'prodigy-last
           "s" 'prodigy-stop
           "r" 'prodigy-restart
           "u" 'prodigy-refresh
           "q" 'quit-window
           ))

clang-include-fixer

(straight-use-package '(clang-include-fixer :local-repo "~/.emacs.d/lisp/clang-include-fixer"))

buttercup (tdd)

(use-package buttercup)

rainbow-delimiters

(use-package rainbow-delimiters
  :config
  (add-hook 'emacs-lisp-mode-hook 'rainbow-delimiters-mode)
  (add-hook 'scheme-mode-hook 'rainbow-delimiters-mode)
  (add-hook 'lisp-interaction-mode-hook 'rainbow-delimiters-mode)
  (add-hook 'lisp-mode-hook 'rainbow-delimiters-mode)
  (add-hook 'geiser-repl-mode-hook 'rainbow-delimiters-mode)
  (add-hook 'sly-mrepl-mode-hook 'rainbow-delimiters-mode)

  (custom-set-faces
   '(rainbow-delimiters-depth-1-face ((t (:foreground "white"))))
   '(rainbow-delimiters-depth-2-face ((t (:foreground "cyan"))))
   '(rainbow-delimiters-depth-3-face ((t (:foreground "yellow"))))
   '(rainbow-delimiters-depth-4-face ((t (:foreground "green"))))
   '(rainbow-delimiters-depth-5-face ((t (:foreground "orange"))))
   '(rainbow-delimiters-depth-6-face ((t (:foreground "purple"))))
   '(rainbow-delimiters-depth-7-face ((t (:foreground "white"))))
   '(rainbow-delimiters-depth-8-face ((t (:foreground "cyan"))))
   '(rainbow-delimiters-depth-9-face ((t (:foreground "yellow"))))
   '(rainbow-delimiters-unmatched-face ((t (:foreground "red"))))))

vundo

(use-package vundo
  :commands (vundo)
  :straight (vundo :type git :host github :repo "casouri/vundo")
  :config
  (setq vundo-compact-display t)
  (custom-set-faces
   '(vundo-node ((t (:foreground "#808080"))))
   '(vundo-stem ((t (:foreground "#808080"))))
   '(vundo-highlight ((t (:foreground "#FFFF00"))))))

s.el

String manipulation library

(use-package s)

f.el

Modern API for working with files and directories

(use-package f)

dash.el

A modern list API

(use-package dash)

ht.el

The missing hash table library for Emacs

(use-package ht)

let-alist

(use-package let-alist)

Functions

make l to behave as expected in dired

(defun ram/dired-open()
  (interactive)
  (cond
   ;; use dired-find-file if it is a directory
   ((file-directory-p (dired-get-file-for-visit))
    (dired-find-file))
   ;; use dired-find-file if the mime type of the file is emacs.desktop
   ((string= "emacs.desktop" (string-trim-right (shell-command-to-string
                                                 (format "xdg-mime query filetype %s | xargs xdg-mime query default"
                                                         (shell-quote-argument (dired-get-file-for-visit))))))
    (dired-find-file))
   (t
    ;; use xdg-open for everything else
    ;; start-process quote the arguments so you do not need the sell-quote-argument function
    (start-process "ram-dired-open" nil "xdg-open" (dired-get-file-for-visit)))))

clean book name

(defun ram/remove-everything-until-period (str)
  "Removes everything in a string until the first period. Period included."
  (replace-regexp-in-string "^[^.]*."
                            ""
                            str))

(defun ram/remove-everything-after-last-period (str)
  "Removes everything in a string after the last period. Period included."
  (replace-regexp-in-string "\.[^.]*$"
                            ""
                            str))

(defun ram/replace-periods-for-whitespaces (str)
  ;; \x20 is the exadecimal value of whitespace
  (subst-char-in-string ?. ?\x20 str))

(defun ram/clean-book-name ()
  (interactive)
  (let ((str  (substring-no-properties (x-get-clipboard))))
    (kill-new
     (ram/replace-periods-for-whitespaces
      (ram/remove-everything-until-period
       (ram/remove-everything-after-last-period str))))))

(defun ram/clean-book-name2 ()
  (interactive)
  (let ((str  (substring-no-properties (x-get-clipboard))))
    (kill-new
     (ram/replace-periods-for-whitespaces
      (ram/remove-everything-after-last-period
       (ram/remove-everything-after-last-period str))))))

switch-recent-tab

(defun ram/switch-recent-tab ()
  (interactive)
  (when (tab-bar-switch-to-recent-tab)
    (tab-new)))

vterm functions

Find file

(with-eval-after-load 'vterm
  (push (list "find-file-below"
              (lambda (path)
                (if-let* ((buf (find-file-noselect path))
                          (window (display-buffer-below-selected buf nil)))
                    (select-window window)
                  (message "Failed to open file: %s" path))))
        vterm-eval-cmds))

Stay in the same positin when going back to normal mode

(with-eval-after-load 'vterm
  (defun evil-collection-vterm-escape-stay ()
    "Go back to normal state but don't move
cursor backwards. Moving cursor backwards is the default vim behavior but it is
not appropriate in some cases like terminals."
    (setq-local evil-move-cursor-back nil))

  (add-hook 'vterm-mode-hook #'evil-collection-vterm-escape-stay))

Vterm completion for files, directories, history and programs

(with-eval-after-load 'vterm
  (defun ram/get-full-list ()
    (let ((program-list (split-string (shell-command-to-string "compgen -c") "\n" t ))
          (file-directory-list (split-string (shell-command-to-string "compgen -f") "\n" t ))
          (history-list (with-temp-buffer
                          (insert-file-contents "~/.bash_history")
                          (split-string (buffer-string) "\n" t))))

      (delete-dups (append program-list file-directory-list history-list))))

  (defun ram/vterm-completion-choose-item ()
    (completing-read "Choose: " (ram/get-full-list) nil nil (thing-at-point 'word 'no-properties)))

  (defun ram/vterm-completion ()
    (interactive)
    (vterm-directory-sync)
    (let ((ram/vterm-chosen-item (ram/vterm-completion-choose-item)))
      (when (thing-at-point 'word)
        (vterm-send-meta-backspace))
      (vterm-send-string ram/vterm-chosen-item))))

Vterm completion for files and directories

(defun ram/get-file-dir-list ()
  (let ((file-dir-list (split-string (shell-command-to-string "compgen -f") "\n" t )))
    file-dir-list))

(defun ram/vterm-completion-file-dir ()
  (interactive)
  (vterm-directory-sync)
  (let* ((word (s-chop-prefix "./" (thing-at-point 'filename 'no-properties)))
         (chosen (completing-read "Choose: " (ram/get-file-dir-list) nil nil word)))
    (vterm-send-meta-backspace)
    (vterm-send-string chosen)))

Consult-yank for vterm

(with-eval-after-load 'vterm
  (advice-add #'insert-for-yank
              :around
              (defun ram/insert-for-yank-vterm-shim (orig-fun &rest args)
                (if (eq major-mode 'vterm-mode)
                    (let ((inhibit-read-only t))
                      (apply #'vterm-insert args))
                  (apply orig-fun args))))

  (defun ram/vterm-consult-yank-pop (&optional arg)
    "A `consult-yank-pop' wrapper for vterm compatibility."
    (interactive "p")
    (let ((inhibit-read-only t))
      (consult-yank-pop arg))))

less like function for vterm

(with-eval-after-load 'vterm
  (defun ram/menos ()
    (switch-to-buffer "menos")
    (when (get-buffer "menos")
      (with-current-buffer "menos")
      (erase-buffer)
      (insert (substring-no-properties (x-get-clipboard)))))
  ;; (current-kill 0)

  (push (list "menos" 'ram/menos)
        vterm-eval-cmds))

Open man pages in a emacs buffer

(with-eval-after-load 'vterm
  (push (list "man" 'man)
        vterm-eval-cmds))

Update the CWD

I use this function in ram/vterm-complreion

(defun vterm-directory-sync ()
  "Synchronize current working directory."
  (interactive)
  (when vterm--process
    (let* ((pid (process-id vterm--process))
           (dir (file-truename (format "/proc/%d/cwd/" pid))))
      (setq default-directory dir))))

(with-eval-after-load 'vterm
  (add-to-list 'vterm-eval-cmds '("update-pwd" (lambda (path) (setq default-directory path)))))

Get dart template (skeletor)

(defun ram/get-dart-template ()
  (->> (shell-command-to-string "dart create")
       (s-slice-at "^Available templates")
       cadr
       (s-split "\n")
       cdr
       (remove "")
       (mapcar 's-trim)
       (completing-read "Choose: ")
       (s-split ":")
       car))

Get flutter template (skeletor)

(defun ram/get-flutter-template ()
  (completing-read "Choose: " '("app" "module" "package" "plugin")))

Create a project (skeletor)

(defun ram/get-skeleton (skeleton)
  (--first (equal skeleton (SkeletorProjectType-title it))
           skeletor--project-types))

(defun ram/cpp-create-project ()
  (let ((project (completing-read "Choose: " '("Cpp Hellow World"
                                               "C++ Make Project"
                                               "C++ Cmake Project"
                                               "C++ Build2 Project"))))

    (skeletor-create-project-at "~/Projects/cpp" (ram/get-skeleton project))))

(defun ram/dcli-create-script ()
  (skeletor-create-project-at "~/bin/scripts" (ram/get-skeleton "Dcli Script")))

(defun ram/dart-create-project ()
  (skeletor-create-project-at "~/Projects/dart" (ram/get-skeleton "Dart Project")))

(defun ram/flutter-create-project ()
  (skeletor-create-project-at "~/Projects/flutter" (ram/get-skeleton "Flutter Project")))

(defun ram/python-create-project ()
  (skeletor-create-project-at "~/Projects/python" (ram/get-skeleton "Python Project")))

(defun ram/create-project ()
  (interactive)
  (let ((project (completing-read "Choose: " '("C++ Project"
                                               "Dart Project"
                                               "Dcli Project"
                                               "Flutter Project"
                                               "Python Project"))))
    (pcase (list project)
      ('("C++ Project") (ram/cpp-create-project))
      ('("Dart Project") (ram/dart-create-project))
      ('("Dcli Project") (ram/dcli-create-script))
      ('("Flutter Project") (ram/flutter-create-project))
      ('("Python Project") (ram/python-create-project)))))

Create a kata (skeletor)

(defun ram/create-kata ()
  (interactive)
  (let ((kata (completing-read "Choose: " '("C Make Munit Kata"
                                            "Cpp Make Fmt Ut Kata"
                                            "Dart Kata"
                                            "Elisp Kata"
                                            "Javascript Kata"
                                            "Lisp Kata"
                                            "Lisp Fiveam Kata"
                                            "Python Kata"
                                            "Typescript Kata"))))
    (skeletor-create-project-at default-directory
                                (ram/get-skeleton kata))))

Autocomplete global org-mode tags

(defun ram/ident-org-tags()
  (interactive)
  (let ((current-prefix-arg '(4))) ;; emulate C-u
    (call-interactively 'org-set-tags-command))) ;; invoke org-set-tags-command interactively

(defun ram/org-swap-tags (tags)
  "Replace any tags on the current headline with TAGS.

The assumption is that TAGS will be a string conforming to Org Mode's
tag format specifications, or nil to remove all tags."
  (let ((old-tags (org-get-tags-string))
        (tags (if tags
                  (concat " " tags)
                "")))
    (save-excursion
      (beginning-of-line)
      (re-search-forward
       (concat "[ \t]*" (regexp-quote old-tags) "[ \t]*$")
       (line-end-position) t)
      (replace-match tags)
      (org-set-tags t)
      )))

(defun ram/org-set-tags (tag)
  "Add TAG if it is not in the list of tags, remove it otherwise.

TAG is chosen interactively from the global tags completion table."
  (interactive
   (list (let ((org-last-tags-completion-table
                (if (derived-mode-p 'org-mode)
                    (org-uniquify
                     (delq nil (append (org-get-buffer-tags)
                                       (org-global-tags-completion-table))))
                  (org-global-tags-completion-table))))
           (org-icompleting-read
            "Tag: " 'org-tags-completion-function nil nil nil
            'org-tags-history))))
  (let* ((cur-list (org-get-tags))
         (new-tags (mapconcat 'identity
                              (if (member tag cur-list)
                                  (delete tag cur-list)
                                (append cur-list (list tag)))
                              ":"))
         (new (if (> (length new-tags) 1) (concat " :" new-tags ":")
                nil)))
    (ram/org-swap-tags new)
    ))

Rename files in numeric sequence

(defun ram/rename-files-numeric-sequence ()
  (interactive)
  (let ((sequence 1)
        (files (directory-files-recursively default-directory "")))
    (while files
      (rename-file (car files)
                   (format "%s%04d.%s"
                           (file-name-directory (car files))
                           sequence
                           (file-name-extension (car files))))
      (setq files (cdr files))
      (setq sequence (1+ sequence)))))

select last pasted text (like gv)

(defun ram/evil-select-pasted ()
  (interactive)
  (let ((start-marker (evil-get-marker ?\[))
        (end-marker (evil-get-marker ?\])))
    (evil-visual-select start-marker end-marker)))

Insert list of files in buffer

Insert list of files recursively and also replace the path of the directories with “*” org-mode headers

(defun ram/ls-insert ()
  (interactive)
  (save-excursion
    (insert (shell-command-to-string
             (format "ls -1R %s"
                     ;; shell-quote-argument escapes white spaces on the file name
                     (shell-quote-argument
                      ;; remove all properties from a text string with substring-no-properties
                      (substring-no-properties
                       (car kill-ring))))))
    (replace-string
     (format "%s/"(substring-no-properties (car kill-ring)))
     "* "
     nil
     (point-min)
     (point-max))))

Change the default file application to emacs (mime)

(defun ram/change-mime-emacs ()
  (interactive)
  (message "The old default app was %s\n" (shell-command-to-string
                                           (format "xdg-mime query filetype %s | xargs xdg-mime query default"
                                                   (shell-quote-argument (dired-get-file-for-visit)))))

  (shell-command (format "xdg-mime query filetype %s | xargs xdg-mime default emacs.desktop"
                         (shell-quote-argument (dired-get-file-for-visit))))

  (message "The new default app is %s" (shell-command-to-string
                                        (format "xdg-mime query filetype %s | xargs xdg-mime query default"
                                                (shell-quote-argument (dired-get-file-for-visit))))))

Delete current file

(defun ram/delete-current-file-and-buffer ()
  "Kill the current buffer and deletes the file it is visiting."
  (interactive)
  (let ((filename (buffer-file-name)))
    (if filename
        (if (y-or-n-p (concat "Do you really want to delete file " filename " ?"))
            (progn
              (delete-file filename)
              (message "Deleted file %s." filename)
              (kill-buffer)))
      (message "Not a file visiting buffer!"))))

Backward-kill-line

(defun ram/backward-kill-line (arg)
  "Kill ARG lines backward."
  (interactive "p")
  (kill-line (- 1 arg))
  (company-indent-or-complete-common t))

insert ; at the end of line

(defun ram/insertSemicolon ()
  "Insert semicolon end of line"
  (interactive)
  (save-excursion
    (end-of-line)
    (insert ";")))

realign existing contents of buffer on column-width

(defun ram/fill-buffer ()
  (interactive)
  (save-excursion
    (save-restriction
      (widen)
      (fill-region (point-min) (point-max)))))

Cycle in the kill-ring reverse direction

(defun ram/yank-pop-forwards (arg)
  (interactive "p")
  (yank-pop (- arg)))

Projectile functions

;; (defun ram/projectile-run-project ()
;;   (completing-read "Choose: "
;;                    '("pub get"
;;                      "webdev serve")))

(defun ram/dart (arg)
  (interactive (list (completing-read "Choose: "
                                      '("pub get"
                                        "webdev serve"
                                        "pub run test"))))
  (cond ((string= arg "pub get")
         (ram/dart-pub-get))
        ((string= arg "webdev serve")
         (ram/dart-webdev-serve))
        ((string= arg "pub run test")
         (ram/dart-test))
        ;; default
        (t (message "Wrong option"))))

(defun ram/dart-test ()
  (projectile-run-vterm)
  (vterm-clear)
  (vterm-send-string "pub run test")
  (vterm-send-return))

(defun ram/dart-pub-get ()
  (projectile-run-vterm)
  (vterm-clear)
  (vterm-send-string "pub get")
  (vterm-send-return))

(defun ram/dart-webdev-serve ()
  (projectile-run-vterm)
  (vterm-clear)
  (vterm-send-string "webdev serve")
  (vterm-send-return))

Switch to the previous buffer

For some reason mode-line-other-buffer behaves odd in exwm.

(defun ram/switch-to-previous-buffer ()
  "Switch to previously open buffer.
Repeated invocations toggle between the two most recently open buffers."
  (interactive)
  (switch-to-buffer (other-buffer (current-buffer) 1)))

Launch apps

(defun ram/launch-app (arg)
  (interactive (list (completing-read "Apps: "
                                      '("Google-chrome" "Firefox" "Shutdown" "JD" "Rofi"))))
  (cond ((string= arg "Google-chrome")
         ;; shell-quote-argument escapes white spaces on the file name
         (async-start-process "Google-chrome" "google-chrome" nil))
        ((string= arg "Firefox")
         (async-start-process "Firefox" "firefox" nil "-private"))
        ((string= arg "Shutdown")
         (async-start-process "Shutdown" "shutdown" nil "-P" "now"))
        ((string= arg "JD")
         (async-start-process "JD" "~/bin/jd2/JDownloader2" nil))
        ((string= arg "Rofi")
         (async-start-process "rofi" "rofi" nil "-show" "drun"))
        ;; default
        (t (message "Wrong option"))))

Mount drive

(defun ram/mount-drive ()
  (interactive)
  (async-start-process "udisksctl" "udisksctl" nil "mount" "-b" "/dev/sdb1"))

Hiding dired buffers in ivy

(defun ram/ignore-dired-buffers (str)
  "Return non-nil if STR names a Dired buffer.
This function is intended for use with `ivy-ignore-buffers'."
  (let ((buf (get-buffer str)))
    (and buf (eq (buffer-local-value 'major-mode buf) 'dired-mode))))

(with-eval-after-load 'ivy
  (add-to-list 'ivy-ignore-buffers #'ram/ignore-dired-buffers))

Open dots.org

(defun ram/open-dots()
  (interactive)
  (find-file "~/Projects/dots/dots.org"))

Open books

(defun ram/open-books (arg)
  (interactive (list (completing-read "Books: "
                                      (directory-files "~/org/books" nil directory-files-no-dot-files-regexp))))
  (find-file (concat "~/org/books/" arg)))

selectrum-registers

(require 'kmacro)
(require 'frameset)
(require 'register)

(defun selectrum-registers ()
  "Use a register, such as jumping to a buffer location or inserting text.

Each kind of register is prefixed with it's type, so that types are also
searchable.  Displayed type names are:

- \"File\": file names
- \"Frame configuration\": configurations of framesets
- \"Keyboard macro\": keyboard macros
- \"Position\": buffer makers and files queries (positions in closed files)
- \"Number\": numbers
- \"Rectangle\": rectangles of text

Basic text, rectangle of text, and numbers are inserted into the
current buffer at point.  Positions are moved to.  Frame and
window configurations are applied."

  (interactive)
  (let* ((selectrum-should-sort-p nil)
         (formatted-registers
          ;; Want to combine formatting and action function, so that we only have to check
          ;; the type of the register contents once.
          (mapcar (lambda (reg)
                    (append (let ((val (cdr reg)))
                              ;; Many of these description strings are copied from their
                              ;; respective Emacs library.
                              (pcase val
                                ;; File Names
                                (`(file . ,file-name)
                                 (list (concat "File: " file-name)
                                       #'jump-to-register))

                                ;; File Queries
                                ;; Registered markers of file buffers are turned into
                                ;; file queries after their respective buffer is closed.
                                (`(file-query ,file-name ,position)
                                 (list (concat "Position: " file-name
                                               " at " (number-to-string position))
                                       #'jump-to-register))

                                ;; Frame Configurations or Frame Set
                                ((pred frameset-register-p)
                                 (list (let* ((fs (frameset-register-frameset val))
                                              (ns (length (frameset-states fs))))
                                         (format "Frame configuration: %d frame%s, saved on %s."
                                                 ns
                                                 (if (= 1 ns) "" "s")
                                                 (format-time-string "%c" (frameset-timestamp fs))))
                                       #'jump-to-register))

                                ;; Keyboard Macros
                                ((pred kmacro-register-p)
                                 (list (concat "Keyboard macro: "
                                               (condition-case nil
                                                   (format-kbd-macro (kmacro-register-macro val) 1)
                                                 ;; Recover from error from `edmacro-fix-menu-commands'.
                                                 ;; In Emacs 27, it looks like mouse events are silently skipped over.
                                                 (error "Warning: Cannot display macros containing mouse clicks")))
                                       #'jump-to-register))

                                ;; Markers
                                ((pred markerp)
                                 (list (concat "Position: "
                                               (if-let ((buf (marker-buffer val)))
                                                   (concat (buffer-name buf)
                                                           " at "
                                                           (number-to-string (marker-position val)))
                                                 "Buffer no longer exists."))
                                       #'jump-to-register))

                                ;; Numbers
                                ((pred numberp)
                                 (list (concat "Number: " (number-to-string val))
                                       #'insert-register))

                                ;; Rectangles
                                ((and `(,elem1 . ,_)
                                      (guard (stringp elem1)))
                                 ;; NOTE: You'll need to adjust the indentation given your
                                 ;;       Selectrum settings.
                                 (list (concat "Rectangle: "
                                               (string-join
                                                val
                                                "\n                "))
                                       #'insert-register))

                                ;; Strings
                                ((pred stringp)
                                 (list (concat "Text: " val)
                                       ;; Could also do the following to flatten text.
                                       ;; (concat "Text: "
                                       ;;   (replace-regexp-in-string
                                       ;;    "\n"
                                       ;;    (propertize "^J" 'face 'escape-glyph)
                                       ;;    ;; (substring-no-properties val)
                                       ;;    val))
                                       #'insert-register))

                                ;; Window Configurations
                                ((and `(,window-config ,_)
                                      (guard (window-configuration-p window-config)))
                                 (list
                                  (let* ((stored-window-config window-config)
                                         (window-config-frame (window-configuration-frame stored-window-config))
                                         (current-frame (selected-frame)))
                                    ;; These mostly copied from register.el.
                                    (format "Window configuration: %s."
                                            (if (frame-live-p window-config-frame)
                                                (with-selected-frame window-config-frame
                                                  (save-window-excursion
                                                    (set-window-configuration stored-window-config)
                                                    (concat
                                                     (mapconcat (lambda (w) (buffer-name (window-buffer w)))
                                                                (window-list (selected-frame)) ", ")
                                                     (unless (eq current-frame window-config-frame)
                                                       " in another frame"))))
                                              "dead frame")))
                                  #'jump-to-register))

                                ;; For anything else, just mark it as garbage.
                                (_ '(garbage))))
                            ;; The register key.
                            (list (car reg))))
                  ;; Destructively sort a copy of the alist by ordering the keys.
                  (seq-sort-by #'car #'< (copy-sequence register-alist))))
         ;; Remove anything marked as garbage.
         (filtered-choices (seq-remove (lambda (choice) (eq (car choice) 'garbage))
                                       formatted-registers))

         ;; Create candidates as a list of strings.
         (actual-candidates (mapcar (lambda (choice)
                                      (propertize (car choice)
                                                  'selectrum-candidate-display-prefix
                                                  (concat (single-key-description (caddr choice))
                                                          ": ")))
                                    filtered-choices))

         ;; Use the selected string to match the desired register.
         (chosen-register (assoc (completing-read "Select register: " actual-candidates nil t)
                                 filtered-choices)))

    ;; Apply the correct action function to the register key.
    (funcall (cadr chosen-register) (caddr chosen-register))))

selectrum jump to outline headings

(defvar selectrum-outline-history nil "History of chosen headings for `selectrum-outline'.")
(defun selectrum-outline ()
  "Jump to a heading.  Regexps are pre-defined.  Obeys narrowing."
  (interactive)
  (let ((selectrum-should-sort-p nil)) ; Headings should stay in order of appearance.
    ;; Just use Org's built-in features when applicable.
    (if (eq major-mode 'org-mode)
        (let ((org-outline-path-complete-in-steps)
              (org-goto-interface 'outline-path-completion))
          (org-goto))

      ;; Otherwise, have to find and format headings manually.
      (let* ((heading-regexp
              (cl-case major-mode
                ;; Groups: (1) level determinant, (2) heading text.
                ;; The top level is 0, for a zero-length determinant.
                (emacs-lisp-mode "^;;;\\(?1:;*\\)[[:blank:]]*\\(?2:[[:alnum:]][^z-a]*\\)\\'")
                (python-mode "^##\\(?1:\\**\\|#*\\)[[:blank:]]*\\(?2:[[:alnum:]][^z-a]*\\)\\'")
                (t (user-error "No headings defined for mode: %s" major-mode))))

             ;; Get the basic information of each heading in the accessible portion of the buffer.
             (buffer-contents (split-string (buffer-string) "\n"))
             (headings
              (cl-loop for txt in buffer-contents
                       for num from 1 to (1- (length buffer-contents))
                       ;; Only get the heading lines.
                       when (string-match heading-regexp txt)
                       ;; Heading text, Outline level, Line number
                       collect (list (match-string-no-properties 2 txt)
                                     (length (match-string-no-properties 1 txt))
                                     num)))

             ;; Create the prefix headings ("H1", "H1/h2", etc.)
             (formatted-headings
              (cl-loop
               ;; Variables for keeping track of heading "path".
               with prefix-list = '()   ; List of parent headings.
               with prev-heading-level = 0
               with prev-heading-text = nil
               ;; Heading titles can be repeated, so we include line numbers for context.
               with number-format = (format "L%%0%dd: " (length (number-to-string (length buffer-contents))))
               for (heading-text heading-level line-num) in headings
               collect (progn
                         ;; Check if we've moved to a different level.
                         (when (/= heading-level prev-heading-level)
                           ;; Update the prefix-list appropriately.
                           (setq prefix-list (if (> heading-level prev-heading-level)
                                                 (append prefix-list (list prev-heading-text))
                                               (cl-subseq prefix-list 0 heading-level)))
                           ;; Update prev-heading-level to current.
                           (setq prev-heading-level heading-level))

                         ;; Always update the previous heading.
                         (setq prev-heading-text heading-text)

                         (concat (format number-format line-num)
                                 (concat (string-join prefix-list "/")
                                         (and prefix-list "/") heading-text)))))

             ;; Get the desired heading.
             (chosen-heading (completing-read "Jump to heading: " formatted-headings
                                              nil t nil
                                              'selectrum-outline-history))
             ;; Stop at the ":". It is followed by one " ".
             (line-number-prefix (seq-take-while (lambda (char)
                                                   (not (char-equal ?: char)))
                                                 chosen-heading))
             ;; Get the line number for that heading, skipping the "L" in
             ;; line-number-prefix.
             (chosen-line-number (string-to-number (substring line-number-prefix 1)))
             ;; Get the current line number to determine the travel distance.
             (current-line-number (line-number-at-pos (point))))

        ;; Now do the actual movement, but first push mark.
        (push-mark (point) t)
        ;; Manually edit history to remove line numbers.
        (setcar selectrum-outline-history (substring chosen-heading
                                                     ;; Want after line-prefix followed by ": ".
                                                     (+ (length line-number-prefix) 2)))
        ;; Using `goto-line' isn't recommended for non-interactive use.
        (forward-line (- chosen-line-number current-line-number))
        (beginning-of-line-text 1)))))

In an org mode buffer, when you search for text that is in a fold Selectrum

swiper doesn’t take care of opening the folds so you can see the text you’re at. You can call the following function at the end of selectrum swiper.

(defun org:show-subtree-headlines ()
  "Show headlines surrounding point."
  (save-excursion
    (let ((points nil) (count 0))
      (unless (org-at-heading-p) (org-back-to-heading t))
      (push (point) points)
      (while (org-up-heading-safe)
        (push (point) points))
      (dolist (point points)
        (goto-char point)
        (when (org:heading-folded-p)
          (outline-toggle-children))))))

(defun selectrum:reveal-if-in-org-folds (orig-fn &rest args)
  (prog1 (apply orig-fn args)
    (when (eq major-mode 'org-mode)
      (org:show-subtree-headlines))))

(advice-add #'selectrum-swiper :around #'selectrum:reveal-if-in-org-folds)

selectrum swiper-like Jumping to Matching Lines

(defvar selectrum-swiper-history nil "Submission history for `selectrum-swiper'.")
(defun selectrum-swiper ()
  "Search for a matching line and jump to the beginning of its text.  Obeys narrowing."
  (interactive)
  (let* ((selectrum-should-sort-p nil)
         (line-choices (cl-loop
                        with minimum-line-number = (line-number-at-pos (point-min) t)
                        with buffer-text-lines = (split-string (buffer-string) "\n")
                        with number-format = (format "L%%0%dd: " (length (number-to-string (length buffer-text-lines))))
                        for txt in buffer-text-lines
                        for num from minimum-line-number to (+ minimum-line-number
                                                               (1- (length buffer-text-lines)))
                        unless (string-empty-p txt) ; Just skip empty lines.
                        collect (concat (format number-format num) txt)))
         ;; Get the matching line.
         (chosen-line (completing-read "Jump to matching line: " line-choices
                                       nil t nil 'selectrum-swiper-history))
         ;; Stop at the ":". It is followed by one " ".
         (line-number-prefix (seq-take-while (lambda (char)
                                               (not (char-equal ?: char)))
                                             chosen-line))
         ;; Get the corresponding line number, skipping the "L" in line-number-prefix.
         (chosen-line-number (string-to-number (substring line-number-prefix 1)))
         ;; Get the current line number for determining the travel distance.
         (current-line-number (line-number-at-pos (point) t)))

    (push-mark (point) t)
    ;; Manually edit history to remove line numbers.
    (setcar selectrum-swiper-history (substring chosen-line
                                                ;; Want after line-prefix followed by ": ".
                                                (+ (length line-number-prefix) 2)))
    (forward-line (- chosen-line-number current-line-number))
    (beginning-of-line-text 1)))

Launching apps

(defun ram/launch-app (arg)
  (interactive (list (completing-read "Apps: "
                                      '("google-chrome"
                                        "firefox"
                                        "shutdown"
                                        "jd"
                                        "calibre"
                                        "gimp"
                                        ))))
  (cond ((string= arg "google-chrome")
         ;; shell-quote-argument escapes white spaces on the file name
         (async-start-process "Google-chrome" "google-chrome" nil))
        ((string= arg "firefox")
         (async-start-process "Firefox" "firefox" nil "-private"))
        ((string= arg "shutdown")
         (async-start-process "Shutdown" "shutdown" nil "-P" "now"))
        ((string= arg "jd")
         (async-start-process "JD" "~/bin/jd2/JDownloader2" nil))
        ((string= arg "calibre")
         (async-start-process "Calibre" "calibre" nil))
        ((string= arg "gimp")
         (async-start-process "Gimp" "gimp" nil))
        ;; default
        (t (message "Wrong option"))))

elfeed and mpv

(defun ram/mpv (url &optional ignored)
  (interactive (browse-url-interactive-arg "URL: "))
  (vterm)
  (vterm-send-string (format "mpv %s" url))
  (vterm-send-return))

Make gc pauses faster by decreasing the threshold

Dial the GC threshold back down so that garbage collection happens more frequently but in less time.

(setq  gc-cons-threshold (* 2 1024 1024))
(setq  gc-cons-percentage .1)

Early emacs

;;; early-init.el --- Early Emacs configuration -*- lexical-binding: t; -*-

(setq-default
 load-prefer-newer t
 package-enable-at-startup nil
 package-native-compile t)

(setq-default
 default-frame-alist
 '((background-color . "#3F3F3F")       ;; Default background color
   (foreground-color . "#DCDCCC")       ;; Default foreground color
   (fullscreen . maximized)             ;; Maximize the window by default
   (horizontal-scroll-bars . nil)       ;; No horizontal scroll-bars
   (left-fringe . 8)                    ;; Thin left fringe
   (menu-bar-lines . 0)                 ;; No menu bar
   (right-divider-width . 1)            ;; Thin vertical window divider
   (right-fringe . 8)                   ;; Thin right fringe
   (tool-bar-lines . 0)                 ;; No tool bar
   (vertical-scroll-bars . nil)))       ;; No vertical scroll-bars

;;; early-init.el ends here

Emacs daemon

It is not needed to add systemctl start --user emacs.service to ~.profile. If systemctl enable --user emacs.service is run. https://www.youtube.com/watch?v=fg_jTo9SK9I

[Unit]
Description=Emacs text editor
Documentation=info:emacs man:emacs(1) https://gnu.org/software/emacs/

[Service]
Type=forking
ExecStart=/home/last/bin/emacs/bin/emacs --daemon
ExecStop=/home/last/bin/emacs/bin/emacsclient --eval "(kill-emacs)"
Restart=no

[Install]
WantedBy=default.target

Alacritty

Theme

# Colors (Doom One)
colors:
  # Default colors
  primary:
    background: '0x282c34'
    foreground: '0xbbc2cf'

  # Normal colors
  normal:
    black:   '0x282c34'
    red:     '0xff6c6b'
    green:   '0x98be65'
    yellow:  '0xecbe7b'
    blue:    '0x51afef'
    magenta: '0xc678dd'
    cyan:    '0x46d9ff'
    white:   '0xbbc2cf'

.profile

Variables

# locations where the .desktop files are searched
export XDG_DATA_DIRS="/var/lib/flatpak/exports/share/applications:$XDG_DATA_DIRS"
export _JAVA_AWT_WM_NONREPARENTING=1            # makes java application work correctly
export LSP_USE_PLISTS=true
export ANDROID_HOME="$HOME/bin/android"
export PYENV_ROOT="$HOME/bin/pyenv"
export GOPATH="$HOME/bin/go"
export POETRY_HOME="$HOME/bin/poetry"
export ALTERNATE_EDITOR=""
export EDITOR="emacsclient -c"                  # $EDITOR opens in GUI mode
export VISUAL="emacsclient -c -a emacs"         # $VISUAL opens in GUI mode
export MANPAGER=cat
export CXX="clang++"
export CC="gcc"
export PATH="$HOME/bin/cpp-libraries/bin:$HOME/bin/graphviz/bin:$PATH"
# for the linker
export LIBRARY_PATH="$HOME/bin/cpp-libraries/lib:$HOME/bin/c-libraries/lib:$LIBRARY_PATH"
# looks for include path both C and C++
export C_INCLUDE_PATH="$HOME/bin/c-libraries/include:$CPLUS_INCLUDE_PATH"
# looks for include path only C++
export CPLUS_INCLUDE_PATH="$HOME/bin/cpp-libraries/include:$CPLUS_INCLUDE_PATH"
export LD_LIBRARY_PATH="$HOME/bin/c-libraries/lib:$HOME/bin/gcc-trunk/lib64:$HOME/bin/gcc-trunk/lib:$HOME/bin/clang/lib:$HOME/bin/cpp-libraries/lib:$HOME/bin/graphviz/lib:$LD_LIBRARY_PATH"
export HISTSIZE=10000
export HISTFILESIZE=10000
# export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:"$HOME/bin/pyenv/versions/3.5.0/lib"

Paths

Default

# if running bash
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
        . "$HOME/.bashrc"
    fi
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
    PATH="$HOME/.local/bin:$PATH"
fi

Awk

export PATH="$HOME/bin/awk/bin:$PATH"
export PATH="$HOME/.local/bin:$PATH"

Build2

export "PATH=$HOME/bin/build2/bin:$PATH"

Clang

export PATH="$HOME/bin/clang/bin:$PATH"
# For some reason this only works in .bashrc
# export LD_LIBRARY_PATH="$HOME/bin/clang/lib:$LD_LIBRARY_PATH"
# export LIBRARY_PATH="$HOME/bin/clang/lib:$LD_LIBRARY_PATH"

Ccls

export PATH="$HOME/bin/ccls/bin:$PATH"

Eldev

It is an alternative to Cask. Unlike Cask, Eldev itself is fully written in Elisp and its configuration files are also Elisp programs.

export PATH="$HOME/bin/eldev:$PATH"

Fd

export PATH="$HOME/bin/fd:$PATH"

Kmonad

export PATH="$HOME/bin/kmonad:$PATH"

Deno

export DENO_INSTALL="$HOME/.deno"
export PATH="$DENO_INSTALL/bin:$PATH"

Gcc

export PATH="$HOME/bin/gcc-trunk/bin:$PATH"
#export LD_LIBRARY_PATH="$HOME/bin/gcc-10.2.0/lib:$HOME/bin/gcc-10.2.0/lib64:$LD_LIBRARY_PATH"
#export LIBRARY_PATH="$HOME/bin/gcc-10.2.0/lib:$HOME/bin/gcc-10.2.0/lib64:$LIBRARY_PATH"
export MANPATH="$HOME/bin/gcc-trunk/share/man:$MANPATH"
export INFOPATH="$HOME/bin/gcc-trunk/share/info:$INFOPATH"

Golang

export PATH="/usr/local/go/bin:$PATH"
export PATH="$GOPATH/bin:$PATH"

Pyenv

export PATH=$PYENV_ROOT/bin:$PATH
export PATH=$PYENV_ROOT/shims:$PATH

Anki

export PATH="$HOME/bin/anki/bin:$PATH"

Poetry

export PATH="$HOME/bin/poetry/bin:$PATH"

Alacritty

export PATH=$HOME/bin/alarcritty:$PATH

Emacs

export PATH=$HOME/bin/emacs/bin:$PATH

Neovim

export PATH=$HOME/bin/neovim:$PATH

Node

export PATH=$HOME/bin/node/bin:$PATH

Ninja

export PATH=$HOME/bin/ninja:$PATH

Dart

export PATH=$HOME/bin/flutter/bin/cache/dart-sdk/bin:$PATH
export PATH=$HOME/.pub-cache/bin:$PATH

Hugo

export PATH=$HOME/bin/hugo:$PATH

Flutter

export PATH=$HOME/bin/flutter/bin:$PATH

Android Studio

export PATH=$HOME/bin/android-studio/bin:$PATH

Android Tools

export PATH=$HOME/bin/android/emulator:$PATH
export PATH=$HOME/bin/android/cmdline-tools/latest/bin:$PATH

Jdk

export PATH=$HOME/bin/jdk/bin:$PATH

Sqlite

export PATH=$HOME/bin/sqlite:$PATH

Cmake

export PATH=$HOME/bin/cmake/bin:$PATH

Scripts

export PATH=$HOME/bin/scripts:$PATH
export PATH=$HOME/bin/scripts/build:$PATH

Guile

export PATH=$HOME/bin/guile/bin:$PATH

Common lisp

export PATH=$HOME/bin/sbcl/bin:$PATH

Racket

export PATH=$HOME/bin/racket/bin:$PATH

Ripgrep

export PATH=$HOME/bin/ripgrep:$PATH

.xsession

This solves Mouse scroll not working in GTK+ applications in stumpwm
export GDK_CORE_DEVICE_EVENTS=1

Bashrc

prompt

https://github.com/riobard/bash-powerline

source ~/.config/bash-powerline/bash-powerline.sh

Variables

export HISTSIZE=10000
export HISTFILESIZE=10000
export HISTCONTROL=ignoreboth:erasedups
export CXX="g++"
export CC="gcc"
export PATH="$HOME/bin/gcc-trunk/bin:$HOME/bin/build2/bin:$HOME/bin/cpp-libraries/bin:$HOME/bin/graphviz/bin:$PATH"

export LSP_USE_PLISTS=true

#export LD_LIBRARY_PATH="$HOME/bin/gcc-10.2.0/lib:$HOME/bin/gcc-10.2.0/lib64:$LD_LIBRARY_PATH"
#export LIBRARY_PATH="$HOME/bin/gcc-10.2.0/lib:$HOME/bin/gcc-10.2.0/lib64:$LIBRARY_PATH"
export MANPATH="$HOME/bin/gcc-10.2.0/share/man:$MANPATH"
export INFOPATH="$HOME/bin/gcc-10.2.0/share/info:$INFOPATH"

# For some reason this only works in .bashrc
# Also seems that one stdlib can be active (clang or gcc)
# export LD_LIBRARY_PATH="$HOME/bin/clang/lib:/usr/local/lib:$HOME/bin/gcc-10.2.0/lib64:$HOME/Projects/cpp/lazy cpp/cpp-for-lazy-programmers/external/SSDL/unix:$HOME/bin/cpp-libraries/lib:$HOME/bin/graphviz/lib:$LD_LIBRARY_PATH"

export LD_LIBRARY_PATH="$HOME/bin/gcc-trunk/lib64:$HOME/bin/gcc-trunk/lib:$HOME/bin/clang/lib:$HOME/bin/cpp-libraries/lib:$HOME/bin/graphviz/lib:$LD_LIBRARY_PATH"
#export LD_LIBRARY_PATH="$HOME/bin/clang/lib:$LD_LIBRARY_PATH"

functions

# fd - cd to selected directory
ff() {
  local dir
  dir=$(find ${1:-.} -path '*/\.*' -prune \
                  -o -type d -print 2> /dev/null | fzf +m) &&
  cd "$dir"
}
# fd - cd to selected directory
fd() {
  DIR=`find * -maxdepth 0 -type d -print 2> /dev/null | fzf-tmux` \
    && cd "$DIR"
}
# fdr - cd to selected parent directory
fdr() {
  local declare dirs=()
  get_parent_dirs() {
    if [[ -d "${1}" ]]; then dirs+=("$1"); else return; fi
    if [[ "${1}" == '/' ]]; then
      for _dir in "${dirs[@]}"; do echo $_dir; done
    else
      get_parent_dirs $(dirname "$1")
    fi
  }
  local DIR=$(get_parent_dirs $(realpath "${1:-$PWD}") | fzf-tmux --tac)
  cd "$DIR"
}

vterm

Enable the shell to send information to vterm via properly escaped sequences

function vterm_printf(){
    if [ -n "$TMUX" ]; then
        # Tell tmux to pass the escape sequences through
        # (Source: http://permalink.gmane.org/gmane.comp.terminal-emulators.tmux.user/1324)
        printf "\ePtmux;\e\e]%s\007\e\\" "$1"
    elif [ "${TERM%%-*}" = "screen" ]; then
        # GNU screen (screen, screen-256color, screen-256color-bce)
        printf "\eP\e]%s\007\e\\" "$1"
    else
        printf "\e]%s\e\\" "$1"
    fi
}

Function to be able to call elisp functions in vterm

vterm_cmd() {
    local vterm_elisp
    vterm_elisp=""
    while [ $# -gt 0 ]; do
        vterm_elisp="$vterm_elisp""$(printf '"%s" ' "$(printf "%s" "$1" | sed -e 's|\\|\\\\|g' -e 's|"|\\"|g')")"
        shift
    done
    vterm_printf "51;E$vterm_elisp"
}

Open file or dired in emacs when using vterm

op() {
    vterm_cmd find-file "$(realpath "$@")"
}

Use emacs built-in man command

if [[ "$INSIDE_EMACS" = 'vterm' ]]; then
    function mn() {
        vterm_cmd man "$1"
    }
fi

Use a temp buffer instead of less

function menos() {
    xclip -selection clipboard
    vterm_cmd menos
}

Update the CWD

vterm_set_directory() {
    vterm_cmd update-pwd "$PWD/"
}

fzf

  • Install https://github.com/junegunn/fzf
    git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
    ~/.fzf/install
        

    This is add automaticly after installing fzf

    [ -f ~/.fzf.bash ] && source ~/.fzf.bash
        

pyenv

export PATH=$PYENV_ROOT/bin:$PATH
export PATH=$PYENV_ROOT/shims:$PATH

if command -v pyenv 1>/dev/null 2>&1; then
    eval "$(pyenv init -)"
fi

Directory tracking and Prompt tracking

vterm_prompt_end(){
    vterm_printf "51;A$(whoami):$(pwd)"
}
PS1=$PS1'\[$(vterm_prompt_end)\]'

dcli

export PATH=$PATH:/home/last/.dcli/bin
complete -o nospace -C 'dcli_complete' dcli

Zathura

# Open document in fit-width mode by default
set adjust-open "width"

set smooth-scroll true
set statusbar-basename true
set selection-clipboard clipboard

Common lisp (.sbclrc)

;;; The following lines added by ql:add-to-init-file:
#-quicklisp
(let ((quicklisp-init (merge-pathnames "bin/quicklisp/setup.lisp"
                                       (user-homedir-pathname))))
  (when (probe-file quicklisp-init)
    (load quicklisp-init)))
;;;

(pushnew (truename "~/Projects/lisp") ql:*local-project-directories* )
;; update of the system index file
;; ~/bin/quicklisp/local-projects/system-index.txt
(ql:register-local-projects)

Guile (.guile)

(module-set! (resolve-module '(system repl common))
             'repl-welcome (const #f))

~/.guile-geiser

Remove the welcome message
(module-set! (resolve-module '(system repl common))
             'repl-welcome (const #f))

Stumpwm

Have access to the sumpwm functions

(in-package :stumpwm)

Fix scrolling problem

;; bugfix for scrolling doesn't work with an external mouse in GTK+3 apps.
(setf (getenv "GDK_CORE_DEVICE_EVENTS") "1")

Connect sly to stumpwm

Going back to the .stumpwmrc, notice how the port is set to 4004? I do that so that when you start SLY in Emacs, there are no errors because the default port is actually 4005. This ensures you can’t mess up your WM by accident while writing unrelated code. kaashif.co.uk: Hacking StumpWM with Common Lisp

(ql:quickload :slynk)
(slynk:create-server :port 4004 :dont-close t)
;; (slynk:create-server :port 4008)

Workspaces

Stumpwm has only one workspace by default.

(defvar *ram/workspaces* (list "1" "2" "3"))
;; rename the default workspace to "1"
(stumpwm:grename (nth 0 *ram/workspaces*))
;; create workspace "2" and "3"
(dolist (workspace (cdr *ram/workspaces*))
  (stumpwm:gnewbg workspace))

Set the prefix key

;; (run-shell-command "xmodmap $HOME/Projects/dots/modmap" t)
;; (run-shell-command "xmodmap -e \'keycode 94 = F20\'" t)
;; (set-prefix-key (kbd "F20"))
;; (set-prefix-key (kbd "less"))

Key bindings

Programs

(define-key *root-map* (kbd "p") (concat "exec " (getenv "HOME") "/.dcli/bin/dmenu_core"))
(define-key *root-map* (kbd "c") "exec alacritty")

Switch to a workspace

;; move to workspace
(defvar *move-to-keybinds* (list "!" "@" "#"))
(dotimes (y (length *ram/workspaces*))
  (let ((workspace (write-to-string (+ y 1))))
    (define-key *root-map* (kbd workspace) (concat "gselect " workspace))
    (define-key *root-map* (kbd (nth y *move-to-keybinds*)) (concat "gmove-and-follow " workspace))))

Volume control

;; define volume control keys
(define-key *top-map* (kbd "XF86AudioLowerVolume") "exec amixer set Master 5%-")
(define-key *top-map* (kbd "XF86AudioRaiseVolume") "exec amixer set Master 5%+")
(define-key *top-map* (kbd "XF86AudioMute") "exec amixer set Master toggle")
;; (define-key *top-map* (kbd "XF86AudioMicMute") "exec amixer set Capture toggle")

Windows focus

;; (define-key *root-map* (kbd "h") "move-focus left")
;; (define-key *root-map* (kbd "j") "move-focus down")
;; (define-key *root-map* (kbd "k") "move-focus up")
;; (define-key *root-map* (kbd "l") "move-focus right")

Move windows around

;; (define-key *root-map* (kbd "H") "move-window left")
;; (define-key *root-map* (kbd "J") "move-window down")
;; (define-key *root-map* (kbd "K") "move-window up")
;; (define-key *root-map* (kbd "L") "move-window right")

Restart

;; (define-key *root-map* (kbd "R") "restart-hard")

Show programs in every workspaces

(define-key *root-map* (kbd "0") "vgroups")

Brightness

;; (define-key *top-map* (kbd "XF86MonBrightnessUp") "backlight-up")
;; (define-key *top-map* (kbd "XF86MonBrightnessDown") "backlight-down")

Frame preference

;;;; Frame Preferences
(define-frame-preference "Default"
    ;; frame raise lock (lock AND raise == jumpto)
    (0 t   t :class "Firefox"))

(define-frame-preference "MAIL"
    ;; frame raise lock (lock AND raise == jumpto)
    (0 t   t :class "Thunderbird"))

(define-frame-preference "EMACS"
    ;; frame raise lock (lock AND raise == jumpto)
    (0 t   t :class "Emacs"))

Start up programs

(run-shell-command "kmonad /home/last/.config/kmonad/config.kbd")
(run-shell-command "systemctl start --user emacs.service")

Kmonad

Copy-out the following template to quickly create a layer

#| --------------------------------------------------------------------------

(deflayer base
  _         _    _    _    _    _    _    _    _    _    _   _   _   _   _     _    _
  _         _    _    _    _    _    _    _    _    _    _   _   _   _              _
  _         _    _    _    _    _    _    _    _    _    _   _   _   _              _
  _         _    _    _    _    _    _    _    _    _    _   _   _                  _
  _    _    _    _    _    _    _    _    _    _    _    _   _       _              _
  _         _    _         _         _    _    _                 _   _   _
  )

-------------------------------------------------------------------------- |#

Basic system config

The name given as the first argument to uinput-sink will be the name given to the virtual keyboard that KMonad creates.

input is the build-in notebook keyboard. If a keyboard is plug, the value has to be changed.

fallthrough just means that if a key is not define in the current layer, it will take the key value of the base layer.

(defcfg
  input  (device-file "/dev/input/by-path/platform-i8042-serio-0-event-kbd")
  output (uinput-sink "KMonad kbd")
  allow-cmd true)

Aliases

Layout aliases

(defalias
  def (layer-switch default)
  d+e #((layer-switch default) P20 esc)
  d+s #((layer-switch default) P20 spc)
  ev (layer-switch edit-nav)
  hl (layer-switch handler)
  win (layer-switch window)
  qk (layer-switch quick-access)
  ema (layer-switch emacs)
  sym (layer-switch symbol)
  sy+ (layer-switch symbol+)
  caps (layer-switch caps)
  num (layer-switch num)
  org (layer-switch org-mode)
  fight (layer-switch fight)
)

Handler aliases

(defalias
;; toggle vterm
cccvv #(C-c c v v @def)
;; relative indent
cccoi #(C-c c o i @def)
;; jump bookmark
cxrb #(C-x r b @def)
;; copy
aw #(A-w @def)
;; paste
cy #(C-y @def)
;; undo
c/ #(C-/ @def)
;; fancy-dabbrev-expand-or-indent
cccfd #(C-c c f d @def))

Window manager aliases

;; Window manager
(defalias
  ctt #(C-t P20 C-t @def)
  ct1 #(C-t P20 1 @def)
  ct2 #(C-t P20 2 @def)
  ct3 #(C-t P20 3 @def)
  kill #(C-t P20 C-k @def)
  nxt #(C-t P20 A-n @def)
  pvs #(C-t P20 A-p @def)
  pro #(C-t P50 p @def)
  ctqu #(C-t P50 " @def)
  ctq #(C-t P50 q @def)
  ct: #(C-t P50 : @def)
  cta #(C-t P50 a @def)
  )

Emacs aliases

(defalias
  ch #(C-h @def)
  ;; M-x
  mx #(A-x @def)
  ;; search and replace
  as5 #(A-S-5 @def)
  ;; tab-new
  cxt2 #(C-x t 2 @def)
  ;; save-buffer
  cxcs #(C-x C-s @def)
  ;; cancel
  cg #(C-g @def)
  ;; confirm
  cccc #(C-c C-c @def)
  ;; open file
  cxcf #(C-x C-f @def)
  ;; open roam
  cccrn #(C-c c r n @def)
  ;; tangle
  cccvt #(C-c C-v t @def)
  ;; magit-status
  cxg #(C-x g @def)
  ;; eval-expression
  as: #(A-S-: @def)
  ;; consult-ripgrep
  ccccr #(C-c c c r @def)
  ;; consult-yank-pop
  ay #(A-y @def)
  )

Symbols aliases

;; symbols
(defalias
  [ #([ @def)
  ] #(] @def)
  op #(\( @def)
  cp #(\) @def)
  { #({ @def)
  } #(} @def)
  & #(& @def)
  * #(* @def)
  / #(/ @def)
  r/ #(\\ @def)
  ex #(^ @def)
  = #(= @def)
  ` #(` @def)
  ~ #(~ @def)
  at #(@ @def)
  us #(\_ @def)
  - #(- @def)
  | #(| @def)
  ; #(; @def)
  + #(+ @def)
  ? #(? @def)
  % #(% @def)
  ! #(! @def)
  # #(# @def)
  < #(< @def)
  > #(> @def)
  : #(: @def)
  , #(, @def)
  . #(. @def)
  $ #($ @def)
  ^ #(^ @def)
  qu #(" @def)
  ;; one tap -> ;
  ;; two taps -> :
  ;: (multi-tap 200 @; @:)
  ;; one tap -> ?
  ;; two taps -> !
  ?! (multi-tap 200 @? @!)
  ;; one tap -> /
  ;; two taps -> \
  // (multi-tap 200 @/ @r/)
  ;; one tap -> {
  ;; two taps -> }
  {} (multi-tap 200 @{ @})
  ;; one tap -> -
  ;; two taps -> _
  -u (multi-tap 200 @- @us)
  ;; one tap -> <
  ;; two taps -> >
  <> (multi-tap 200 @< @>)
  ;; one tap -> `
  ;; two taps -> ~
  `~ (multi-tap 200 @` @~)
  ;; one tap -> '
  ;; two taps -> "
  qq (multi-tap 200 ' ")
)

Navegation aliases

(defalias
  ;; beggining of line
  ca #(C-a @def)
  ;; end of line
  ce #(C-e @def)
  ;; scroll half page up
  cccvu #(C-c c v u)
  ;; scroll half page down
  cccvd #(C-c c v d)
  ;; tab-next
  cxto #(C-x t o @def)
  ;; delete-window
  cx0 #(C-x 0 @def)
  ;; delete-other-window
  cx1 #(C-x 1 @def)
  ;; other-window
  cxo #(C-x o @def)
  ;; return and then go to def layer
  rdef #(ret @def)
  )

Quick access aliases

(defalias
  ;; yas-expand
  cccyi #(C-c c y i @def)
  ;; search and replace
  as% #(A-S-% @def)
  ;; org-toggle-narrow-to-subtree
  cccon #(C-c c o n @def)
  ;; search
  cs #(C-s @def)
  ;; open dired
  cccdd #(C-c c d d @def)
  ;; escape
  escp #(esc @def)
  ;; previous buffer
  ccce, #(C-c c e , @def)
  ;; previous tab
  cccet #(C-c c e t @def)
  ;; avy-goto-char-timer
  cccaf #(C-c c a f @def)
  ;; jump to "("
  cccap #(C-c c a p @def)
  ;; eval sexp
  cxce #(C-x C-e @def)
  ;; eval definition
  cmx #(A-C-x @def)
  ;; embark-act
  cccka #(C-c c k a @def)
  ;; embark-dwim
  ccckd #(C-c c k d @def)
  ;; one tap -> embark-act
  ;; two taps -> embark-dwim
  ead (multi-tap 300 @cccka @ccckd)
  ;; V
  V #(V @def)
  ;; C-v
  cv #(C-v @def)
  ;; one tap -> V
  ;; two taps -> C-v
  vv (multi-tap 300 @V @cv)
)

Org-mode aliases

(defalias
  ;; consult-outline
  ccno #(C-c c n o @def)
)

Edit aliases

(defalias
  ;;M-k kills to the left
  cccrk #(C-c c r k @def)
  ck #(C-k @def)
)

Fight aliases

(defalias
  haf  (layer-toggle handlerfight)
  fr  (layer-toggle fordwardright)
  df (cmd-button "xdotool keydown Down; xdotool keydown Right; xdotool keyup Down; xdotool keyup Right; sleep 0.01; xdotool key b")
  fdf (cmd-button "xdotool key Right; xdotool keydown Down; sleep 0.01; xdotool keydown Right; sleep 0.01; xdotool keyup Down; xdotool keyup Right; sleep 0.01; xdotool key b; xdotool key m")

  nhaf (around-next @haf)
  nfr (around-next @fr)
  lp b
)

Source layer

First up is the source (base) layer; this is used to set the default keys that will be overwritten later. It is `not’ a layer that will be used in the actual layout.

(defsrc
  esc         f1   f2   f3   f4   f5   f6   f7   f8   f9   f10  f11   f12    pause  prnt  ins  del
  `           1    2    3    4    5    6    7    8    9    0    -     =      bspc              home
  tab         q    w    e    r    t    y    u    i    o    p    [     ]      ret               pgup
  caps        a    s    d    f    g    h    j    k    l    ;    '     \                        pgdn
  lsft   102d z    x    c    v    b    n    m    ,    .    /    rsft         up                end
  lctl        lmet lalt      spc       ralt cmps rctl                 left   down   rght
  )

Layers

Default layer

Since this is the first layer, it’s the layout KMonad starts in.

(deflayer default
  esc         f1     f2   f3   f4     f5   f6   f7   f8   f9   f10  f11   f12    pause  prnt  ins  del
  `           1      2    3    4      5    6    7    8    9    0    -     =      bspc              home
  tab         q      w    e    r      t    y    u    i    o    p    [     ]      ret               pgup
  @ev         a      s    d    f      g    h    j    k    l    @hl  '     \                        pgdn
  lsft  C-t   z      x    c    v      b    n    m    @qk  @sym /    rsft         up                end
  lctl        lmet   lalt      spc         ralt cmps @fight               left   down   rght
  )

Handler layer

(deflayer handler
  @d+e      _      _      _       _      _     _    _    _    _    _     _   _   _   _     _    _
  _         _      _      _       _      _     _    _    _    _    _     _   _   _              _
  _         @caps  _      @ema    _      _     _    @c/  _    @org _     _   _   _              _
  _         @cccfd @cccoi @cccvv  @escp  @[    @]   @op  @cp  _    @ctt  _   _                  _
  _    _    _      _      @aw     @ev    @cxrb @num _    _    _    _     _       _              _
  _         _      _            @win           @def _    _                   _   _   _
  )

Quick access layer

(deflayer quick-access
  @d+e      _      _     _      _      _      _      _      _      _    _     _   _   _   _     _    _
  _         _      _     _      _      _      _      _      _      _    _     _   _   _              _
  _         @cccet _     @cxce  @as%   _      _      _      @cccyi _    _     _   _   _              _
  _         _      @cs   @cccdd @cccaf _      @ead   @cccap _      _    _     _   _                  _
  _    _    _      @cmx  _      @vv    _      @cccon _      @ccce, _    _     _       _              _
  _         _      _            @cxo          @def   _      _                     _   _   _
  )

Edit-navegation layer

(deflayer edit-nav
  @d+e      _    _    _      _    _    _      _       _      _      _      _   _   _   _     _    _
  _         _    _    _      _    _    _      _       _      _      _      _   _   _              _
  _         _    _    A-del  A-d  _    _      @cccvd  @cccvu @cxo   @cxto  _   _   @rdef          _
  @def      _    _    bspc   C-d  _    left   down    up     rght   @ctt   _   _                  _
  _    _    _    _    @cccrk @ck  _    @ca    @ce     @cx1   @cx0   _      _       _              _
  _         _    _           @def      @def   _       _                        _   _   _
  )

Symbols layer

(deflayer symbol
  @d+e      _    _    _    _    _    _    _    _    _    _   _   _   _   _     _    _
  _         _    _    _    _    _    _    _    _    _    _   _   _   bspc           _
  _         @?   @at  @^   @`   _    _    _    @=   _    _   _   _   _              _
  _         @qu  @*   @/   @:   @#   @$   @-   @us  @<   @;  _   _                  _
  _    _    _    _    _    @%   _    @{   @}   @,   @.   _   _       _              _
  _         _    _         @sy+      @def _    _                 _   _   _
  )

Fight layer

(deflayer fight
  _         _    _    f3   _    _    _     _    _    _    f10 f11 f12 _   _     _    _
  _         1    2    3    4    5    _     _    _    _    0   _   _   _              _
  _         _    up   _    _    _    _     _    _    _    _   _   _   _              _
  _         left down rght _    _    h     j    k    _    _   _   _                  _
  _    _    _    _    _    _    b    n     m    _    _    _   _       _              _
  _         _    _         @nhaf     @def  _    _                 _   _   _
  )

(deflayer handlerfight
  _         _    _    _    _    _    _     _    _    _    _   _   _   _   _     _    _
  _         _    _    _    _    _    _     _    _    _    _   _   _   _              _
  _         _    up   _    _    _    _     _    _    _    _   _   _   _              _
  _         left down @nfr _    _    _     _    _    _    _   _   _                  _
  _    _    _    _    _    _    _    n     _    _    _    _   _       _              _
  _         _    _         _         @def  _    _                 _   _   _
  )

(deflayer fordwardright
  _         _    _    _    _    _    _     _    _    _    _   _   _   _   _     _    _
  _         _    _    _    _    _    _     _    _    _    _   _   _   _              _
  _         _    up   _    _    _    _     _    _    _    _   _   _   _              _
  _         left down rght _    _    _     _    _    _    _   _   _                  _
  _    _    _    _    _    _    @df  n     _    _    _    _   _       _              _
  _         _    _         _         @def  _    _                 _   _   _
  )

Symbols+ layer

(deflayer symbol+
  @d+e      _    _    _    _    _    _    _    _    _    _   _   _   _   _     _    _
  _         _    _    _    _    _    _    _    _    _    _   _   _   bspc           _
  _         _    _    _    _    _    _    _    _    _    _   _   _   _              _
  _         @&   @|   @r/  @+   _    _    @~   @!   @>   _   _   _                  _
  _    _    _    _    _    _    _    _    _    _    _    _   _       _              _
  _         _    _         @def      @def _    _                 _   _   _
  )

Window manager layer

(deflayer window
  @d+e      _    _    _    _     _    _    _    _     _    _     _   _   _   _     _    _
  _         _    _    _    _     _    _    _    _     _    _     _   _   _              _
  _         @ctq _    _    _     @cta _    _    _     _    _     _   _   _              _
  _         @ct1 @ct2 @ct3 @ctqu _    _    _    @kill _    @ct:  _   _                  _
  _    _    _    _    _    _     _    @pvs @nxt _     _    _     _       _              _
  _         _    _         @pro       @def _    _                    _   _   _
  )

Emacs layer

(deflayer emacs
  @d+e      _      _     _      _      _     _      _    _     _      _     _   _   _   _     _    _
  _         _      _     _      _      _     _      _    _     _      _     _   _   _              _
  _         @cxcf  @cxcs @mx    @ccccr @cxt2 _      _    _     _      _     _   _   _              _
  _         _      _     _      @as5   @cg   @ch    _    _     @cccvt @as:  _   _                  _
  _    _    _      _     @cccc  @ay    _     @cccrn @cxg _     _      _     _       _              _
  _         _      _            _            @def   _    _                      _   _   _
  )

Org-mode

(deflayer org-mode
  @d+e      _    _    _    _    _    _    _    _    _     _     _   _   _   _     _    _
  _         _    _    _    _    _    _    _    _    _     _     _   _   _              _
  _         _    _    _    _    _    _    _    _    @ccno _     _   _   _              _
  _         _    _    _    _    _    _    _    _    _     _     _   _                  _
  _    _    _    _    _    _    _    _    _    _    _     _     _       _              _
  _         _    _         _         @def _    _                    _   _   _
  )

Caps layer

(deflayer caps
  @d+e      _      _    _       _      _    _    _    _    _    _     _   _   _   _     _    _
  _         _      _    _       _      _    _    _    _    _    _     _   _   bspc           _
  _         Q      W    E       R      T    Y    U    I    O    P     _   _   _              _
  _         A      S    D       F      G    H    J    K    L    @hl   _   _                  _
  _    _    Z      X    C       V      B    N    M    @qk  @sym _     _       _              _
  _         _      _            @def        @def _    _                   _   _   _
  )

Number layer

(deflayer num
  @d+e      _    _    _    _    _    _    _    _    _    _   _   _   _   _     _    _
  _         _    _    _    _    _    _    _    _    _    _   _   _   bspc           _
  _         _    _    _    _    _    _    _    _    _    _   _   _   _              _
  _         1    2    3    4    5    6    7    8    9    @hl _   _                  _
  _    _    _    _    _    _    _    0    _    @qk  @sym _   _       _              _
  _         _    _         @def      @def _    _                 _   _   _
  )