-;; startup
-;; don't need to see the startup echo area message
-(advice-add #'display-startup-echo-area-message :override #'ignore)
-(csetq
- ;; i want *scratch* as my startup buffer
- initial-buffer-choice t
- ;; i don't need the default hint
- initial-scratch-message nil
- ;; use customizable text-mode as major mode for *scratch*
- ;; (initial-major-mode 'text-mode)
- ;; inhibit buffer list when more than 2 files are loaded
- inhibit-startup-buffer-menu t
- ;; don't need to see the startup screen or echo area message
- inhibit-startup-screen t
- inhibit-startup-echo-area-message user-login-name)
-
-;; files
-(csetq
- ;; backups (C-h v make-backup-files RET)
- backup-by-copying t
- backup-directory-alist (list (cons "." (b/var "backup/")))
- version-control t
- delete-old-versions t
- ;; auto-save
- auto-save-file-name-transforms `((".*" ,(b/var "auto-save/") t))
- ;; insert newline at the end of files
- require-final-newline t
- ;; open read-only file buffers in view-mode
- ;; (enables niceties like `q' for quit)
- view-read-only t)
-
-;; novice
-;; disable disabled commands
-(csetq disabled-command-function nil)
-
-;; lazy-person-friendly yes/no prompts
-(defalias 'yes-or-no-p #'y-or-n-p)
+(with-eval-after-load 'minibuffer
+ (setq read-file-name-completion-ignore-case t))
+
+;; `startup'
+(setq auto-save-list-file-prefix (b/var "auto-save/sessions/"))
+
+(with-eval-after-load 'files
+ (setq
+ ;; backups (C-h v make-backup-files RET)
+ backup-by-copying t
+ backup-directory-alist (list (cons "." (b/var "backup/")))
+ version-control t
+ delete-old-versions t
+ ;; auto-save
+ auto-save-file-name-transforms `((".*" ,(b/var "auto-save/") t))
+ ;; insert newline at the end of files
+ ;; require-final-newline t
+ ;; open read-only file buffers in view-mode
+ ;; (enables niceties like `q' for quit)
+ view-read-only t))
+
+;; `novice'
+(setq disabled-command-function nil)
+
+;; `subr'
+;; (keyboard-translate ?\( ?\[)
+;; (keyboard-translate ?\) ?\])
+;; (keyboard-translate ?\[ ?\()
+;; (keyboard-translate ?\] ?\))
+
+(run-with-idle-timer 0.1 nil #'require 'autorevert)
+(with-eval-after-load 'autorevert
+ (setq
+ ;; auto-revert-verbose nil
+ global-auto-revert-non-file-buffers nil)
+ (global-auto-revert-mode 1))
+
+(run-with-idle-timer 0.1 nil #'require 'time)
+(with-eval-after-load 'time
+ (setq
+ display-time-default-load-average nil
+ display-time-format " %a %Y-%m-%d %-l:%M%P"
+ display-time-mail-icon '(image :type xpm
+ :file "gnus/gnus-pointer.xpm"
+ :ascent center)
+ display-time-use-mail-icon t
+ zoneinfo-style-world-list
+ `(,@zoneinfo-style-world-list
+ ("Etc/UTC" "UTC")
+ ("Asia/Tehran" "Tehran")
+ ("Australia/Melbourne" "Melbourne")))
+ (display-time-mode))
+
+(run-with-idle-timer 0.1 nil #'require 'battery)
+(with-eval-after-load 'battery
+ (setq battery-mode-line-format " [%p%% %t]")
+ (display-battery-mode))
+
+(progn ; display system volume in mode-line
+ (defvar b/volume-level 0)
+ (defvar b/volume-mute nil)
+ (defvar b/volume-level-mic 0)
+ (defvar b/volume-mute-mic nil)
+
+ (defun b/volume-get (&optional use-default-source)
+ "Get the default sink volume and mute state.
+If USE-DEFAULT-SOURCE is non-nill, use the default source (e.g. a
+microphone) instead of the default sink."
+ (pcase (split-string ; expecting: <mute> <volume> (e.g. true 15)
+ (string-trim
+ (shell-command-to-string
+ (mapconcat
+ #'identity
+ `("pamixer"
+ ,(when use-default-source "--default-source")
+ "--get-volume"
+ "--get-mute")
+ " "))))
+ (`(,m ,v)
+ (let ((mute (string= "true" m))
+ (volume (string-to-number v)))
+ `(,mute ,volume)))))
+
+ (defun b/volume-update ()
+ "Update system sound volume as displayed in mode-line."
+ (let ((changed))
+ (pcase (b/volume-get)
+ (`(,mute ,volume)
+ (unless (eq mute b/volume-mute)
+ (setq b/volume-mute mute
+ changed t))
+ (unless (= volume b/volume-level)
+ (setq b/volume-level volume
+ changed t))))
+ (pcase (b/volume-get 'mic)
+ (`(,mute ,volume)
+ (unless (eq mute b/volume-mute-mic)
+ (setq b/volume-mute-mic mute
+ changed t))
+ (unless (= volume b/volume-level-mic)
+ (setq b/volume-level-mic volume
+ changed t))))
+ (when changed
+ (force-mode-line-update))))
+
+ (defvar b/volume-timer (run-at-time nil 5 #'b/volume-update))