summaryrefslogtreecommitdiff
path: root/gnosis.el
diff options
context:
space:
mode:
authorThanos Apollo <[email protected]>2024-06-28 04:19:33 +0300
committerThanos Apollo <[email protected]>2024-06-28 04:19:33 +0300
commitbe12c1ac92df9f0236915119a275d92c97a34cf1 (patch)
tree2c1b08144de17a920e3ce69b7abd368288b39869 /gnosis.el
parent88d47a200ed6330c605b8049d2ece2a04e0edc0c (diff)
Add gnosis-center-current-line
Diffstat (limited to 'gnosis.el')
-rw-r--r--gnosis.el9
1 files changed, 9 insertions, 0 deletions
diff --git a/gnosis.el b/gnosis.el
index 413e146..8123510 100644
--- a/gnosis.el
+++ b/gnosis.el
@@ -320,6 +320,15 @@ History is disabled."
(defun gnosis-apply-overlays ()
"Apply custom font overlays for syntax highlighting."
+(defun gnosis-center-current-line ()
+ "Center text in the current line ignoring leading spaces."
+ (interactive)
+ (let* ((start (line-beginning-position))
+ (end (line-end-position))
+ (text (string-trim (buffer-substring start end)))
+ (padding (max (/ (- (window-width) (length text)) 2) 0)))
+ (delete-region start end)
+ (insert (make-string padding ? ) text)))
(save-excursion
(goto-char (point-min))
(while (re-search-forward "\\*\\([^*]+\\)\\*" nil t)