From 3214b7ca9380f41f1f5482c530abd605b9a13502 Mon Sep 17 00:00:00 2001 From: Amin Bandali Date: Mon, 18 Nov 2019 11:50:09 -0500 Subject: [PATCH] emacs: make b/insert-asterism more robust w.r.t. fill-column --- .emacs.d/init.el | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/.emacs.d/init.el b/.emacs.d/init.el index 4f286c0..85aeba0 100644 --- a/.emacs.d/init.el +++ b/.emacs.d/init.el @@ -266,9 +266,21 @@ (previous-line) (insert "\n \n;;; ")) +(defvar b/fill-column 47 + "My custom `fill-column'.") + +(defconst b/asterism "* * *") + (defun b/insert-asterism () + "Insert a centred asterism." (interactive) - (insert "\n\n * * *\n\n")) + (insert + (concat + "\n\n" + (make-string (floor (/ (- b/fill-column (length b/asterism)) 2)) + ?\s) + b/asterism + "\n\n"))) (defun b/no-mouse-autoselect-window () "Conveniently disable `focus-follows-mouse'. @@ -281,9 +293,6 @@ For disabling the behaviour for certain buffers and/or modes." ;;;; C-level customizations -(defvar b/fill-column 47 - "My custom `fill-column'.") - (setq ;; minibuffer enable-recursive-minibuffers t -- 2.20.1