diff options
author | Vincent Ambo <tazjin@google.com> | 2019-12-14T15·24+0000 |
---|---|---|
committer | Vincent Ambo <tazjin@google.com> | 2019-12-14T15·24+0000 |
commit | 7d03ab714059a05e4f841be379b7a5ba2d033b09 (patch) | |
tree | 43dfc7b90339c69a5827ab468099591ca6b5edd3 /tools/emacs/config/look-and-feel.el | |
parent | 1584607fb9c0d7d8c151509573c3447f17f42ec8 (diff) |
chore(emacs.d): Move init/* to config/* r/144
Diffstat (limited to 'tools/emacs/config/look-and-feel.el')
-rw-r--r-- | tools/emacs/config/look-and-feel.el | 132 |
1 files changed, 132 insertions, 0 deletions
diff --git a/tools/emacs/config/look-and-feel.el b/tools/emacs/config/look-and-feel.el new file mode 100644 index 000000000000..8f42133fb8a0 --- /dev/null +++ b/tools/emacs/config/look-and-feel.el @@ -0,0 +1,132 @@ +;;; -*- lexical-binding: t; -*- + +;; Hide those ugly tool bars: +(tool-bar-mode 0) +(scroll-bar-mode 0) +(menu-bar-mode 0) +(add-hook 'after-make-frame-functions + (lambda (frame) (scroll-bar-mode 0))) + +;; Don't do any annoying things: +(setq ring-bell-function 'ignore) +(setq initial-scratch-message "") + +;; Remember layout changes +(winner-mode 1) + +;; Usually emacs will run as a proper GUI application, in which case a few +;; extra settings are nice-to-have: +(when window-system + (setq frame-title-format '(buffer-file-name "%f" ("%b"))) + (mouse-wheel-mode t) + (blink-cursor-mode -1)) + +;; Configure editor fonts +(let ((font (format "Input Mono-%d" 12))) + (setq default-frame-alist `((font-backend . "xft") + (font . ,font))) + (set-frame-font font t t)) + +;; Display modeline time in dottime (see https://dotti.me) +;; +;; This is done in a way that initially seems more complicated than +;; one would like, but this is unfortunately required due to the way +;; `format-time-string' handles timezones. +(defun format-dottime-advice (orig _ &optional _ _) + (let* ((offset-sec (car (current-time-zone))) + (offset-hours (/ offset-sec 60 60)) + (dottime (if (/= offset-hours 0) + (concat "%M-%Dt%H·%M" (format "%0+3d" offset-hours)) + "%m-%dT%H·%M"))) + (apply orig '("%m-%dT%H·%M" nil t)))) + +(advice-add 'format-time-string :around #'format-dottime-advice) + +;; Configure telephone-line +(defun telephone-misc-if-last-window () + "Renders the mode-line-misc-info string for display in the + mode-line if the currently active window is the last one in the + frame. + + The idea is to not display information like the current time, + load, battery levels on all buffers." + + (when (bottom-right-window-p) + (telephone-line-raw mode-line-misc-info t))) + +(defun telephone-line-setup () + (telephone-line-defsegment telephone-line-last-window-segment () + (telephone-misc-if-last-window)) + + ;; Display the current EXWM workspace index in the mode-line + (telephone-line-defsegment telephone-line-exwm-workspace-index () + (when (bottom-right-window-p) + (format "[%s]" exwm-workspace-current-index))) + + ;; Define a highlight font for ~ important ~ information in the last + ;; window. + (defface special-highlight '((t (:foreground "white" :background "#5f627f"))) "") + (add-to-list 'telephone-line-faces + '(highlight . (special-highlight . special-highlight))) + + (setq telephone-line-lhs + '((nil . (telephone-line-position-segment)) + (accent . (telephone-line-buffer-segment)))) + + (setq telephone-line-rhs + '((accent . (telephone-line-major-mode-segment)) + (nil . (telephone-line-last-window-segment + telephone-line-exwm-workspace-index)) + + ;; TODO(tazjin): lets not do this particular thing while I + ;; don't actually run notmuch, there are too many things + ;; that have a dependency on the modeline drawing correctly + ;; (including randr operations!) + ;; + ;; (highlight . (telephone-line-notmuch-counts)) + )) + + (setq telephone-line-primary-left-separator 'telephone-line-tan-left + telephone-line-primary-right-separator 'telephone-line-tan-right + telephone-line-secondary-left-separator 'telephone-line-tan-hollow-left + telephone-line-secondary-right-separator 'telephone-line-tan-hollow-right) + + (telephone-line-mode 1)) + +;; Auto refresh buffers +(global-auto-revert-mode 1) + +;; Use clipboard properly +(setq select-enable-clipboard t) + +;; Show in-progress chords in minibuffer +(setq echo-keystrokes 0.1) + +;; Show column numbers in all buffers +(column-number-mode t) + +;; Highlight currently active line +(global-hl-line-mode t) + +(defalias 'yes-or-no-p 'y-or-n-p) +(defalias 'auto-tail-revert-mode 'tail-mode) + +;; Style line numbers (shown with M-g g) +(setq linum-format + (lambda (line) + (propertize + (format (concat " %" + (number-to-string + (length (number-to-string + (line-number-at-pos (point-max))))) + "d ") + line) + 'face 'linum))) + +;; Display tabs as 2 spaces +(setq tab-width 2) + +;; Don't wrap around when moving between buffers +(setq windmove-wrap-around nil) + +(provide 'look-and-feel) |