From cf0ae4b20cb8375046266214ba918fb3cc8a2cc0 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sun, 19 Dec 2021 22:11:39 -0600 Subject: Changes and shit --- lisp/+emacs.el | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'lisp/+emacs.el') diff --git a/lisp/+emacs.el b/lisp/+emacs.el index 15e23da..3fe243c 100644 --- a/lisp/+emacs.el +++ b/lisp/+emacs.el @@ -120,7 +120,8 @@ Do this only if the buffer is not visiting a file." (when (version< emacs-version "28") (fset 'yes-or-no-p 'y-or-n-p)) -;; Encoding -- UTF-8 everywhere +;;; Encodings + (setq-default locale-coding-system 'utf-8-unix coding-system-for-read 'utf-8-unix coding-system-for-write 'utf-8-unix @@ -174,8 +175,36 @@ Do this only if the buffer is not visiting a file." (add-hook 'after-save-hook 'executable-make-buffer-file-executable-if-script-p) (add-hook 'minibuffer-setup-hook 'cursor-intangible-mode) +;;; Better-default functions + +(defun +cycle-spacing (&optional n preserve-nl-back mode) + "Negate N argument on `cycle-spacing'. +That is, with a positive N, deletes newlines as well, leaving -N +spaces. If N is negative, it will not delete newlines and leave +N spaces. See docstring of `cycle-spacing' for the meaning of +PRESERVE-NL-BACK and MODE." + (interactive "*p") + (cycle-spacing (- n) preserve-nl-back mode)) + +(defun +save-buffers-quit (&optional arg) + "Silently save each buffer, then kill the current connection. +If the current frame has no client, kill Emacs itself using +`save-buffers-kill-emacs' after confirming with the user. + +With prefix ARG, silently save all file-visiting buffers, then +kill without asking." + (interactive "P") + (save-some-buffers t) + (if (and (not (frame-parameter nil 'client)) + (and (not arg))) + (when (yes-or-no-p "Sure you want to quit? ") + (save-buffers-kill-emacs)) + (server-save-buffers-kill-terminal nil))) + ;;; Bindings +(global-set-key (kbd "C-x C-c") '+save-buffers-quit) +(global-set-key (kbd "M-SPC") '+cycle-spacing) (global-set-key (kbd "M-/") 'hippie-expand) (global-set-key (kbd "M-=") 'count-words) (global-set-key (kbd "C-x C-b") 'ibuffer) -- cgit 1.4.1-21-gabe81