Just so there is a backup
This commit is contained in:
@@ -4,20 +4,22 @@
|
||||
* Base setup
|
||||
** Bootstrapping
|
||||
|
||||
Partially based on [[https://stackoverflow.com/questions/151945/how-do-i-control-how-emacs-makes-backup-files][this post on StackOverflow]]. Setting backups, external custom file.
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(setq
|
||||
vc-follow-symlinks t ;Follow symlinks
|
||||
;Backup location TODO FIND IF RELEVANT FOR NIX
|
||||
backup-directory-alist `(("." . "~/.cache/emacs-backups/"))
|
||||
auto-save-file-name-transforms '((".*" "~/.cache/emacs-backups/" t))
|
||||
|
||||
;Backups from https://www.emacswiki.org/emacs/BackupDirectory
|
||||
backup-directory-alist `(("." . temporary-file-directory))
|
||||
auto-save-file-name-transforms '((".*" temporary-file-directory t))
|
||||
backup-by-copying t ;Always copy never link
|
||||
delete-old-versions t ;Auto delete old backups
|
||||
kept-new-versions 6 ;Number of versions to keep
|
||||
kept-old-versions 2
|
||||
version-control t ;Backups for files
|
||||
gc-cons-threshold 100000000 ;Setting garbage collection to 100M.
|
||||
|
||||
;Garbage collection
|
||||
gc-cons-threshold 100000000
|
||||
|
||||
;Set external cusotm file
|
||||
custom-file (expand-file-name "custom.el" user-emacs-directory)
|
||||
)
|
||||
@@ -276,7 +278,7 @@ Disabling the toolbar, the splash-screen, the menu-bar and the scroll-bar
|
||||
While we don't actually want fringes (almost at all), some frames use them.
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(set-face-attribute 'fringe nil :background "LemonChiffon1")
|
||||
;; (set-face-attribute 'fringe nil :background "LemonChiffon1")
|
||||
#+end_src
|
||||
|
||||
*** Window dividers
|
||||
@@ -288,6 +290,218 @@ While we don't actually want fringes (almost at all), some frames use them.
|
||||
(window-divider-mode 1)
|
||||
#+end_src
|
||||
|
||||
*** Tab bar
|
||||
*** Base
|
||||
|
||||
Prettification of tab bar. We only use tab-bar if the version is greater than 27.1.
|
||||
We also use this section to bind keys.
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
;; If version greater than 27.1
|
||||
|
||||
(defun azos/new-tab-and-rename ()
|
||||
"Created for back compatibility with emacs 27"
|
||||
(interactive)
|
||||
(progn
|
||||
(tab-bar-new-tab)
|
||||
(call-interactively 'tab-bar-rename-tab)))
|
||||
|
||||
(if (version<= "27.1" emacs-version) (progn
|
||||
(tab-bar-mode 1)
|
||||
|
||||
(set-face-attribute 'tab-bar nil
|
||||
:box t
|
||||
:background "LightYellow3"
|
||||
:foreground "DarkSlateGrey"
|
||||
:font "LiberationMono"
|
||||
:height 90)
|
||||
|
||||
(set-face-attribute 'tab-bar-tab nil
|
||||
:box '(:color "DarkSlateGrey" :line-width -2)
|
||||
:background "LightYellow3"
|
||||
:weight 'bold)
|
||||
|
||||
(set-face-attribute 'tab-bar-tab-inactive nil
|
||||
:background "LightYellow3"
|
||||
:inherit 'tab-bar)
|
||||
|
||||
(define-key azos/global-minor-mode/keymap
|
||||
(kbd "M-<tab>") 'tab-next)
|
||||
(define-key azos/global-minor-mode/keymap
|
||||
(kbd "M-'") 'tab-previous)
|
||||
(define-key azos/global-minor-mode/keymap
|
||||
(kbd "M-t r") 'tab-bar-rename-tab)
|
||||
(define-key azos/global-minor-mode/keymap
|
||||
(kbd "M-t n") 'tab-next)
|
||||
(define-key azos/global-minor-mode/keymap
|
||||
(kbd "M-t p") 'tab-previous)
|
||||
(define-key azos/global-minor-mode/keymap
|
||||
(kbd "M-t x") 'tab-bar-close-tab)
|
||||
(define-key azos/global-minor-mode/keymap
|
||||
(kbd "M-t c") 'azos/new-tab-and-rename)
|
||||
(setq tab-bar-close-button-show nil
|
||||
tab-bar-new-button-show nil
|
||||
tab-bar-separator (propertize " ● " 'face
|
||||
(list :foreground "LightYellow1"
|
||||
:box '(:color "DarkSlateGrey")))
|
||||
)
|
||||
(add-hook 'emacs-startup-hook (lambda () (tab-bar-rename-tab "home" 1)))
|
||||
))
|
||||
#+end_src
|
||||
|
||||
*** Right Group Display
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(defvar azos/tab-bar/right-update-group '()
|
||||
"Functions needed to run to update tab bar")
|
||||
|
||||
(defvar azos/tab-bar/right-group '()
|
||||
"A list of items to be displayed on the right of the tab-bar")
|
||||
|
||||
(defun azos/tab-bar/right-group-func ()
|
||||
"Function that returns a string to be displayed on right of tab-bar"
|
||||
(concat
|
||||
tab-bar-separator
|
||||
(mapconcat 'eval
|
||||
(remove ""
|
||||
(mapcar 'funcall azos/tab-bar/right-group))
|
||||
tab-bar-separator)
|
||||
tab-bar-separator))
|
||||
|
||||
(defun azos/tab-bar/update-func () "Function to update the tab bar"
|
||||
(progn
|
||||
(mapc 'funcall azos/tab-bar/right-update-group)
|
||||
(force-mode-line-update)))
|
||||
|
||||
(if (version<= "28.1" emacs-version) (progn
|
||||
(setq tab-bar-format
|
||||
'(
|
||||
tab-bar-format-history
|
||||
tab-bar-format-tabs
|
||||
tab-bar-separator
|
||||
tab-bar-format-add-tab
|
||||
tab-bar-format-align-right
|
||||
azos/tab-bar/right-group-func)
|
||||
tab-bar-auto-width nil)
|
||||
(define-key azos/global-minor-mode/keymap
|
||||
(kbd "M-n") 'tab-switch)
|
||||
;; (if (member system-type '(gnu gnu/linux))
|
||||
;; (azos/run-timer 'tab-timer 'azos/tab-bar/update-func 5))
|
||||
;; No auto-update, maybe some other way
|
||||
))
|
||||
#+end_src
|
||||
|
||||
Let's define a clock for the tab bar
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(defun azos/tab-bar/get-clock-string () "Get tab bar time string"
|
||||
(propertize (format-time-string "%a, %b %d %H:%M")
|
||||
'face '(:background "LightYellow3" :foreground "DarkSlateGrey")))
|
||||
|
||||
(defun azos/tab-bar/enable-clock-display ()
|
||||
"Enables clock display in tab bar"
|
||||
(cl-pushnew 'azos/tab-bar/get-clock-string
|
||||
azos/tab-bar/right-group))
|
||||
#+end_src
|
||||
|
||||
By default let's enable the clock display
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(azos/tab-bar/enable-clock-display)
|
||||
#+end_src
|
||||
|
||||
*** Tab bar addons
|
||||
**** Battery status in tab bar
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(defun azos/bat/get-stats () "Gets battery statistics. First value returned
|
||||
is battery percentage, second one is t if charging"
|
||||
(let* ((commandout (string-clean-whitespace (shell-command-to-string
|
||||
"upower -i /org/freedesktop/UPower/devices/DisplayDevice"))))
|
||||
(list
|
||||
(string-to-number (progn
|
||||
(string-match "\\(?:percentage\\:\s+\\)\\([0-9]+\\)" commandout)
|
||||
(match-string 1 commandout)))
|
||||
(progn
|
||||
(string-match "\\(?:state\\:\s+\\)\\([^\s]+\\)" commandout)
|
||||
(match-string 1 commandout)))
|
||||
))
|
||||
|
||||
(defvar azos/bat/status-string nil "Holds battery string")
|
||||
|
||||
(defun azos/bat/set-status-string () "Sets battery-string"
|
||||
(let* ((bat-stats (azos/bat/get-stats))
|
||||
(bat-charge-state (nth 1 bat-stats))
|
||||
(bat-percentage-number
|
||||
(if (string= bat-charge-state "fully-charged") 100
|
||||
(nth 0 bat-stats)))
|
||||
(bat-color (if (<= bat-percentage-number 10) "red3"
|
||||
(if (<= bat-percentage-number 20) "DarkOrange"
|
||||
"DarkSlateGrey")))
|
||||
(bat-weight (if (<= bat-percentage-number 20) 'bold 'normal))
|
||||
(bat-charge-symbol (if (string= bat-charge-state "charging") "↑"
|
||||
(if (string= bat-charge-state "fully-charged") "◼" "↓"))))
|
||||
(setq azos/bat/status-string
|
||||
(concat
|
||||
"⚡" bat-charge-symbol " "
|
||||
(propertize (format "%3d" bat-percentage-number)
|
||||
'face (list :foreground bat-color
|
||||
:box (list :color "DarkSlateGrey")))))))
|
||||
|
||||
(defun azos/bat/get-status-string () "Get battery string"
|
||||
(if azos/bat/status-string azos/bat/status-string ""))
|
||||
|
||||
(defun azos/bat/enable-tab-display ()
|
||||
"Enables battery display in tab bar"
|
||||
(progn
|
||||
(cl-pushnew 'azos/bat/get-status-string azos/tab-bar/right-group)
|
||||
(cl-pushnew 'azos/bat/set-status-string azos/tab-bar/right-update-group)
|
||||
))
|
||||
#+end_src
|
||||
|
||||
**** Network status in tab bar
|
||||
|
||||
Code to check for internet connection:
|
||||
|
||||
https://emacs.stackexchange.com/questions/7653/elisp-code-to-check-for-internet-connection
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(defvar azos/network/status-string nil "Holds network status string")
|
||||
|
||||
(defun azos/network/get-status-string () "Gets the network status string"
|
||||
(if azos/network/status-string azos/network/status-string ""))
|
||||
|
||||
(defun azos/network/set-status-string-sentinel (process event)
|
||||
"Sets the network string based on proc run"
|
||||
(setq azos/network/status-string
|
||||
(concat
|
||||
"↹ "
|
||||
(if (= 0 (process-exit-status process))
|
||||
(propertize "✓" 'face
|
||||
(list :foreground "green3"
|
||||
:background "LightYellow3"
|
||||
:box (list :color "DarkSlateGrey")))
|
||||
(propertize "X" 'face
|
||||
(list :foreground "red3"
|
||||
:background "LightYellow3"
|
||||
:box (list :color "DarkSlateGrey")))))))
|
||||
|
||||
(defun azos/network/start-test-proc () "Tests whether internet"
|
||||
(interactive)
|
||||
(set-process-sentinel
|
||||
(start-process "wget" nil "wget" "--spider" "--timeout=1"
|
||||
"www.google.com") 'azos/network/set-status-string-sentinel))
|
||||
|
||||
(defun azos/network/enable-tab-display ()
|
||||
"Enables network display in tab bar"
|
||||
(progn
|
||||
(cl-pushnew 'azos/network/get-status-string
|
||||
azos/tab-bar/right-group)
|
||||
(cl-pushnew 'azos/network/start-test-proc
|
||||
azos/tab-bar/right-update-group)
|
||||
))
|
||||
#+end_src
|
||||
|
||||
*** Easy Prompt
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
@@ -898,9 +1112,216 @@ Taken from: https://github.com/emacs-evil/evil/issues/1288
|
||||
:around #'azos/org/evil-org-insert-state-in-edit-buffer)
|
||||
#+end_src
|
||||
|
||||
*** Fonts
|
||||
|
||||
Fonts
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
;; (set-face-attribute 'org-document-title nil :height 200 :underline t)
|
||||
#+end_src
|
||||
|
||||
*** Inline images
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(setq org-startup-with-inline-images t)
|
||||
|
||||
(defun azos/org/shk-fix-inline-images ()
|
||||
(when org-inline-image-overlays
|
||||
(org-redisplay-inline-images)))
|
||||
|
||||
(with-eval-after-load 'org
|
||||
(add-hook 'org-babel-after-execute-hook 'azos/org/shk-fix-inline-images))
|
||||
#+end_src
|
||||
|
||||
*** Snippets
|
||||
|
||||
Want to create snippets for latex insertion.
|
||||
There is one template for inline and one template for standalone latex snippets.
|
||||
Each template is defind by two templates. One for other langauges and one for standard
|
||||
input. This is done to toggle back to the original language once done with the
|
||||
function toggle-input-method.
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(defun azos/org/toggle-input-method ()
|
||||
(if current-input-method (toggle-input-method))
|
||||
)
|
||||
;Inline
|
||||
(add-hook 'org-mode-hook (lambda () (progn
|
||||
(yas-define-snippets 'org-mode (list (list
|
||||
nil
|
||||
"\$$1\$$0"
|
||||
"ORG_LATEX_INLINE_SNIPPET_ENG"
|
||||
'(not (eval current-input-method))
|
||||
nil
|
||||
nil
|
||||
nil
|
||||
"C-l"
|
||||
nil
|
||||
nil
|
||||
)))
|
||||
|
||||
(yas-define-snippets 'org-mode (list (list
|
||||
nil
|
||||
"\$$1\$$0"
|
||||
"ORG_LATEX_INLINE_SNIPPET_OTHER_LANG"
|
||||
'(eval current-input-method)
|
||||
nil
|
||||
'((unused (azos/org/toggle-input-method))
|
||||
(yas-after-exit-snippet-hook 'toggle-input-method))
|
||||
nil
|
||||
"C-l"
|
||||
nil
|
||||
nil
|
||||
)))
|
||||
|
||||
;Not inline
|
||||
(yas-define-snippets 'org-mode (list (list
|
||||
nil
|
||||
"\$\$$1\$\$$0"
|
||||
"ORG_LATEX_OUTLINE_SNIPPET_ENG"
|
||||
'(not (eval current-input-method))
|
||||
nil
|
||||
nil
|
||||
nil
|
||||
"C-S-l"
|
||||
nil
|
||||
nil
|
||||
)))
|
||||
(yas-define-snippets 'org-mode (list (list
|
||||
nil
|
||||
"\$\$$1\$\$$0"
|
||||
"ORG_LATEX_OUTLINE_SNIPPET_OTHER_LANG"
|
||||
'(eval current-input-method)
|
||||
nil
|
||||
'((unused (azos/org/toggle-input-method))
|
||||
(yas-after-exit-snippet-hook 'toggle-input-method))
|
||||
nil
|
||||
"C-S-l"
|
||||
nil
|
||||
nil
|
||||
)))
|
||||
)))
|
||||
#+end_src
|
||||
|
||||
Snippet for src blocks
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(add-hook 'org-mode-hook (lambda () (progn
|
||||
(yas-define-snippets 'org-mode (list (list
|
||||
nil
|
||||
"#+begin_src $1\n$0\n#+end_src"
|
||||
"ORG_SRC_BLOCK"
|
||||
nil
|
||||
nil
|
||||
nil
|
||||
nil
|
||||
"C-c i b"
|
||||
nil
|
||||
nil
|
||||
)))
|
||||
|
||||
(yas-define-snippets 'org-mode (list (list
|
||||
nil
|
||||
(concat
|
||||
"#+begin_export latex\n"
|
||||
"\\begin{english}\n"
|
||||
"#+end_export\n"
|
||||
"#+begin_src $1\n"
|
||||
"$0\n#+end_src\n"
|
||||
"#+begin_export latex\n"
|
||||
"\\end{english}\n"
|
||||
"#+end_export")
|
||||
"ORG_SRC_ENGLISH_BLOCK"
|
||||
nil
|
||||
nil
|
||||
nil
|
||||
nil
|
||||
"C-c i B"
|
||||
nil
|
||||
nil
|
||||
)))
|
||||
)))
|
||||
#+end_src
|
||||
|
||||
*** Imenu quirks
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(add-to-list 'org-show-context-detail '(isearch . tree))
|
||||
(add-to-list 'org-show-context-detail '(default . tree))
|
||||
#+end_src
|
||||
|
||||
** Ibuffer
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(evil-collection-ibuffer-setup)
|
||||
(define-key azos/global-minor-mode/keymap
|
||||
(kbd "C-x C-b") 'ibuffer)
|
||||
#+end_src
|
||||
|
||||
** Dashboard
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(setq inhibit-startup-screen t)
|
||||
(use-package dashboard
|
||||
:config
|
||||
(add-hook 'after-init-hook
|
||||
(lambda () (dashboard-insert-startupify-lists)))
|
||||
(add-hook 'emacs-startup-hook (lambda ()
|
||||
(switch-to-buffer dashboard-buffer-name)
|
||||
(goto-char (point-min))
|
||||
(redisplay)
|
||||
(run-hooks 'dashboard-after-initialize-hook)))
|
||||
(add-to-list 'evil-emacs-state-modes 'dashboard-mode)
|
||||
(setq dashboard-items '((recents . 5)
|
||||
(bookmarks . 5)
|
||||
(projects . 5))
|
||||
dashboard-center-content t
|
||||
dashboard-banner-logo-title nil
|
||||
dashboard-set-init-info nil
|
||||
dashboard-set-footer nil
|
||||
dashboard-startup-banner 'ascii
|
||||
dashboard-banner-ascii "azos"))
|
||||
#+end_src
|
||||
|
||||
** VTerm
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
;; (use-package xterm-color :ensure t)
|
||||
;; (use-package eterm-256color :ensure t
|
||||
;; :config
|
||||
;; (add-hook 'term-mode-hook #'eterm-256color-mode)
|
||||
;; (add-hook 'vterm-mode-hook #'eterm-256color-mode)
|
||||
;; )
|
||||
#+end_src
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(use-package vterm
|
||||
:if (member system-type '(gnu gnu/linux))
|
||||
:config
|
||||
(add-hook 'vterm-mode-hook
|
||||
(lambda () (setq-local global-hl-line-mode nil)))
|
||||
|
||||
(evil-collection-define-key 'normal 'vterm-mode-map
|
||||
(kbd "p") 'vterm-yank)
|
||||
(setq vterm-timer-delay 0.01
|
||||
vterm-term-environment-variable "xterm-256color"))
|
||||
#+end_src
|
||||
|
||||
** Boomkark
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(use-package bookmark
|
||||
:straight
|
||||
(:type built-in)
|
||||
:config
|
||||
(evil-collection-bookmark-setup)
|
||||
)
|
||||
#+end_src
|
||||
|
||||
* Provide
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(provide 'azos-emacs-base)
|
||||
(add-hook 'after-init-hook (lambda () (require 'azos-emacs-base)))
|
||||
#+end_src
|
||||
|
||||
|
||||
Reference in New Issue
Block a user