Make things a bit more configurable
This commit is contained in:
parent
1db2c7bff6
commit
f1a1c4a172
@ -1,4 +1,4 @@
|
||||
;;; center-content.el --- Center buffer content horizontally and vertically -*- lexical-binding: t; -*-
|
||||
;;; center-content.el --- Center buffer content -*- lexical-binding: t; -*-
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
@ -9,13 +9,33 @@
|
||||
|
||||
(require 'face-remap)
|
||||
|
||||
(defgroup center-content ()
|
||||
"Center buffer content."
|
||||
:group 'convinience
|
||||
:prefix "center-content-")
|
||||
|
||||
(defcustom center-content-horizontal t
|
||||
"Enable horizontal centering."
|
||||
:type 'boolean
|
||||
:group 'center-content)
|
||||
|
||||
(defcustom center-content-vertical t
|
||||
"Enable vertical centering."
|
||||
:type 'boolean
|
||||
:group 'center-content)
|
||||
|
||||
(defcustom center-content-hide-mode-line t
|
||||
"Hide mode-line when centering."
|
||||
:type 'boolean
|
||||
:group 'center-content)
|
||||
|
||||
(defvar-local center-content--horizontal-overlay nil
|
||||
"Overlay used to add left margin for horizontal centering.")
|
||||
|
||||
(defvar-local center-content--original-header-line-format nil
|
||||
(defvar-local center-content--original-header-line-format header-line-format
|
||||
"Stores the original `header-line-format` to restore upon disabling.")
|
||||
|
||||
(defvar-local center-content--original-mode-line-format nil
|
||||
(defvar-local center-content--original-mode-line-format mode-line-format
|
||||
"Stores the original `mode-line-format` to restore upon disabling.")
|
||||
|
||||
(defvar-local center-content--header-line-face-remap-cookie nil
|
||||
@ -57,10 +77,13 @@
|
||||
(defun center-content--enable ()
|
||||
"Enable horizontal and vertical centering of content."
|
||||
(let* ((content-size (center-content--content-pixel-size)))
|
||||
(center-content--horizontal (car content-size))
|
||||
(center-content--vertical (cdr content-size))
|
||||
(when center-content-horizontal
|
||||
(center-content--horizontal (car content-size)))
|
||||
(when center-content-vertical
|
||||
(center-content--vertical (cdr content-size)))
|
||||
(when center-content-hide-mode-line
|
||||
(setq center-content--original-mode-line-format mode-line-format)
|
||||
(setq mode-line-format nil)))
|
||||
(setq mode-line-format nil))))
|
||||
|
||||
(defun center-content--disable ()
|
||||
"Disable centering of content."
|
||||
@ -74,13 +97,8 @@
|
||||
(setq center-content--header-line-face-remap-cookie nil))
|
||||
;; Restore the header-line-format
|
||||
(setq header-line-format center-content--original-header-line-format)
|
||||
(setq center-content--original-mode-line-format nil)
|
||||
;; Restore the original mode-line-format
|
||||
(setq mode-line-format center-content--original-mode-line-format)
|
||||
(setq center-content--original-header-line-format nil)
|
||||
;; Force redisplay
|
||||
(force-mode-line-update)
|
||||
(redisplay))
|
||||
(setq mode-line-format center-content--original-mode-line-format))
|
||||
|
||||
;;;###autoload
|
||||
(define-minor-mode center-content-mode
|
||||
|
Loading…
Reference in New Issue
Block a user