Skip to content

Flirre/.emacs.d

Repository files navigation

Emacs Config

Customize settings

A custom file to keep customizations out of init.el. All to declutter my init.el.

(setq custom-file (expand-file-name "custom.el" user-emacs-directory))
(load custom-file)

Loading contents from a file containing all of my life ruining secrets.

(if (file-exists-p "private.el") (load-file (concat user-emacs-directory "private.el")))

Diminish mode, for less clutter.

(use-package diminish)

Setup from Ian’s Yay-Evil Distro.

(use-package emacs
  :preface
  (defvar flirre/indent-width 4) ; change this value to your preferred width
  :config
  (setq frame-title-format '("Emacs")
  ring-bell-function 'ignore
  frame-resize-pixelwise t
  default-directory "~/")

  (tool-bar-mode -1)
  (menu-bar-mode -1)
  (scroll-bar-mode -1)
  ;; better scrolling experience
  (setq scroll-margin 0
        scroll-conservatively 10000
        scroll-preserve-screen-position t
        auto-window-vscroll nil)

  ;; increase line space for better readability
  (setq-default line-spacing 2)

  ;; Always use spaces for indentation
  (setq-default indent-tabs-mode nil
                tab-width flirre/indent-width))

Package managing

Package utils

A package for smoother upgrading of packages.

(use-package package-utils)

Dashboard

The package emacs-dashboard is a package that provides a dashboard to get a quick overview of different things while inside Emacs. For example projects via Projectile, agenda-view via Org-Agenda, etc.

(use-package dashboard
:demand t
  :config
  (dashboard-setup-startup-hook)
  (setq initial-buffer-choice (lambda () (get-buffer "*dashboard*")))

;; Customizing what is shown on the dashboard.
(setq dashboard-banner-logo-title nil)
(setq dashboard-center-content t)
(setq dashboard-items '((recents . 15)
                        (projects . 6)
                        (agenda  . 6)))
(setq dashboard-set-file-icons t))

Themes

Doom-themes

(use-package doom-themes
  :config
  ;; Global settings (defaults)
  (setq doom-themes-enable-bold t    ; if nil, bold is universally disabled
        doom-themes-enable-italic t) ; if nil, italics is universally disabled
  (load-theme 'doom-molokai-fixed t)

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

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

Font

Inconsolata is a pleasant monospaced font. You can install it on Arch Linux using an AUR-helper such as yay, which would look like this:

yay -S ttf-inconsolata

And to tell Emacs to use that font you run:

(when (eq system-type 'darwin)
(add-to-list 'default-frame-alist
'(font . "FantasqueSansMono Nerd Font-18")))

(when (eq system-type 'gnu/linux)
(add-to-list 'default-frame-alist
'(font . "FantasqueSansMono Nerd Font-14")))

Sane defaults / customizations

;; Less prompting
(fset 'yes-or-no-p 'y-or-n-p)

;; Put all backup in one place
(setq backup-directory-alist '(("." . "~/.emacs.d/backups")))
(setq auto-save-file-name-transforms '((".*" "~/.emacs.d/auto-save-list/" t)))

;; Quiet in Emacs, please
(setq visible-bell t)
(use-package paren
  :ensure nil
  :config
  (setq show-paren-delay 0)
  (show-paren-mode))

(use-package elec-pair
  :ensure nil
  :hook (prog-mode . electric-pair-mode))

(use-package mwheel
  :ensure nil
  :config (setq mouse-wheel-scroll-amount '(1 ((shift) . 1))
                mouse-wheel-progressive-speed nil))

(use-package company
  :diminish company-mode
  :hook (prog-mode . company-mode)
  :config
  (setq company-minimum-prefix-length 1
        company-idle-delay 0
        company-selection-wrap-around t
        company-tooltip-align-annotations t
        company-frontends '(company-pseudo-tooltip-frontend ; show tooltip even for single candidate
                            company-echo-metadata-frontend))
  (with-eval-after-load 'company
    (define-key company-active-map (kbd "C-n") 'company-select-next)
    (define-key company-active-map (kbd "C-p") 'company-select-previous)))

;; A modern on-the-fly syntax checking extension – absolutely essential
(use-package flycheck
  :hook (after-init . global-flycheck-mode))

sane-term provides ansi-term with some sane defaults making for a smoother experience.

(use-package sane-term
  :bind (
    ("C-x t" . sane-term)
    ("C-x T" . sane-term-create)))

The kill ring can be a pain to browse through using M-y. That’s why we use popup-kill-ring instead!

(use-package popup-kill-ring
:bind ("M-y" . popup-kill-ring))

Keybindings

which-key mode, great for finding and using new commands/

(use-package which-key
:diminish
:config
(which-key-mode t)
(which-key-setup-side-window-bottom))

This is where I’ll keep my different keybindings for all kinds of things.

(global-set-key (kbd "M-n w") 'make-frame-command)
(global-set-key (kbd "C-x C-k") 'kill-this-buffer)

Keybind for window resize

(global-set-key (kbd "M-s-<left>") 'shrink-window-horizontally)
(global-set-key (kbd "M-s-<right>") 'enlarge-window-horizontally)
(global-set-key (kbd "M-s-<up>") 'enlarge-window)
(global-set-key (kbd "M-s-<down>") 'shrink-window)

Rebind key to helm-imenu

(global-set-key (kbd "M-i") 'helm-imenu-in-all-buffers)

Keybinding for running company (conflict with Magit-status-mode)

(with-eval-after-load 'company
(define-key company-mode-map (kbd "TAB") #'company-indent-or-complete-common)
)

Keyboard shortcut for reverting buffer without confirming.

(defun revert-buffer-no-confirm ()
  "Revert buffer without confirmation."
  (interactive) (revert-buffer t t))
(global-set-key (kbd "C-S-R") 'revert-buffer-no-confirm)
(global-set-key (kbd "M-o") 'other-window)
(global-set-key (kbd "C-S-o") 'open-line )

Buffers

Use ibuffer instead of list-buffers

(defalias 'list-buffers 'ibuffer)
(global-set-key (kbd "C-x b") 'helm-buffers-list)

Swap-buffers is a package that makes it easier to swap around buffers to get the placements you want.

(use-package swap-buffers
 :bind
  ("M-s M-s" . swap-buffers))

Dimmer.el ‘dims’ all buffers that aren’t in focus so that it’s easier to concentrate on the buffer you are editing.

(use-package dimmer
:config
(dimmer-configure-which-key)
(dimmer-configure-helm)
(dimmer-configure-magit)
(dimmer-mode t))

Org-mode

Visual lines in org mode for better readability and indent those headers for me, please.

(use-package org
 :defer t
  :hook ((org-mode . visual-line-mode)
         (org-mode . org-indent-mode))
:config
(with-eval-after-load 'org
  (use-package org-bullets
  :hook (org-mode . org-bullets-mode))
))

Pretty symbols shown in buffer

(setq org-pretty-entities t)

minted for org-mode pdfs

(setq org-latex-listings 'minted
org-latex-packages-alist '(("" "minted"))
org-latex-pdf-process
'("latexmk -pdflatex='pdflatex -interaction nonstopmode' -pdf -bibtex -f %f"))

keybinding for storing links to files/lines

(global-set-key (kbd "C-c l") 'org-store-link)

Agenda mode for organization.

(global-set-key (kbd "C-c a") 'org-agenda)

Add all agenda files to agenda.

(setq org-agenda-files '("~/agenda"))

Set correct path for archiving.

(setq org-archive-location "~/agenda/archives/%s_archive::")

Function to insert an :ARCHIVE: property with corresponding header.

(defun org-insert-archive ()
"Inserts an :ARCHIVE: property under the current header."
(interactive)
(save-excursion
(outline-back-to-heading t)
(end-of-line)
(newline)
(insert ":ARCHIVE: %s_archive::* " (org-get-heading t t t t))))
(defun org-insert-archive-all ()
"Inserts :ARCHIVE: on all headings that do not already have it."
(interactive)
(save-excursion
(org-map-entries #'org-insert-archive nil nil 'archive)
))

Set keybinding for adding archive property

(define-key org-mode-map (kbd "C-c C-x s") 'org-insert-archive)

Store diary entries in a synced file.

(setq diary-file "~/agenda/diary.org")

Some personal preference Org-mode settings.

  • Org-mode deadlines do not warn until 7 days are left.
  • Agenda times have a leading zero to make a more symmetric agenda.
  • Calendar has 12 for left margin to have it better centered.
(setq org-deadline-warning-days 7)
(setq org-agenda-time-leading-zero t)
(setq calendar-left-margin 12)

Since I want extra Agenda TODO-states to show that a task is in-progress or if something is canceled, I’ve added them to the Org Todo Keywords.

(setq org-todo-keywords
'((sequence "TODO(t)" "IN-PROGRESS(i)" "|" "DONE(d)" "CANCELED(c)")))

Extra keybind for quick access to org files from Agenda view.

(global-set-key (kbd "C-'") 'org-cycle-agenda-files)

Redefining stuck-projects as TODO items that aren’t scheduled.

(setq org-stuck-projects
'("TODO={.+}/-DONE" nil nil "SCHEDULED:\\|DEADLINE:"))

Org templates to quickly generate code blocks for different languages in org-mode. Activated with ‘C-c C-,’

(lisp-to-list 'org-structure-template-alist '("el" . "src emacs-lisp"))

(add-to-list 'org-structure-template-alist '("sh" . "src sh"))

(add-to-list 'org-structure-template-alist '("js" . "src js"))
;         (after-load 'org
;    (org-babel-do-load-languages
;     'org-babel-load-languages
;     '(
;       (awk . t)
;       (calc .t)
;       (C . t)
;       (emacs-lisp . t)
;       (haskell . t)
;       (gnuplot . t)
;       (latex . t)
;       ;;(ledger . t)
;       (js . t)
;       (haskell . t)
;       (http . t)
;       (perl . t)
;       (python . t)
;       ;; (gnuplot . t)
;       ;; org-babel does not currently support php.  That is really sad.
;       ;;(php . t)
;       (R . t)
;       (scheme . t)
;       (sh . t)
;       (sql . t)
;       ;;(sqlite . t)
;       )))

Project management

Projectile is a package that provides Emacs with a way to easier interact with the files a project.

(use-package projectile
:demand t
:bind-keymap
("C-c p" . projectile-command-map)
("s-p" . projectile-command-map)
:config
(projectile-mode +1))

Searching via ag

(use-package ag)

Using Helm

(use-package helm-ag
:after ag helm)

Helm

helm-M-x is a beautiful thing that always helps me find what command I need.

(use-package helm
:demand t
:bind
 (("M-x" . helm-M-x)
 ("M-y" . helm-show-kill-ring)
 ("C-x C-f" . helm-find-files)
 ("C-s" . helm-occur))
 :config
 (require 'helm-config)
 (helm-mode 1)

 (setq helm-always-two-windows nil)
 (setq helm-display-buffer-default-height 23)
 (setq helm-buffer-max-length nil)
 (setq helm-default-display-buffer-functions '(display-buffer-in-side-window)))

 (use-package helm-projectile
 :after helm projectile
 :demand t
 :config
 (helm-projectile-on))

Ido

Looking for things using Ido is a more efficient way of looking while still keeping that “Emacs-way” of life.

(use-package ido
:config
(ido-mode))

Git

Magit

Magit is a great interface for git. Much smoother than using commandline git.

(use-package magit
:bind ("C-c g" . magit-status)
:config
 (define-key magit-status-mode-map (kbd "q") 'magit-quit-session)
 (setq magit-section-visibility-indicator nil))

Smerge rebind

(setq smerge-command-prefix "\C-cs")

Forge

A package from the creator of magit which allows the user to interact with Git forges such as GitHub and GitLab while using Emacs and Magit.

(use-package forge
:after magit)

Programming

General

Line numbering.

(add-hook 'prog-mode-hook 'display-line-numbers-mode)

Rainbow delimiters in all languages!

(use-package rainbow-delimiters
:config
(add-hook 'prog-mode-hook 'rainbow-delimiters-mode))

Lightweight syntax highlighting improvement for numbers, operators, and escape sequences From Yay-Evil.

(use-package highlight-numbers
:hook (prog-mode . highlight-numbers-mode))

(use-package highlight-operators
:hook (prog-mode . highlight-operators-mode))

(use-package highlight-escape-sequences
:hook (prog-mode . hes-mode))

Remove trailing whitespace when saving files.

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

Comment/uncomment regions of code.

(global-set-key (kbd "C-x c") 'comment-or-uncomment-region)

Multimarkers!

(use-package multiple-cursors
:bind
(("C-s-c C-s-c" . mc/edit-lines)
("C-s->" . mc/mark-next-like-this)
("C-s-<" . mc/mark-previous-like-this)
("C-s-h" . mc/mark-all-like-this)))

Line movement

(use-package move-dup
:bind
(("M-<up>" . 'md-move-lines-up)
(("M-<down>" . 'md-move-lines-down))
(("C-M-<up>" . 'md-duplicate-up)
(("C-M-<down>" . 'md-duplicate-down)))))

Show flycheck errors inline.

(use-package flycheck-inline
:after flycheck
:hook (flycheck-mode . flycheck-inline-mode))

Sort words (useful when sorting incoming destructured objects in jsx)

(defun sort-words (reverse beg end)
  "Sort words in region alphabetically, in REVERSE if negative.
Prefixed with negative \\[universal-argument], sorts in reverse.

The variable `sort-fold-case' determines whether alphabetic case
affects the sort order.

See `sort-regexp-fields'."
  (interactive "*P\nr")
  (sort-regexp-fields reverse "\\w+" "\\&" beg end))

LSP

;; set prefix for lsp-command-keymap (few alternatives - "C-l", "C-c l")

;;;;; LSP ;;;;;
(use-package lsp-mode
  :init
  (setq lsp-prefer-flymake nil)
  (setq lsp-keymap-prefix "C-l")
  :hook ((js-mode . lsp-deferred)
         (typescript-mode . lsp-deferred)
         (yaml-mode . lsp-deferred)
         (json-mode . lsp-deferred)
         (sh-mode . lsp-deferred)
         (html-mode . lsp-deferred)
         (css-mode . lsp-deferred)
         (sh-mode . lsp-deferred)
         (lsp-mode . lsp-lens-mode))
  ;; waits too long when typing
  :config (add-hook 'lsp-mode-hook #'lsp-enable-which-key-integration)
  :commands (lsp lsp-deferred))

(use-package lsp-ui
  ;; this plays bad with customized at the bottom of init.el
  :custom
    (lsp-ui-doc-enable t)
    (lsp-ui-doc-use-childframe t)
    (lsp-ui-doc-position 'at-point)
    (lsp-ui-doc-include-signature t)
    (lsp-modeline-code-actions-enable nil)
    (lsp-ui-flycheck-enable t)
    (lsp-ui-flycheck-list-position 'bottom)
    (lsp-ui-flycheck-live-reporting t)
    (lsp-ui-sideline-enable t)
    (lsp-ui-sideline-ignore-duplicate t)
    (lsp-ui-sideline-show-diagnostics t)
    (lsp-ui-sideline-show-code-actions t)
    (lsp-ui-sideline-code-actions-prefix "")
    (lsp-ui-peek-enable t)
    (lsp-ui-peek-list-width 60)
    (lsp-ui-peek-peek-height 25)
    (lsp-ui-imenu-enable t)
    (lsp-ui-imenu-kind-position 'top)
  :bind (:map lsp-mode-map ("C-l m" . lsp-ui-imenu))
  :config
    (lsp-diagnostics-modeline-mode)
  :hook (lsp-mode . lsp-ui-mode)
  :commands (lsp-ui-mode)
  :after lsp-mode);; if you are helm user

(use-package helm-lsp :commands helm-lsp-workspace-symbol)

;; optionally if you want to use debugger
(use-package dap-mode :hook
  (lsp-mode . dap-mode)
  (lsp-mode . dap-ui-mode))

(use-package posframe)
(require 'dap-firefox)
(require 'dap-chrome)

Godot

(use-package gdscript-mode
:hook (gdscript-mode . lsp)
:config
(setq gdscript-godot-executable "/usr/bin/godot"))

Python

Some Python packages needed for a working Elpy env. should be installed before elpy is installed and configured.

# Either of these
pip install rope
pip install jedi
# flake8 for code checks
pip install flake8
# importmagic for automatic imports
pip install importmagic
# and autopep8 for automatic PEP8 formatting
pip install autopep8
# and yapf for code formatting
pip install yapf

Or you could the the whole install with a oneliner

pip install jedi flake8 importmagic autopep8

Enables Elpy, a nice Python environment.

(use-package elpy
   :config
 (add-hook 'python-mode-hook 'elpy-enable))

SQL

(use-package sqlformat
:defer t
:config
(setq sqlformat-command "pg_format")
(setq sqlformat-mode-format-on-save t)
(add-hook 'sql-mode-hook 'sqlformat-mode))

Web Development

Use local node modules from inside emacs.

(use-package add-node-modules-path
:after rjsx-mode typescript-mode web-mode js-mode js2-mode
:hook
(rjsx-mode . #'add-node-modules-path)
(typescript-mode . #'add-node-modules-path)
(js-mode . #'add-node-modules-path)
(js2-mode . #'add-node-modules-path)
(web-mode . #'add-node-modules-path))

Web-mode

Web-mode configuration inspired by/semi-stolen from fransiska.

(use-package web-mode
:mode (
("\\.html?\\'" . web-mode))
:config
(add-to-list 'auto-mode-alist '("\\.html?\\'" . web-mode))
(setq web-mode-enable-auto-closing t)
(setq web-mode-markup-indent-offset 2)
(setq web-mode-code-indent-offset 2)
(setq web-mode-css-indent-offset 2)
(setq web-mode-enable-css-colorization t)
(setq web-mode-enable-auto-pairing t)
(setq web-mode-enable-current-element-highlight t)
(defun my-web-mode-hook ()
  (when (string-equal "html" (file-name-extension buffer-file-name))
  (set (make-local-variable 'company-backends) '(company-css company-web-html company-yasnippet company-files )))
))
(use-package company-web
:defer t
:init
(with-eval-after-load 'company
(add-to-list 'company-backends 'company-web-html)))
(use-package emmet-mode
:ensure t
:defer t
:hook
(web-mode . emmet-mode)
(css-mode . emmet-mode)
(scss-mode . emmet-mode)
:config
(setq emmet-move-cursor-between-quotes t)
;;(setq emmet-expand-jsx-className? t) For use with React jsx
)

JavaScript

Indium

(use-package indium)

TypeScript

(use-package add-node-modules-path
:config
(eval-after-load 'web-mode
  '(add-hook 'web-mode-hook #'add-node-modules-path)))
(use-package prettier-js
:diminish 'prettier-js-mode
:hook
(web-mode . prettier-js-mode)
(typescript-mode . prettier-js-mode)
(js-mode . prettier-js-mode))
(use-package typescript-mode
  :mode ("\\.tsx?\\'"))

Markdown

Markdown mode

(use-package markdown-mode
  :commands (markdown-mode gfm-mode)
  :mode (("README\\.md\\'" . gfm-mode)
         ("\\.md\\'" . markdown-mode)
         ("\\.markdown\\'" . markdown-mode))
  :init (setq markdown-command "multimarkdown"))

LaTeX

Auctex for Latex

(use-package auctex
:defer t
:ensure t
:config
((setq TeX-auto-save t)
 (setq TeX-parse-self t)
 (setq-default TeX-master nil))
 (add-hook 'LaTeX-mode-hook 'visual-line-mode)
 (add-hook 'LaTeX-mode-hook 'flyspell-mode)
 (add-hook 'LaTeX-mode-hook 'LaTeX-math-mode)
 (add-hook 'LaTeX-mode-hook 'turn-on-reftex)
 (setq reftex-plug-into-AUCTeX t))

Spotify Bindings

Keybindings so that I can control Spotify without switching focus from Emacs.

(use-package spotify
:bind (
("M-s M-n" . spotify-next)
("M-s M-p" . spotify-previous)
("M-p" . spotify-playpause)
("M-s M-c" . spotify-current)
("<XF86AudioPlay>" . spotify-play)))

TRAMP/Sudo

I borrowed this from somewhere. It makes sudo access much smoother.

  (defvar find-file-root-prefix (if (featurep 'xemacs) "/[sudo/root@localhost]" "/sudo:root@localhost:" )
  "*The filename prefix used to open a file with `find-file-root'.")

(defvar find-file-root-history nil
  "History list for files found using `find-file-root'.")

(defvar find-file-root-hook nil
  "Normal hook for functions to run after finding a \"root\" file.")

(defun find-file-root ()
  "*Open a file as the root user.
   Prepends `find-file-root-prefix' to the selected file name so that it
   maybe accessed via the corresponding tramp method."

  (interactive)
  (require 'tramp)
  (let* ( ;; We bind the variable `file-name-history' locally so we can
	 ;; use a separate history list for "root" files.
	 (file-name-history find-file-root-history)
	 (name (or buffer-file-name default-directory))
	 (tramp (and (tramp-tramp-file-p name)
		     (tramp-dissect-file-name name)))
	 path dir file)

    ;; If called from a "root" file, we need to fix up the path.
    (when tramp
      (setq path (tramp-file-name-localname tramp)
	    dir (file-name-directory path)))

    (when (setq file (read-file-name "Find file (UID = 0): " dir path))
      (find-file (concat find-file-root-prefix file))
      ;; If this all succeeded save our new history list.
      (setq find-file-root-history file-name-history)
      ;; allow some user customization
      (run-hooks 'find-file-root-hook))))

(global-set-key [(control x) (control r)] 'find-file-root)

Modeline

(use-package doom-modeline
:ensure t
:hook (after-init . doom-modeline-mode)
:config
(setq doom-modeline-height 25)
(setq doom-modeline-bar-width 3)
(setq doom-modeline-buffer-file-name-style 'truncate-with-project)
(setq doom-modeline-icon (display-graphic-p))
(setq doom-modeline-major-mode-icon t)
(setq doom-modeline-major-mode-color-icon t)
(setq doom-modeline-buffer-state-icon t)
(setq doom-modeline-buffer-modification-icon t)
(setq doom-modeline-buffer-encoding nil)
(setq doom-modeline-checker-simple-format t)
(setq doom-modeline-env-version t)
(setq doom-modeline-env-load-string "...")
(setq doom-modeline-vcs-max-length 30)

(doom-modeline-def-modeline 'flirres-line
  '(bar matches buffer-info remote-host selection-info)
  '(misc-info major-mode process vcs checker))

(defun setup-custom-doom-modeline ()
  (doom-modeline-set-modeline 'flirres-line 'default))

(add-hook 'doom-modeline-mode-hook 'setup-custom-doom-modeline))

Navigation

Ace-jump-mode to be able to quickly jump around in buffers by specifying letters.

(use-package ace-jump-mode
:bind
("C-." . ace-jump-mode)
:config
(setq ace-jump-mode-gray-background nil))

PDF

(use-package pdf-tools
:config
(pdf-loader-install))

Mac OS

(when (eq system-type 'darwin)
(setq mac-option-modifier 'super))

(use-package exec-path-from-shell
  :ensure t
  :defer 0.1
  :config
  (exec-path-from-shell-initialize))

All The Icons

(use-package all-the-icons)

(use-package all-the-icons-dired
:after all-the-icons
:hook (dired-mode . all-the-icons-dired-mode))

(use-package all-the-icons
  :config (setq all-the-icons-scale-factor 1.0))

(use-package all-the-icons-ivy
  :hook (after-init . all-the-icons-ivy-setup))

(use-package all-the-icons-ibuffer
  :ensure t
  :init (all-the-icons-ibuffer-mode 1))

Dired

Show less information in dired by default. To show more information press ‘C-(‘.

(add-hook 'dired-mode-hook (lambda () (dired-hide-details-mode 1)))

View of subfolders in dired

(use-package dired-subtree
        :ensure t
        :bind (:map dired-mode-map
                    ("i" . dired-subtree-insert)
                    (";" . dired-subtree-remove)
                    ("<tab>" . dired-subtree-toggle)
                    ("<backtab>" . dired-subtree-cycle)))

if there is a Dired buffer displayed in the next window, use its current directory.

(setq dired-dwim-target t)

Yay-Evil steals

Replace the active region just by typing text, just like modern editors

(use-package delsel
  :ensure nil
  :bind
  (:map mode-specific-map
        ("C-g" . minibuffer-keyboard-quit))
  :config (delete-selection-mode +1))

Enable column numbers

(use-package simple
  :ensure nil
  :config (column-number-mode +1))
(use-package autorevert
  :ensure nil
  :defer 0.1
  :config
  (global-auto-revert-mode +1)
  (setq auto-revert-interval 2
        auto-revert-check-vc-info t
        global-auto-revert-non-file-buffers t
        auto-revert-verbose nil))
(use-package eldoc
  :ensure nil
  :diminish eldoc-mode
  :config
  (global-eldoc-mode +1)
  (setq eldoc-idle-delay 0.4))

Terminal

libvterm for an okay functioning terminal emulator experience inside Emacs

(use-package vterm
    :ensure t)

Misc

This is where I keep all random functions and packages that can’t be easily categorized into my other existing categories while not big enough to warrant a new category.

Functions to increment or decrement the number where the pointer is.

  1. Handy when bumping version numbers or doing exploratory programming.
(defun increment-number-at-point-decimal (&optional arg)
  "Increment the number forward from point by 'arg'."
  (interactive "p*")
  (save-excursion
    (save-match-data
      (let (inc-by field-width answer)
        (setq inc-by (if arg arg 1))
        (skip-chars-backward "0123456789")
        (when (re-search-forward "[0-9]+" nil t)
          (setq field-width (- (match-end 0) (match-beginning 0)))
          (setq answer (+ (string-to-number (match-string 0) 10) inc-by))
          (when (< answer 0)
            (setq answer (+ (expt 10 field-width) answer)))
          (replace-match (format (concat "%0" (int-to-string field-width) "d")
                                 answer)))))))

(defun decrement-number-at-point-decimal (&optional arg)
  (interactive "p*")
  (increment-number-at-point-decimal (if arg (- arg) -1)))

Keybindings for inc and dec

(global-set-key (kbd "C-c C-+") 'increment-number-at-point-decimal)
(global-set-key (kbd "C-c C--") 'decrement-number-at-point-decimal)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published