summaryrefslogtreecommitdiff
path: root/modally.el
diff options
context:
space:
mode:
authorBlake Romero <blake@developercraft.com>2025-10-12 14:43:14 +0100
committerBlake Romero <blake@developercraft.com>2025-10-12 14:43:14 +0100
commitd0c8423b1fee38ac1e2c9d35705622c1734c0473 (patch)
tree24ed14fa2e46aefe986fc1f14506b51c9bbbc7d5 /modally.el
parent0ec78530b114d7d51aa080331702dc7cab16908d (diff)
Add read-only construct
Diffstat (limited to 'modally.el')
-rw-r--r--modally.el45
1 files changed, 29 insertions, 16 deletions
diff --git a/modally.el b/modally.el
index fdc45b4..69dfca0 100644
--- a/modally.el
+++ b/modally.el
@@ -22,11 +22,12 @@
;;
;;; Code:
-(require 'subr-x)
-(require 'cl-lib)
-(require 'vc-git)
-(require 'flymake)
-(require 'org-timer)
+;; (require 'subr-x)
+;; (require 'cl-lib)
+;; (require 'vc-git)
+;; (require 'flymake)
+;; (require 'org-timer)
+(autoload 'org-timer-start "org-timer")
(require 'modally-faces)
@@ -34,8 +35,14 @@
(defun modally--seperator ()
"Return a propertized separator."
(propertize "┃" 'face (if (mode-line-window-selected-p)
- '(t :foreground "#444444")
- '(t :foreground "#222222"))))
+ 'modally-active
+ 'modally-inactive)))
+
+(defun modally--read-only-status ()
+ "Return a string to display read-only status."
+ (format "%s %s"
+ (if buffer-read-only " RO" " RW")
+ (modally--seperator)))
(defun modally--buffer-name ()
"Return a propertized buffer name string."
@@ -44,15 +51,14 @@
((buffer-modified-p) 'modally-buffer-modified)
(buffer-read-only 'modally-buffer-readonly)
('modally-buffer)))
- (buffer-name (concat (if buffer-read-only "🔒 " "✏️ ")
- (if buffer-file-name
- (if (string-match "^\\(/home/[^/]+\\)\\(.+\\)"
- buffer-file-name)
- (concat "~" (match-string 2 buffer-file-name))
- buffer-file-name)
- (buffer-name (current-buffer)))))
+ (buffer-name
+ (if buffer-file-name
+ (if (string-match "^\\(/home/[^/]+\\)\\(.+\\)"
+ buffer-file-name)
+ (concat "~" (match-string 2 buffer-file-name))
+ buffer-file-name)
+ (buffer-name (current-buffer))))
(spath (string-split buffer-name "/")))
-
;; Format
(if (> (length spath) 1)
;; if buffer has a path
@@ -145,6 +151,7 @@
(defun modally--org-timer ()
"Return a timer from `org-timer'."
(when (and
+ (featurep 'org-timer)
(or org-timer-mode-line-timer
org-timer-pause-time)
(mode-line-window-selected-p))
@@ -161,6 +168,10 @@
))))
;; VARIABLES
+(defvar modally-display-read-only
+ '(:eval (modally--read-only-status))
+ "Modeline construct to display the read-only status.")
+
(defvar modally-display-buffer-name
'(:eval (modally--buffer-name))
"Modeline construct to display the buffer name.")
@@ -196,7 +207,8 @@
"Modeline construct to display `org-timer' info.")
;; set as risky local variable
-(dolist (construct '(modally-display-buffer-name
+(dolist (construct '(modally-display-read-only
+ modally-display-buffer-name
modally-display-major-mode
modally-display-git-branch
modally-display-line-row
@@ -209,6 +221,7 @@
;; FORMATS
(defvar modally-format-default
`("%e"
+ modally-display-read-only
modally-display-buffer-name
mode-line-format-right-align
modally-display-org-timer