2024-11-13 16:10:01 +00:00
|
|
|
;;; Essential configurations
|
|
|
|
(use-package emacs
|
|
|
|
:ensure nil
|
|
|
|
:demand t
|
|
|
|
:config
|
|
|
|
;;;; General settings and common custom functions
|
|
|
|
(setq-default truncate-partial-width-windows nil)
|
2025-01-03 22:26:14 +00:00
|
|
|
(setq column-number-mode t
|
|
|
|
debug-on-error t
|
|
|
|
echo-keystrokes-help t
|
|
|
|
epa-keys-select-method 'minibuffer
|
|
|
|
eval-expression-print-length nil
|
|
|
|
find-file-visit-truename t
|
|
|
|
find-library-include-other-files nil
|
|
|
|
fringe-mode '(1 . 0)
|
|
|
|
global-auto-revert-mode t
|
|
|
|
global-display-line-numbers-mode nil
|
|
|
|
help-window-select t
|
|
|
|
inhibit-startup-message t
|
|
|
|
initial-scratch-message nil
|
|
|
|
kill-do-not-save-duplicates t
|
|
|
|
mode-require-final-newline t
|
|
|
|
next-error-recenter '(4) ; center of the window
|
|
|
|
save-interprogram-paste-before-kill t
|
|
|
|
scroll-error-top-bottom t
|
|
|
|
tramp-connection-timeout (* 60 10))) ; seconds
|
2024-11-13 16:10:01 +00:00
|
|
|
|
2024-11-17 10:11:46 +00:00
|
|
|
(use-package exec-path-from-shell
|
2024-12-12 03:09:58 +00:00
|
|
|
:if (memq (window-system) '(mac ns))
|
2024-11-17 10:11:46 +00:00
|
|
|
:ensure t
|
2024-11-17 16:11:26 +00:00
|
|
|
:demand t
|
2024-11-17 10:11:46 +00:00
|
|
|
:config
|
|
|
|
(exec-path-from-shell-initialize))
|
|
|
|
|
2024-11-13 16:10:01 +00:00
|
|
|
(use-package recentf
|
|
|
|
:ensure nil
|
2024-12-10 10:35:25 +00:00
|
|
|
:hook (elpaca-after-init . recentf-mode)
|
2024-11-13 16:10:01 +00:00
|
|
|
:config
|
|
|
|
(setq recentf-max-saved-items 100)
|
|
|
|
(setq recentf-max-menu-items 25) ; I don't use the `menu-bar-mode', but this is good to know
|
|
|
|
(setq recentf-save-file-modes nil)
|
|
|
|
(setq recentf-keep nil)
|
|
|
|
(setq recentf-auto-cleanup nil)
|
|
|
|
(setq recentf-initialize-file-name-history nil)
|
|
|
|
(setq recentf-filename-handlers nil)
|
|
|
|
(setq recentf-show-file-shortcuts-flag nil))
|
|
|
|
|
2024-12-19 06:11:29 +00:00
|
|
|
(use-package saveplace
|
|
|
|
:ensure nil
|
|
|
|
:hook (elpaca-after-init . save-place-mode)
|
|
|
|
:config
|
|
|
|
(setq save-place-file (locate-user-emacs-file "saveplace")))
|
|
|
|
|
2024-11-13 16:10:01 +00:00
|
|
|
;;;; Built-in bookmarking framework (bookmark.el)
|
|
|
|
(use-package bookmark
|
|
|
|
:ensure nil
|
|
|
|
:commands (bookmark-set bookmark-jump bookmark-bmenu-list)
|
|
|
|
:hook (bookmark-bmenu-mode . hl-line-mode)
|
|
|
|
:config
|
|
|
|
(setq bookmark-use-annotations nil)
|
|
|
|
(setq bookmark-automatically-show-annotations nil)
|
|
|
|
(setq bookmark-fringe-mark nil) ; Emacs 29 to hide bookmark fringe icon
|
|
|
|
;; Write changes to the bookmark file as soon as 1 modification is
|
|
|
|
;; made (addition or deletion). Otherwise Emacs will only save the
|
|
|
|
;; bookmarks when it closes, which may never happen properly
|
|
|
|
;; (e.g. power failure).
|
|
|
|
(setq bookmark-save-flag 1))
|
|
|
|
|
|
|
|
;;;; Registers (register.el)
|
|
|
|
(use-package register
|
|
|
|
:ensure nil
|
|
|
|
:defer t ; its commands are autoloaded, so this will be loaded then
|
|
|
|
:config
|
|
|
|
(setq register-preview-delay 0.8
|
|
|
|
register-preview-function #'register-preview-default)
|
|
|
|
|
|
|
|
(with-eval-after-load 'savehist
|
|
|
|
(add-to-list 'savehist-additional-variables 'register-alist)))
|
|
|
|
|
2024-11-23 04:08:20 +00:00
|
|
|
(use-package files
|
|
|
|
:ensure nil
|
|
|
|
:config
|
|
|
|
(setq confirm-kill-emacs #'y-or-n-p)
|
2024-12-16 16:49:29 +00:00
|
|
|
(setq require-final-newline t)
|
|
|
|
(setq backup-directory-alist ;; Put the ~ files in tmp
|
|
|
|
`(("." . ,(locate-user-emacs-file "temp-files/backups")))))
|
2024-11-23 04:08:20 +00:00
|
|
|
|
2024-11-13 16:10:01 +00:00
|
|
|
;;;; Delete selection
|
|
|
|
(use-package delsel
|
|
|
|
:ensure nil
|
2024-12-10 10:35:25 +00:00
|
|
|
:hook (elpaca-after-init . delete-selection-mode))
|
2024-11-13 16:10:01 +00:00
|
|
|
|
|
|
|
;;;; Tooltips (tooltip-mode)
|
|
|
|
(use-package tooltip
|
|
|
|
:ensure nil
|
2024-12-10 10:35:25 +00:00
|
|
|
:hook (elpaca-after-init . tooltip-mode)
|
2024-11-13 16:10:01 +00:00
|
|
|
:config
|
|
|
|
(setq tooltip-delay 0.5
|
|
|
|
tooltip-short-delay 0.5
|
|
|
|
x-gtk-use-system-tooltips t
|
|
|
|
tooltip-frame-parameters
|
|
|
|
'((name . "tooltip")
|
|
|
|
(internal-border-width . 10)
|
|
|
|
(border-width . 0)
|
|
|
|
(no-special-glyphs . t))))
|
|
|
|
|
|
|
|
;;;; Emacs server (allow emacsclient to connect to running session)
|
|
|
|
(use-package server
|
|
|
|
:ensure nil
|
|
|
|
:defer 1
|
|
|
|
:config
|
|
|
|
(setq server-client-instructions nil)
|
|
|
|
(unless (server-running-p)
|
|
|
|
(server-start)))
|
|
|
|
|
2024-11-17 10:18:41 +00:00
|
|
|
(use-package easy-kill
|
|
|
|
:ensure t
|
|
|
|
:bind
|
|
|
|
("M-w" . easy-kill)) ; re-map kill-ring-save
|
|
|
|
|
2024-12-10 08:21:38 +00:00
|
|
|
;;; Install and use tree-sitter major modes where possible
|
2024-12-16 01:39:38 +00:00
|
|
|
(use-package treesit-auto
|
|
|
|
:ensure t
|
|
|
|
:config
|
|
|
|
(setq treesit-auto-install 'prompt)
|
2024-12-30 06:19:03 +00:00
|
|
|
(treesit-auto-add-to-auto-mode-alist)
|
2024-12-31 20:51:51 +00:00
|
|
|
(global-treesit-auto-mode))
|
2024-12-10 08:21:38 +00:00
|
|
|
|
2024-11-13 16:10:01 +00:00
|
|
|
;;; Mark syntactic constructs efficiently if tree-sitter is available (expreg)
|
2024-12-31 20:51:51 +00:00
|
|
|
(use-package expreg
|
|
|
|
:ensure t
|
|
|
|
:functions (prot/expreg-expand prot/expreg-expand-dwim)
|
2025-01-04 19:17:01 +00:00
|
|
|
:bind ("C-=" . prot/expreg-expand-dwim) ; overrides `mark-sexp'
|
2024-12-31 20:51:51 +00:00
|
|
|
:config
|
|
|
|
(defun prot/expreg-expand (n)
|
|
|
|
"Expand to N syntactic units, defaulting to 1 if none is provided interactively."
|
|
|
|
(interactive "p")
|
|
|
|
(dotimes (_ n)
|
|
|
|
(expreg-expand)))
|
|
|
|
|
|
|
|
(defun prot/expreg-expand-dwim ()
|
|
|
|
"Do-What-I-Mean `expreg-expand' to start with symbol or word.
|
2024-11-13 16:10:01 +00:00
|
|
|
If over a real symbol, mark that directly, else start with a
|
|
|
|
word. Fall back to regular `expreg-expand'."
|
2024-12-31 20:51:51 +00:00
|
|
|
(interactive)
|
|
|
|
(let ((symbol (bounds-of-thing-at-point 'symbol)))
|
|
|
|
(cond
|
|
|
|
((equal (bounds-of-thing-at-point 'word) symbol)
|
|
|
|
(prot/expreg-expand 1))
|
|
|
|
(symbol (prot/expreg-expand 2))
|
|
|
|
(t (expreg-expand))))))
|
2024-11-13 16:10:01 +00:00
|
|
|
|
2024-11-15 08:39:23 +00:00
|
|
|
;;;; Configuration on Mac OS X machine
|
|
|
|
(when (eq system-type 'darwin)
|
|
|
|
(use-package ns-win
|
|
|
|
:ensure nil
|
|
|
|
:config
|
|
|
|
(defun copy-from-osx ()
|
|
|
|
"Make cut and paste work with the OS X clipboard"
|
|
|
|
(shell-command-to-string "pbpaste"))
|
|
|
|
|
|
|
|
(defun paste-to-osx (text &optional push)
|
|
|
|
"Make cut and paste work with the OS X clipboard"
|
|
|
|
(let ((process-connection-type nil))
|
|
|
|
(let ((proc (start-process "pbcopy" "*Messages*" "pbcopy")))
|
|
|
|
(process-send-string proc text)
|
|
|
|
(process-send-eof proc))))
|
|
|
|
|
|
|
|
(setq mac-command-modifier 'meta)
|
|
|
|
(setq mac-option-modifier 'alt)
|
|
|
|
(setq interprogram-cut-function #'paste-to-osx)
|
|
|
|
(setq interprogram-paste-function #'copy-from-osx)
|
|
|
|
;; Work around a bug on OS X where system-name is a fully qualified
|
|
|
|
;; domain name
|
|
|
|
(setq system-name (car (split-string system-name "\\.")))
|
|
|
|
;;; Binaries
|
|
|
|
(setq vc-git-program (or (executable-find "git") "/usr/local/bin/git"))
|
2024-12-31 20:51:51 +00:00
|
|
|
(setq epg-gpg-program (or (executable-find "gpg") "/usr/local/bin/gpg"))))
|
2024-11-15 08:39:23 +00:00
|
|
|
|
2024-11-17 06:59:17 +00:00
|
|
|
(defun vedang/backward-kill-word-or-kill-region (&optional arg)
|
2024-12-30 19:02:45 +00:00
|
|
|
"fancy C-w.
|
2024-11-17 06:59:17 +00:00
|
|
|
If the region is selected, retain the original behaviour, otherwise call
|
|
|
|
`backward-kill-word' instead. ARG is passed to `backward-kill-word'."
|
|
|
|
(interactive "p")
|
|
|
|
(if (region-active-p)
|
|
|
|
(kill-region (region-beginning) (region-end))
|
|
|
|
(backward-kill-word arg)))
|
|
|
|
|
|
|
|
(use-package simple
|
|
|
|
:ensure nil
|
2024-11-23 04:09:17 +00:00
|
|
|
:after vertico ;; so that we can bind to vertico-map
|
2024-11-17 06:59:17 +00:00
|
|
|
:bind
|
|
|
|
;; Rebind `C-w' to work differently based on whether a region is
|
|
|
|
;; active.
|
|
|
|
( :map global-map
|
|
|
|
("C-w" . vedang/backward-kill-word-or-kill-region)
|
|
|
|
:map vertico-map
|
2024-11-23 04:09:17 +00:00
|
|
|
("C-l" . vedang/backward-kill-word-or-kill-region))
|
|
|
|
:hook
|
|
|
|
((before-save . delete-trailing-whitespace)
|
|
|
|
(text-mode . turn-on-visual-line-mode))
|
|
|
|
:config
|
|
|
|
(setq column-number-mode t))
|
2024-11-17 06:59:17 +00:00
|
|
|
|
2024-12-02 04:23:37 +00:00
|
|
|
(use-package helpful
|
|
|
|
:ensure t)
|
|
|
|
|
2024-12-31 20:51:51 +00:00
|
|
|
(use-package indent-tools
|
|
|
|
:ensure t)
|
|
|
|
|
2025-01-04 19:35:02 +00:00
|
|
|
(use-package undo-tree
|
|
|
|
:ensure t
|
|
|
|
:init
|
|
|
|
(global-undo-tree-mode)
|
|
|
|
(blackout 'undo-tree-mode)
|
|
|
|
:bind (("C-z" . undo)
|
|
|
|
("C-S-z" . redo)))
|
|
|
|
|
2024-12-31 20:51:51 +00:00
|
|
|
(use-package key-chord
|
|
|
|
:ensure t
|
|
|
|
:config
|
|
|
|
(key-chord-mode +1)
|
|
|
|
(setq key-chord-one-key-delay 0.185) ; e.g. "jj", default 0.2
|
|
|
|
(setq key-chord-two-keys-delay 0.1) ; e.g. "jk", default 0.1
|
|
|
|
(setq key-chord-safety-interval-backward 0.2) ; default 0.1 is too close to key delays
|
|
|
|
(setq key-chord-safety-interval-forward 0.3) ; default 0.35 causes laggy experience
|
|
|
|
|
|
|
|
(key-chord-define-global "VV" 'split-window-right)
|
|
|
|
(key-chord-define-global "HH" 'split-window-below)
|
|
|
|
(key-chord-define-global "BB" 'switch-to-buffer)
|
|
|
|
(key-chord-define-global "CC" 'recenter)
|
|
|
|
(key-chord-define-global "00" 'delete-window)
|
|
|
|
(key-chord-define-global "11" 'delete-other-windows)
|
|
|
|
(key-chord-define-global "WW" 'rotate-windows)
|
|
|
|
)
|
|
|
|
|
|
|
|
(use-package which-key
|
|
|
|
:ensure t
|
|
|
|
:config
|
|
|
|
(which-key-mode t)
|
|
|
|
(setq which-key-idle-delay 0.5)
|
|
|
|
(setq which-key-sort-order 'which-key-description-order))
|
|
|
|
|
2025-01-02 23:32:50 +00:00
|
|
|
(use-package blackout
|
|
|
|
:ensure t
|
|
|
|
:demand t)
|
|
|
|
|
2024-12-31 20:51:51 +00:00
|
|
|
(provide 'nebkor-essentials)
|