2022-04-22 04:25:29 +00:00
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Packages related
2022-04-22 04:48:52 +00:00
( require 'package ) ; this goes in chemacs2 init -- DO NOT UNCOMMENT
( add-to-list 'package-archives ' ( " melpa " . " https://melpa.org/packages/ " ) t ) ; this goes in chemacs2 init -- DO NOT UNCOMMENT
( package-initialize ) ; this goes in chemacs2 init -- DO NOT UNCOMMENT
2022-04-22 04:25:29 +00:00
( add-to-list 'package-selected-packages
2022-04-25 22:51:41 +00:00
' ( magit helpful helm helm-org helm-ls-git projectile helm-projectile dired-rainbow dired-rainbow-listing dired-single dash s origami diminish persp-mode persp-mode-projectile-bridge modus-themes transpose-frame use-package )
2022-04-22 04:25:29 +00:00
)
( require 'use-package )
2022-04-22 21:03:15 +00:00
; helper functions
( require 'subr-x )
( setq kmn/is-termux
( string-suffix-p " Android " ( string-trim ( shell-command-to-string " uname -a " ) ) ) )
2022-04-23 19:35:42 +00:00
; ensure elisp plugins are compiled
( require 'dash )
( require 'f )
( defun was-compiled-p ( path )
" Does the directory at PATH contain any .elc files? "
( --any-p ( f-ext? it " elc " ) ( f-files path ) ) )
( defun ensure-packages-compiled ( )
" If any packages installed with package.el aren't compiled yet, compile them. "
( --each ( f-directories package-user-dir )
( unless ( was-compiled-p it )
( byte-recompile-directory it 0 ) ) ) )
( ensure-packages-compiled )
2022-04-23 17:10:05 +00:00
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; backups
( defconst kmn/backup-dir
( expand-file-name " backups/ " user-emacs-directory ) )
( unless ( file-exists-p kmn/backup-dir )
( make-directory kmn/backup-dir ) )
( setq backup-directory-alist ` ( ( " .* " . , kmn/backup-dir ) ) )
( setq auto-save-list-file-prefix kmn/backup-dir )
( setq auto-save-file-name-transforms
` ( ( " \\ (?:[^/]*/ \\ )* \\ (.* \\ ) " , ( concat kmn/backup-dir " \\ 1 " ) t ) ) )
( setq backup-by-copying t ) ; safest form of backup file creation
; Config backups so we have *more*, not less
( setq delete-old-versions t
kept-new-versions 1
kept-old-versions 3
version-control t
)
2022-04-22 21:03:15 +00:00
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; dired adjustments
( use-package dired-rainbow
:defer 4
:config
( dired-rainbow-define-chmod directory " #0074d9 " " d.* " )
( dired-rainbow-define html " #eb5286 "
( " css " " less " " sass " " scss " " htm " " html " " jhtm " " mht "
" eml " " mustache " " xhtml " ) )
( dired-rainbow-define xml " #f2d024 "
( " xml " " xsd " " xsl " " xslt " " wsdl " " bib " " json " " msg "
" pgn " " rss " " yaml " " yml " " rdata " " sln " " csproj "
2022-04-25 19:54:47 +00:00
" meta " " unity " " tres " " tscn " " import " " godot " ) )
2022-04-22 21:03:15 +00:00
( dired-rainbow-define document " #9561e2 "
( " docm " " doc " " docx " " odb " " odt " " pdb " " pdf " " ps "
" rtf " " djvu " " epub " " odp " " ppt " " pptx " " xls " " xlsx "
" vsd " " vsdx " " plantuml " ) )
( dired-rainbow-define markdown " #4dc0b5 "
( " org " " org_archive " " etx " " info " " markdown " " md "
" mkd " " nfo " " pod " " rst " " tex " " texi " " textfile " " txt " ) )
( dired-rainbow-define database " #6574cd "
( " xlsx " " xls " " csv " " accdb " " db " " mdb " " sqlite " " nc " ) )
( dired-rainbow-define media " #de751f "
( " mp3 " " mp4 " " MP3 " " MP4 " " avi " " mpeg " " mpg " " flv "
" ogg " " mov " " mid " " midi " " wav " " aiff " " flac " " mkv " ) )
( dired-rainbow-define image " #f66d9b "
( " tiff " " tif " " cdr " " gif " " ico " " jpeg " " jpg " " png "
" psd " " eps " " svg " ) )
( dired-rainbow-define log " #c17d11 "
( " log " " log.1 " " log.2 " " log.3 " " log.4 " " log.5 " " log.6 "
" log.7 " " log.8 " " log.9 " ) )
( dired-rainbow-define shell " #f6993f "
( " awk " " bash " " bat " " fish " " sed " " sh " " zsh " " vim " ) )
( dired-rainbow-define interpreted " #38c172 "
( " py " " ipynb " " hy " " rb " " pl " " t " " msql " " mysql "
" pgsql " " sql " " r " " clj " " cljs " " cljc " " cljx " " edn "
" scala " " js " " jsx " " lua " " fnl " " gd " ) )
( dired-rainbow-define compiled " #6cb2eb "
( " asm " " cl " " lisp " " el " " c " " h " " c++ " " h++ " " hpp "
" hxx " " m " " cc " " cs " " cp " " cpp " " go " " f " " for " " ftn "
" f90 " " f95 " " f03 " " f08 " " s " " rs " " active " " hs "
" pyc " " java " ) )
( dired-rainbow-define executable " #8cc4ff "
( " com " " exe " " msi " ) )
( dired-rainbow-define compressed " #51d88a "
( " 7z " " zip " " bz2 " " tgz " " txz " " gz " " xz " " z " " Z " " jar "
" war " " ear " " rar " " sar " " xpi " " apk " " xz " " tar " " rar " ) )
( dired-rainbow-define packaged " #faad63 "
( " deb " " rpm " " apk " " jad " " jar " " cab " " pak " " pk3 " " vdf "
" vpk " " bsp " ) )
( dired-rainbow-define encrypted " #f2d024 "
( " gpg " " pgp " " asc " " bfe " " enc " " signature " " sig " " p12 "
" pem " ) )
( dired-rainbow-define fonts " #f6993f "
( " afm " " fon " " fnt " " pfb " " pfm " " ttf " " otf " " woff "
" woff2 " " eot " ) )
( dired-rainbow-define partition " #e3342f "
( " dmg " " iso " " bin " " nrg " " qcow " " toast " " vcd " " vmdk "
" bak " ) )
( dired-rainbow-define vc " #6cb2eb "
( " git " " gitignore " " gitattributes " " gitmodules " ) )
( dired-rainbow-define config " #5040e2 "
( " cfg " " conf " ) )
( dired-rainbow-define certificate " #6cb2eb "
( " cer " " crt " " pfx " " p7b " " csr " " req " " key " ) )
( dired-rainbow-define junk " #7F7D7D "
( " DS_Store " " projectile " ) )
( dired-rainbow-define icloud " #e3342f " ( " icloud " ) )
( dired-rainbow-define-chmod executable-unix " #38c172 " " -.*x.* " )
)
; use single buffer for nav damnit
( require 'dired-single )
( defun my-dired-init ( )
" Bunch of stuff to run for dired, either immediately or when it's
loaded. "
;; <add other stuff here>
( define-key dired-mode-map [ remap dired-find-file ]
'dired-single-buffer )
( define-key dired-mode-map [ remap dired-mouse-find-file-other-window ]
'dired-single-buffer-mouse )
( define-key dired-mode-map [ remap dired-up-directory ]
'dired-single-up-directory ) )
;; if dired's already loaded, then the keymap will be bound
( if ( boundp 'dired-mode-map )
;; we're good to go; just add our bindings
( my-dired-init )
;; it's not loaded yet, so add our bindings to the load-hook
( add-hook 'dired-load-hook 'my-dired-init ) )
; icons / colors / line tunes
( add-hook 'dired-mode-hook
( lambda ( )
( interactive )
( when kmn/is-termux ( all-the-icons-dired-mode 1 ) )
( hl-line-mode 1 ) ) )
( add-to-list 'load-path ( expand-file-name " dired-rainbow-listing " user-emacs-directory ) )
( require 'dired-rainbow-listing )
( add-hook 'dired-mode-hook #' dired-rainbow-listing-mode )
2022-04-22 04:25:29 +00:00
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2022-04-22 21:03:15 +00:00
; origami config
( use-package origami
:demand
:config
( define-prefix-command 'origami-mode-map )
( define-key ctl-x-map ( kbd " z " ) 'origami-mode-map )
( global-origami-mode )
:bind
( :map origami-mode-map
( " o " . origami-open-node )
( " O " . origami-open-node-recursively )
( " c " . origami-close-node )
( " C " . origami-close-node-recursively )
( " a " . origami-toggle-node )
( " t " . origami-recursively-toggle-node )
( " R " . origami-open-all-nodes )
( " M " . origami-close-all-nodes )
( " v " . origami-show-only-node )
( " k " . origami-previous-fold )
( " j " . origami-forward-fold )
( " x " . origami-reset ) ) )
2022-04-22 04:25:29 +00:00
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Setup global keys
2022-04-23 21:36:44 +00:00
( require 'transpose-frame )
2022-04-22 04:25:29 +00:00
( cua-mode 1 )
2022-04-23 17:18:39 +00:00
( windmove-default-keybindings 'meta )
2022-04-22 04:25:29 +00:00
( global-set-key ( kbd " <escape> " ) 'keyboard-escape-quit )
2022-04-23 21:36:44 +00:00
( global-set-key ( kbd " M-m " ) 'menu-bar-open )
2022-04-22 04:25:29 +00:00
( global-set-key ( kbd " <M-f4> " ) 'delete-frame )
( global-set-key ( kbd " C-x C-z " ) nil )
2022-04-23 21:36:44 +00:00
( global-set-key ( kbd " C-g " ) 'goto-line )
( global-set-key ( kbd " C-c u " ) 'toggle-truncate-lines )
2022-04-23 15:56:10 +00:00
( global-set-key ( kbd " C-o " ) 'find-file )
( global-set-key ( kbd " C-k " ) 'dired )
2022-04-23 14:21:53 +00:00
( global-set-key ( kbd " C-c w " )
( lambda ( )
( interactive )
( whitespace-mode )
( whitespace-newline-mode )
)
)
2022-04-22 04:25:29 +00:00
2022-04-23 21:36:44 +00:00
( global-set-key ( kbd " M-k " ) 'delete-window )
( global-set-key ( kbd " M- \" " ) 'split-window-below )
( global-set-key ( kbd " M-# " ) 'split-window-right )
( global-set-key ( kbd " M-. " ) 'rotate-frame-clockwise )
( global-set-key ( kbd " M-, " ) 'rotate-frame-anticlockwise )
2022-04-22 04:25:29 +00:00
;; Lookup the current symbol at point. C-c C-d is a common keybinding
;; for this in lisp modes.
2022-04-23 21:36:44 +00:00
( global-set-key ( kbd " M-h " ) 'describe-bindings )
2022-04-22 04:25:29 +00:00
( global-set-key ( kbd " C-c C-d " ) #' helpful-at-point )
2022-04-23 15:49:04 +00:00
; more vscode/gui styled find/replace
( defun query-replace-region-or-from-top ( )
" If marked, query-replace for the region, else for the whole buffer (start from the top) "
( interactive )
( progn
( let ( ( orig-point ( point ) ) )
( if ( use-region-p )
( call-interactively 'query-replace )
( save-excursion
( goto-char ( point-min ) )
( call-interactively 'query-replace ) ) )
( message " Back to old point. " )
( goto-char orig-point ) ) ) )
( bind-key* " M-% " 'query-replace-region-or-from-top )
( global-set-key ( kbd " C-h " ) 'query-replace-region-or-from-top )
; more vscode/gui styled find/replace
( global-set-key ( kbd " C-s " ) 'isearch-forward )
( global-set-key ( kbd " C-f " ) 'isearch-forward )
2022-04-22 04:25:29 +00:00
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Set some global config
( setq inhibit-splash-screen t ) ; why do you need to tell me things i know by default
( setq-default tab-width 4 ) ; sanity!
( electric-indent-mode 0 ) ; return should NOT fuck with the indentation of the previous line
2022-04-23 16:14:37 +00:00
2022-04-22 04:25:29 +00:00
;; make typing delete/overwrites selected text
( delete-selection-mode 1 )
2022-04-23 16:14:37 +00:00
2022-04-22 04:25:29 +00:00
;; UTF-8 as default encoding
( set-default-coding-systems 'utf-8 )
( set-language-environment " UTF-8 " )
( set-default-coding-systems 'utf-8-unix )
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; set font for emoji -- DOES NOT WORK ON MOBILE
( when ( eq system-type 'windows-nt )
( set-fontset-font
t
' ( #x1f300 . #x1fad0 )
( cond
( ( member " Noto Color Emoji " ( font-family-list ) ) " Noto Color Emoji " )
( ( member " Noto Emoji " ( font-family-list ) ) " Noto Emoji " )
( ( member " Segoe UI Emoji " ( font-family-list ) ) " Segoe UI Emoji " )
( ( member " Symbola " ( font-family-list ) ) " Symbola " )
( ( member " Apple Color Emoji " ( font-family-list ) ) " Apple Color Emoji " ) )
;; Apple Color Emoji should be before Symbola, but Richard Stallman skum disabled it.
;; GNU Emacs Removes Color Emoji Support on the Mac
;; http://ergoemacs.org/misc/emacs_macos_emoji.html
;;
)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; line numbers
; find major mode : M-x eval-expression [enter] major-mode
( require 'display-line-numbers )
( defcustom display-line-numbers-exempt-modes ' ( org-mode org-agenda-mode )
" Major modes on which to disable the linum mode, exempts them from global requirement "
:group 'display-line-numbers
:type 'list
:version " green " )
( defun display-line-numbers--turn-on ( )
" turn on line numbers but excempting certain majore modes defined in `display-line-numbers-exempt-modes' "
( if ( and
( not ( member major-mode display-line-numbers-exempt-modes ) )
( not ( minibufferp ) ) )
( display-line-numbers-mode ) ) )
( global-display-line-numbers-mode )
2022-04-23 14:21:53 +00:00
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; whitespace
( progn
;; Make whitespace-mode with very basic background coloring for whitespaces.
;; http://xahlee.info/emacs/emacs/whitespace-mode.html
( setq whitespace-style ( quote ( face spaces tabs newline space-mark tab-mark newline-mark ) ) )
;; Make whitespace-mode and whitespace-newline-mode use “¶” for end of line char and “▷” for tab.
( setq whitespace-display-mappings
;; all numbers are unicode codepoint in decimal. e.g. (insert-char 182 1)
' (
( space-mark 32 [ 183 ] [ 46 ] ) ; SPACE 32 「 」, 183 MIDDLE DOT 「·」, 46 FULL STOP 「.」
( newline-mark 10 [ 8629 10 ] ) ; LINE FEED,
( tab-mark 9 [ 8594 9 ] [ 92 9 ] ) ; tab
) ) )
2022-04-22 04:25:29 +00:00
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; modus-themes setup and enable
( use-package modus-themes
:ensure
:init
( setq modus-themes-region ' ( no-extend )
modus-themes-fringes 'subtle
modus-themes-scale-headings t
)
( modus-themes-load-themes )
:config
( modus-themes-load-vivendi )
)
2022-04-25 19:23:09 +00:00
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; helm
( setq completion-styles ' ( flex ) )
2022-04-25 19:54:47 +00:00
2022-04-25 19:23:09 +00:00
( require 'helm-config )
2022-04-25 19:54:47 +00:00
( require 'helm-color )
( require 'helm-ls-git )
( require 'helm-org )
2022-04-25 19:23:09 +00:00
( helm-mode 1 )
2022-04-25 19:54:47 +00:00
( helm-autoresize-mode 1 )
( global-set-key ( kbd " C-x C-d " ) 'helm-browse-project )
2022-04-25 19:23:09 +00:00
( define-key global-map [ remap find-file ] 'helm-find-files )
( define-key global-map [ remap occur ] 'helm-occur )
( define-key global-map [ remap list-buffers ] 'helm-buffers-list )
( define-key global-map [ remap dabbrev-expand ] 'helm-dabbrev )
( define-key global-map [ remap execute-extended-command ] 'helm-M-x )
( define-key global-map [ remap apropos-command ] 'helm-apropos )
( unless ( boundp 'completion-in-region-function )
( define-key lisp-interaction-mode-map [ remap completion-at-point ] 'helm-lisp-completion-at-point )
( define-key emacs-lisp-mode-map [ remap completion-at-point ] 'helm-lisp-completion-at-point ) )
( add-hook 'kill-emacs-hook #' ( lambda ( ) ( and ( file-exists-p " $CONF_FILE " ) ( delete-file " $CONF_FILE " ) ) ) )
2022-04-25 19:54:47 +00:00
( add-to-list 'helm-completing-read-handlers-alist ' ( org-capture . helm-org-completing-read-tags ) )
( add-to-list 'helm-completing-read-handlers-alist ' ( org-set-tags . helm-org-completing-read-tags ) )
2022-04-25 20:20:00 +00:00
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; projectile
( projectile-mode +1 )
( define-key projectile-mode-map ( kbd " C-c j " ) 'projectile-command-map )
2022-04-25 23:11:06 +00:00
( setq projectile-mode-line-function ' ( lambda ( ) ( format " [%s] " ( projectile-project-name ) ) ) )
( setq projectile-project-search-path ' ( " ~/../src/ " ) )
2022-04-25 22:41:50 +00:00
( require 'helm-projectile )
( helm-projectile-on )
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; persp-mode
( setq persp-auto-resume-time 0.25 )
( setq persp-add-buffer-on-find-file nil )
( with-eval-after-load " persp-mode-autoloads "
( setq wg-morph-on nil ) ;; switch off animation
( setq persp-autokill-buffer-on-remove 'kill-weak )
( add-hook 'window-setup-hook #' ( lambda ( ) ( persp-mode 1 ) ) ) )
( with-eval-after-load " persp-mode-projectile-bridge-autoloads "
( add-hook 'persp-mode-projectile-bridge-mode-hook
#' ( lambda ( )
( if persp-mode-projectile-bridge-mode
( persp-mode-projectile-bridge-find-perspectives-for-all-buffers )
( persp-mode-projectile-bridge-kill-perspectives ) ) ) )
( add-hook 'after-init-hook
#' ( lambda ( )
( persp-mode-projectile-bridge-mode 1 ) )
t ) )
2022-04-25 20:20:00 +00:00
2022-04-25 23:11:06 +00:00
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; diminish config
; https://melpa.org/#/manage-minor-mode
; M-x: manage-minor-mode
;
; M-x: describe-mode
( require 'diminish )
( diminish 'rainbow-mode ) ; Hide lighter from mode-line
( diminish 'org-habit ) ; im well aware i have org-habit enabled globally. thanks
( diminish 'helm-mode )
( diminish 'eldoc-mode )
2022-04-25 18:43:48 +00:00
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; flyspell
;(require 'flyspell)
;(setenv "LANG" "en_US")
;(setenv "DICPATH" "~/.emacs.d.profiles/common/dictionaries") ; https://github.com/wooorm/dictionaries
;(setq ispell-program-name "hunspell")
;(setq ispell-dictionary "en")
;
;(defun flyspell-on-for-buffer-type ()
; "Enable Flyspell appropriately for the major mode of the current buffer. Uses `flyspell-prog-mode' for modes derived from `prog-mode', so only strings and comments get checked. All other buffers get `flyspell-mode' to check all text. If flyspell is already enabled, does nothing."
; (interactive)
; (if (not (symbol-value flyspell-mode)) ; if not already on
; (progn
; (if (derived-mode-p 'prog-mode)
; (progn
; (message "Flyspell on (code)")
; (flyspell-prog-mode))
; ;; else
; (progn
; (message "Flyspell on (text)")
; (flyspell-mode 1)))
; ;; I tried putting (flyspell-buffer) here but it didn't seem to work
; )))
;
; (defun flyspell-toggle ()
; "Turn Flyspell on if it is off, or off if it is on. When turning on, it uses `flyspell-on-for-buffer-type' so code-vs-text is handled appropriately."
; (interactive)
; (if (symbol-value flyspell-mode)
; (progn ; flyspell is on, turn it off
; (message "Flyspell off")
; (flyspell-mode -1))
; ; else - flyspell is off, turn it on
; (flyspell-on-for-buffer-type)))
;
;(add-hook 'find-file-hook 'flyspell-on-for-buffer-type)
;(add-hook 'text-mode-hook 'flyspell-on-for-buffer-type)
;(add-hook 'after-change-major-mode-hook 'flyspell-on-for-buffer-type)