Add the date unit and fix the init-fn order
This commit is contained in:
parent
7f197504b5
commit
60d26d8331
|
@ -29,6 +29,7 @@
|
||||||
(defvar line-unit)
|
(defvar line-unit)
|
||||||
(defvar buffer-name-unit)
|
(defvar buffer-name-unit)
|
||||||
(defvar time-unit)
|
(defvar time-unit)
|
||||||
|
(defvar date-unit)
|
||||||
(defvar mode-name-unit)
|
(defvar mode-name-unit)
|
||||||
(defvar projectile-project-unit)
|
(defvar projectile-project-unit)
|
||||||
(declare-function projectile-project-name "projectile-project-name" ()))
|
(declare-function projectile-project-name "projectile-project-name" ()))
|
||||||
|
@ -105,7 +106,7 @@ Emacs knowing."
|
||||||
(defvar noether--timer nil)
|
(defvar noether--timer nil)
|
||||||
(defun noether--set-time ()
|
(defun noether--set-time ()
|
||||||
"Set the current time to the internal var which is being watched."
|
"Set the current time to the internal var which is being watched."
|
||||||
(setq noether--time (format-time-string "%m-%d %H:%M")))
|
(setq noether--time (format-time-string "%H:%M")))
|
||||||
|
|
||||||
(defun noether--time-format (_ v _ _)
|
(defun noether--time-format (_ v _ _)
|
||||||
"Just return the current time V."
|
"Just return the current time V."
|
||||||
|
@ -115,7 +116,7 @@ Emacs knowing."
|
||||||
(noether-defunit time-unit
|
(noether-defunit time-unit
|
||||||
"just the time for your bar."
|
"just the time for your bar."
|
||||||
:label "T:"
|
:label "T:"
|
||||||
:len 8
|
:len 5
|
||||||
:init (lambda ()
|
:init (lambda ()
|
||||||
(setq noether--timer
|
(setq noether--timer
|
||||||
(run-with-timer 1 1 #'noether--set-time)))
|
(run-with-timer 1 1 #'noether--set-time)))
|
||||||
|
@ -126,6 +127,35 @@ Emacs knowing."
|
||||||
:var 'noether--time
|
:var 'noether--time
|
||||||
:fn #'noether--time-format)
|
:fn #'noether--time-format)
|
||||||
|
|
||||||
|
;; ============================================================================
|
||||||
|
;; Daet indicator
|
||||||
|
;; ============================================================================
|
||||||
|
(defvar noether--date "")
|
||||||
|
(defvar noether--date-timer nil)
|
||||||
|
(defun noether--set-date ()
|
||||||
|
"Set the current date to the internal var which is being watched."
|
||||||
|
(setq noether--date (format-time-string "%m-%d")))
|
||||||
|
|
||||||
|
(defun noether--date-format (_ v _ _)
|
||||||
|
"Just return the current date V."
|
||||||
|
v)
|
||||||
|
|
||||||
|
|
||||||
|
(noether-defunit date-unit
|
||||||
|
"just the date for your bar."
|
||||||
|
:label "D:"
|
||||||
|
:len 5
|
||||||
|
:init (lambda ()
|
||||||
|
(noether--set-date)
|
||||||
|
(setq noether--date-timer
|
||||||
|
(run-with-timer 3600 1 #'noether--set-date)))
|
||||||
|
:deinit (lambda ()
|
||||||
|
(when noether--date-timer
|
||||||
|
(cancel-timer noether--date-timer)))
|
||||||
|
|
||||||
|
:var 'noether--date
|
||||||
|
:fn #'noether--date-format)
|
||||||
|
|
||||||
;; ============================================================================
|
;; ============================================================================
|
||||||
;; Mode name
|
;; Mode name
|
||||||
;; ============================================================================
|
;; ============================================================================
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
;;; Code:
|
;;; Code:
|
||||||
(require 'seq)
|
(require 'seq)
|
||||||
(require 'posframe)
|
(require 'posframe)
|
||||||
|
(require 'subr-x)
|
||||||
|
|
||||||
(defgroup noether nil
|
(defgroup noether nil
|
||||||
"The customization group for the noether-mode."
|
"The customization group for the noether-mode."
|
||||||
|
@ -255,9 +256,6 @@ side BUF and F to it. It's simple trick to make small a closure."
|
||||||
(when (null f)
|
(when (null f)
|
||||||
(error (format "No `fn' in %s" unit)))
|
(error (format "No `fn' in %s" unit)))
|
||||||
|
|
||||||
(when init-fn
|
|
||||||
(funcall init-fn))
|
|
||||||
|
|
||||||
(when var
|
(when var
|
||||||
;; Setup the watcher and the watcher remover
|
;; Setup the watcher and the watcher remover
|
||||||
(add-variable-watcher var updater)
|
(add-variable-watcher var updater)
|
||||||
|
@ -268,6 +266,10 @@ side BUF and F to it. It's simple trick to make small a closure."
|
||||||
(remove-variable-watcher var updater))
|
(remove-variable-watcher var updater))
|
||||||
(get view-name :watcher-removers))))
|
(get view-name :watcher-removers))))
|
||||||
|
|
||||||
|
(when init-fn
|
||||||
|
(funcall init-fn))
|
||||||
|
|
||||||
|
|
||||||
(put view-name :updaters
|
(put view-name :updaters
|
||||||
(cons updater (get view-name :updaters)))
|
(cons updater (get view-name :updaters)))
|
||||||
|
|
||||||
|
|
|
@ -43,8 +43,7 @@
|
||||||
"A simple and minimalist mode-line like status bar"
|
"A simple and minimalist mode-line like status bar"
|
||||||
:managed? t
|
:managed? t
|
||||||
:buffer "*modeline*"
|
:buffer "*modeline*"
|
||||||
;;:binding (kbd "C-c 1")
|
:binding (kbd "C-c 1")
|
||||||
:timeout 0
|
|
||||||
:separator "|"
|
:separator "|"
|
||||||
:visible? t
|
:visible? t
|
||||||
:frame
|
:frame
|
||||||
|
@ -53,6 +52,7 @@
|
||||||
;; (- (frame-outer-height) 40))
|
;; (- (frame-outer-height) 40))
|
||||||
:poshandler #'noether--bottom-right
|
:poshandler #'noether--bottom-right
|
||||||
:border-width 0
|
:border-width 0
|
||||||
|
;;:timeout 5
|
||||||
|
|
||||||
:border-color "#bd93f9")
|
:border-color "#bd93f9")
|
||||||
|
|
||||||
|
@ -60,7 +60,9 @@
|
||||||
(list
|
(list
|
||||||
(line-unit :label "")
|
(line-unit :label "")
|
||||||
(buffer-name-unit :label "B: ")
|
(buffer-name-unit :label "B: ")
|
||||||
(mode-name-unit :label "M: ")))
|
(mode-name-unit :label "M: ")
|
||||||
|
(time-unit)
|
||||||
|
(date-unit)))
|
||||||
|
|
||||||
|
|
||||||
(setq noether-views (list mode-line))
|
(setq noether-views (list mode-line))
|
||||||
|
|
Loading…
Reference in New Issue