-;; 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
+ (defun b/get-volume-level (&optional mic)
+ "Returns the current system sound volume.
+If MIC is non-nil, it returns the microphone volume instead."
+ (string-to-number
+ (string-trim
+ (shell-command-to-string
+ (mapconcat
+ #'identity
+ `("pamixer" ,(when mic "--default-source") "--get-volume")
+ " ")))))
+
+ (defun b/set-volume-level (level &optional mic)
+ "Set the system sound volume to LEVEL.
+If MIC is non-nil, set the volume level for the microphone
+instead."
+ (let ((v (if mic 'b/volume-level-mic 'b/volume-level)))
+ (eval `(setq ,v ,level))))
+
+ (defun b/get-volume-mute (&optional mic)
+ "Returns t if system sound is currently muted.
+If MIC is non-nil, it instead returns t if the microphone is
+muted."
+ (string=
+ "true"
+ (string-trim
+ (shell-command-to-string
+ (mapconcat
+ #'identity
+ `("pamixer" ,(when mic "--default-source") "--get-mute")
+ " ")))))
+
+ (defun b/set-volume-mute (mute &optional mic)
+ "Set the system sound mutedness to MUTE.
+If MIC is non-nil, set the mutedness for the microphone instead."
+ (let ((v (if mic 'b/volume-mute-mic 'b/volume-mute)))
+ (eval `(setq ,v ,mute))))
+
+ (defvar b/volume-level (b/get-volume-level))
+ (defvar b/volume-mute (b/get-volume-mute))
+ (defvar b/volume-level-mic (b/get-volume-level 'mic))
+ (defvar b/volume-mute-mic (b/get-volume-mute 'mic))