From 5d5060a5da9eee99cdd50bc477e70d3c1d0ef38f Mon Sep 17 00:00:00 2001 From: Kévin Le Gouguec Date: Wed, 17 Mar 2021 12:48:00 +0100 Subject: Commit a collection of tweaks to Emacs config --- .emacs | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) (limited to '.emacs') diff --git a/.emacs b/.emacs index 7d3e54d..2b6c443 100644 --- a/.emacs +++ b/.emacs @@ -96,6 +96,22 @@ (set-variable 'tab-width new-width) (message "changed from %s to %s" old-width new-width))) +(defun my/center-window (text-width) + (interactive + (list (cond + ;; Explicit length. + ((integerp current-prefix-arg) + current-prefix-arg) + ;; C-u. + ((and (listp current-prefix-arg) current-prefix-arg) + nil) + ;; Default. + (80)))) + (let ((margin-width (when text-width + (/ (- (window-width) text-width) 2)))) + ;; Only set left margin, so that long lines are not truncated. + (set-window-margins nil margin-width))) + (defun my/kill (stuff) (kill-new stuff) (message stuff)) @@ -149,7 +165,8 @@ (my/define-prefix-command my/display-map "Keymap for display-related commands." - '(("t" toggle-truncate-lines) + '(("c" my/center-window) + ("t" toggle-truncate-lines) ("v" visual-line-mode))) (my/define-prefix-command my/editing-map @@ -177,7 +194,8 @@ (my/define-prefix-command my/manual-map "Keymap for reading manuals." '(("i" info-display-manual) - ("m" man))) + ("m" man) + ("s" shortdoc-display-group))) (my/define-prefix-command my/project-map "Keymap for project-related commands." @@ -274,6 +292,8 @@ ;; in stone, and I would miss out on future updates by Magit. (add-hook 'git-commit-setup-hook 'git-commit-turn-on-flyspell) +(setq magit-process-finish-apply-ansi-colors t) + (defun my/revision-at-point () (cond ((derived-mode-p 'magit-mode) @@ -490,4 +510,15 @@ (setq-default paragraph-start (concat "[ ]*- \\|" paragraph-start)) +(defun my/screenshot (output) + (interactive + (list + (let ((default (format-time-string "/tmp/Emacs-Screenshot-%F-%T.pdf"))) + (read-file-name (format-prompt "Output?" default) nil default)))) + (let ((data (x-export-frames)) + (buf (find-file output))) + (insert data) + (save-buffer) + (kill-buffer buf))) + ;; TODO: decruftify mode-line (e.g. remove superflous parens) -- cgit v1.2.3