;;; Code:
#+END_SRC
-* Initial
+* Load libraries
+Libraries Not from the package manager
#+BEGIN_SRC emacs-lisp
(dolist (path '("sedit-mouse/" "themes/" "re/"))
(add-to-list 'load-path (concat user-emacs-directory path)))
(dolist (file '(pass-alike eng-paper-theme sedit-mouse))
(require file))
-
+#+END_SRC
+* OS specific stuff
+#+BEGIN_SRC emacs-lisp
(setq w32-recognize-altgr 'nil)
(unless (equal system-type 'windows-nt)
(find-alternate-file (concat "/sudo:root@localhost:" buffer-file-name)))))
#+END_SRC
-* Packages
-Add melpa, and reduce the declarations by setting defaults
+* Add melpa, and reduce the declarations by setting defaults
#+BEGIN_SRC emacs-lisp
(require 'package)
:hook
(corfu-mode . corfu-popupinfo-mode)
:custom
- (corfu-popupinfo-delay '(1.0 . 0.01)) ; start with M-t, fast refresh once on
+ (corfu-popupinfo-delay '(1.0 . 0.01)) ; start after one second, fast refresh once on
(corfu-popupinfo-hide nil)
:config
(corfu-popupinfo-mode))
(global-page-break-lines-mode))
#+END_SRC
* AucTeX and pdftools
-Make AucTeX use pdftools, prompt for master file, synctex, etc.
+Make AucTeX use pdftools, prompt for master file, synctex, etc. Be sure to run =pdf-tools-install= before first use.
#+BEGIN_SRC emacs-lisp
(use-package pdf-tools)
(use-package csv-mode
:config
(add-hook 'csv-mode-hook 'csv-align-mode))
-
#+END_SRC
* Markdown Mode
Make markdown act more like org when I'm forced to use it
(keymap-global-set "<remap> <upcase-word>" #'upcase-dwim) ; M-u
#+END_SRC
* Tabs
+I want *TABS*, not spaces, dammit. Globally overwrite the tab key to insert the tab character. This makes it so that many things (completion) will have to be triggered with =C-i= instead, but I don't think it's necessarily bad to have things like that on a control combo instead of overloading the tab key at the expense of being able to actually insert tabs.
#+BEGIN_SRC emacs-lisp
;; Tabs
(setq-default indent-tabs-mode t
history-delete-duplicates t
disabled-command-function nil
save-interprogram-paste-before-kill t
- confirm-kill-processes nil
- recenter-positions '(2 middle -3))
+ confirm-kill-processes nil)
+
+(keymap-global-set "C-x M-f" #'find-file-at-point)
+(keymap-global-set "C-x C-b" #'buffer-menu)
+(keymap-global-set "C-x M-b" #'buffer-menu-other-window)
+(keymap-global-set "C-x k" #'kill-current-buffer)
+(keymap-global-set "C-x K" #'kill-buffer)
+#+END_SRC
+* Recentering and page-by-page navigation
+#+BEGIN_SRC emacs-lisp
+(setq recenter-positions '(2 middle -3))
(defun re/recenter-advice (&rest _)
"Recenter to page start."
(keymap-global-set "C-x C-p" #'backward-page)
(keymap-global-set "<next>" #'forward-page)
(keymap-global-set "<prior>" #'backward-page)
-
+#+END_SRC
+* Macro to open something in its own named frame
+Start a repl in a new frame, open dired in a new frame, etc. etc.
+#+BEGIN_SRC
(defmacro re/open-with-new-frame (frname function)
"Run the function in its own named frame."
`(progn
(select-frame (make-frame '((name . ,(eval frname)))))
(call-interactively ,function)))
-
-(keymap-global-set "C-x M-f" #'find-file-at-point)
-(keymap-global-set "C-x C-b" #'buffer-menu)
-(keymap-global-set "C-x M-b" #'buffer-menu-other-window)
-(keymap-global-set "C-x k" #'kill-current-buffer)
-(keymap-global-set "C-x K" #'kill-buffer)
#+END_SRC
* Motion
#+BEGIN_SRC emacs-lisp
(keymap-global-set "C-," #'previous-buffer)
(keymap-global-set "C-<tab>" (lambda () (interactive) (switch-to-buffer nil))) ; toggle last two buffers
(keymap-global-set "<mouse-4>" #'previous-buffer) ; Back button
+(keymap-global-set "<mouse-5>" #'next-buffer) ; Forward button
+;; Disable M-mouse for window manager bindings
(keymap-global-unset "M-<down-mouse-1>")
(keymap-global-unset "M-<drag-mouse-1>")
(keymap-global-unset "M-<mouse-1>")
* Search
#+BEGIN_SRC emacs-lisp
;; Search
-(defun re/isearch-forward-use-region ()
- "Search text in region if active, otherwise normal forward search."
- (interactive)
+(defun re/add-region-to-search-ring ()
(when (use-region-p)
(add-to-history 'search-ring
(buffer-substring (region-beginning) (region-end)))
- (deactivate-mark))
+ (deactivate-mark)))
+
+(defun re/isearch-forward-use-region ()
+ "Search text in region if active, otherwise normal forward search."
+ (interactive)
+ (re/add-region-to-search-ring)
(isearch-forward))
(keymap-global-set "C-s" #'re/isearch-forward-use-region)
(defun re/isearch-backward-use-region ()
"Search text in region if active, otherwise normal backward search."
(interactive)
- (when (use-region-p)
- (add-to-history 'search-ring
- (buffer-substring (region-beginning) (region-end)))
- (deactivate-mark))
+ (re/add-region-to-search-ring)
(isearch-backward))
(keymap-global-set "C-r" #'re/isearch-backward-use-region)
#+END_SRC
* Cleanup on write
#+BEGIN_SRC emacs-lisp
- (defun re/flush-extra-lines ()
- "Change all groups of blank lines to 1 blank line."
- (interactive)
- (save-excursion (mark-whole-buffer)
- (replace-regexp "^\n+"
- "\n"
- nil
- (region-beginning)
- (region-end))))
- ;; Cleanup on write
- (setq require-final-newline t)
- (add-hook 'before-save-hook #'re/flush-extra-lines)
- (add-hook 'before-save-hook #'whitespace-cleanup)
- (add-hook 'after-save-hook #'executable-make-buffer-file-executable-if-script-p)
+(defun re/flush-extra-lines ()
+ "Change all groups of blank lines to 1 blank line."
+ (interactive)
+ (save-excursion (mark-whole-buffer)
+ (replace-regexp "^\n+"
+ "\n"
+ nil
+ (region-beginning)
+ (region-end))))
+
+(setq require-final-newline t)
+(add-hook 'before-save-hook #'re/flush-extra-lines)
+(add-hook 'before-save-hook #'whitespace-cleanup)
+(add-hook 'after-save-hook #'executable-make-buffer-file-executable-if-script-p)
#+END_SRC
* Control
#+BEGIN_SRC emacs-lisp
(keymap-global-set "C-x S" (lambda () (interactive) (save-some-buffers t))) ; don't ask
(keymap-global-set "C-x c" #'delete-frame) ; delete a frame without asking about saving files
#+END_SRC
-* Versioning and Backups
+* Version-control mode
#+BEGIN_SRC emacs-lisp
;; Versioning and Backups
(defun re/vc-clone ()
(dir (read-string "Local Dir: " (file-name-base url))))
(vc-git-clone url dir nil)))
+(keymap-global-set "C-x v C" #'re/vc-clone)
+
(defun re/vc-show-branches (&optional arg)
"Display all Git branches in a separate buffer.
Remotes as well when arg."
(goto-char (point-min))
(special-mode)))
+(keymap-global-set "C-x v b b" #'re/vc-show-branches)
+
(defun re/vc-fetch (&optional arg)
"Interactively fetch with vc-mode.
Allows separate fetch in addition to pull. Only care about git.
(goto-char (point-min))
(special-mode)))
-(setq vc-make-backup-files nil
- vc-handled-backends '(Git)
- vc-git-diff-switches '("--patch-with-stat" "--histogram")
- vc-git-log-switches '("--oneline" "--all" "--graph")
- vc-git-log-edit-summary-target-len 50
- vc-git-log-edit-summary-max-len 70
- vc-find-revision-no-save t)
+(keymap-global-set "C-x v f" #'re/vc-fetch)
(setq vc-git-root-log-format
`("%d %h %ai %an: %s"
(3 'change-log-name)
(4 'change-log-date))))
+(add-hook 'vc-dir-mode-hook
+ (lambda ()
+ (keymap-set vc-dir-mode-map "b b" #'re/vc-show-branches)
+ (keymap-set vc-dir-mode-map "f" #'re/vc-fetch)))
+
+(setq vc-make-backup-files nil
+ vc-handled-backends '(Git)
+ vc-git-diff-switches '("--patch-with-stat" "--histogram")
+ vc-git-log-switches '("--oneline" "--all" "--graph")
+ vc-git-log-edit-summary-target-len 50
+ vc-git-log-edit-summary-max-len 70
+ vc-find-revision-no-save t)
+#+END_SRC
+* Backups
+#+BEGIN_SRC emacs-lisp
+
(setq backup-directory-alist `((".*" . "~/emacs-backups/"))
backup-by-copying t
delete-old-versions t
kept-new-versions 5
kept-old-versions 5)
-
-(keymap-global-set "C-x v C" #'re/vc-clone)
-(keymap-global-set "C-x v b b" #'re/vc-show-branches)
-(keymap-global-set "C-x v f" #'re/vc-fetch)
-
-(add-hook 'vc-dir-mode-hook
- (lambda ()
- (keymap-set vc-dir-mode-map "b b" #'re/vc-show-branches)
- (keymap-set vc-dir-mode-map "f" #'re/vc-fetch)))
#+END_SRC
* Any Lisp Repl
#+BEGIN_SRC emacs-lisp
(re/balance-and-eval-sexp #'eval-print-last-sexp)))))
#+END_SRC
* IELM
+Rarely used, but nice to have when I want it.
#+BEGIN_SRC emacs-lisp
;; IELM
(add-hook 'ielm-mode-hook
;; Eshell
(keymap-global-set "C-c e" #'eshell)
+(defun eshell-quit-or-delete-char (arg)
+ "Delete char if at one, quit eshell if on empty prompt.
+Stolen from https://depp.brause.cc/dotemacs"
+ (interactive "p")
+ (if (and (eolp) (looking-back eshell-prompt-regexp 0 t))
+ (eshell-life-is-too-much)
+ (delete-char arg)))
+
(add-hook 'eshell-mode-hook
(lambda ()
(keymap-set eshell-mode-map "C-d" #'eshell-quit-or-delete-char)
(keymap-set eshell-mode-map
"]"
(re/balance-and-eval-sexp eval-function)))))
-
-(defun eshell-quit-or-delete-char (arg)
- "Delete char if at one, quit eshell if on empty prompt.
-Stolen from https://depp.brause.cc/dotemacs"
- (interactive "p")
- (if (and (eolp) (looking-back eshell-prompt-regexp 0 t))
- (eshell-life-is-too-much)
- (delete-char arg)))
#+END_SRC
* C-mode
#+BEGIN_SRC emacs-lisp
#+BEGIN_SRC emacs-lisp
;; Auto-Revert
(global-auto-revert-mode t)
-(setq global-auto-revert-non-file-buffers t
- global-auto-revert-ignore-modes '(Buffer-menu-mode))
+(setq global-auto-revert-non-file-buffers t)
#+END_SRC
* Crash HandliĆ
#+BEGIN_SRC emacs-lisp
_ -)
(define-skeleton skel-org-block
- "Add an elisp source block to an org file."
+ "Add a source block to an org file."
""
"#+BEGIN_SRC"
\n
\n
"#+END_SRC")
-(setq abbrev-file-name (expand-file-name "abbrev_defs" user-emacs-directory)
- save-abbrevs 'silently)
+(setq save-abbrevs 'silently)
(dolist (hook '(org-mode-hook howm-mode-hook))
(add-hook hook #'abbrev-mode))
#+END_SRC
* Customization Framework
+Disable it by making it save to a temp file (stolen from prot)
#+BEGIN_SRC emacs-lisp
-;; Customization framework
-;; Disable by making a temp file (stolen from prot)
(setq custom-file (make-temp-file "emacs-custom-"))
-
+#+END_SRC
+* Footer
+#+BEGIN_SRC emacs-lisp
;;; config.el ends here
#+END_SRC