emacs: make b/insert-asterism more robust w.r.t. fill-column
[~bandali/configs] / .emacs.d / init.el
index 4f286c0..85aeba0 100644 (file)
   (previous-line)
   (insert "\n\f\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