[emacs] switch from doom-modeline to smart-mode-line again
[~bandali/configs] / init.org
index 787d386..ae1a6e6 100644 (file)
--- a/init.org
+++ b/init.org
@@ -345,14 +345,12 @@ in my shell.
   (exec-path-from-shell-copy-env "SSH_AUTH_SOCK"))
 #+end_src
 
   (exec-path-from-shell-copy-env "SSH_AUTH_SOCK"))
 #+end_src
 
-** Only one custom theme at a time
+** COMMENT Only one custom theme at a time
 
 #+begin_src emacs-lisp
 
 #+begin_src emacs-lisp
-;; only one custom theme at a time
-;;
-;; (defadvice load-theme (before clear-previous-themes activate)
-;;   "Clear existing theme settings instead of layering them"
-;;   (mapc #'disable-theme custom-enabled-themes))
+(defadvice load-theme (before clear-previous-themes activate)
+  "Clear existing theme settings instead of layering them"
+  (mapc #'disable-theme custom-enabled-themes))
 #+end_src
 
 ** Server
 #+end_src
 
 ** Server
@@ -371,44 +369,42 @@ See [[https://www.gnu.org/software/emacs/manual/html_node/emacs/Emacs-Server.htm
   :config (or (server-running-p) (server-mode)))
 #+end_src
 
   :config (or (server-running-p) (server-mode)))
 #+end_src
 
-** Unicode support
+** COMMENT Unicode support
 
 Font stack with better unicode support, around =Ubuntu Mono= and
 =Hack=.
 
 #+begin_src emacs-lisp
 
 Font stack with better unicode support, around =Ubuntu Mono= and
 =Hack=.
 
 #+begin_src emacs-lisp
-;; unicode support
-;;
-;; (dolist (ft (fontset-list))
-;;   (set-fontset-font
-;;    ft
-;;    'unicode
-;;    (font-spec :name "Source Code Pro" :size 14))
-;;   (set-fontset-font
-;;    ft
-;;    'unicode
-;;    (font-spec :name "DejaVu Sans Mono")
-;;    nil
-;;    'append)
-;;   ;; (set-fontset-font
-;;   ;;  ft
-;;   ;;  'unicode
-;;   ;;  (font-spec
-;;   ;;   :name "Symbola monospacified for DejaVu Sans Mono")
-;;   ;;  nil
-;;   ;;  'append)
-;;   ;; (set-fontset-font
-;;   ;;  ft
-;;   ;;  #x2115  ; ℕ
-;;   ;;  (font-spec :name "DejaVu Sans Mono")
-;;   ;;  nil
-;;   ;;  'append)
-;;   (set-fontset-font
-;;    ft
-;;    (cons ?Α ?ω)
-;;    (font-spec :name "DejaVu Sans Mono" :size 14)
-;;    nil
-;;    'prepend))
+(dolist (ft (fontset-list))
+  (set-fontset-font
+   ft
+   'unicode
+   (font-spec :name "Source Code Pro" :size 14))
+  (set-fontset-font
+   ft
+   'unicode
+   (font-spec :name "DejaVu Sans Mono")
+   nil
+   'append)
+  ;; (set-fontset-font
+  ;;  ft
+  ;;  'unicode
+  ;;  (font-spec
+  ;;   :name "Symbola monospacified for DejaVu Sans Mono")
+  ;;  nil
+  ;;  'append)
+  ;; (set-fontset-font
+  ;;  ft
+  ;;  #x2115  ; ℕ
+  ;;  (font-spec :name "DejaVu Sans Mono")
+  ;;  nil
+  ;;  'append)
+  (set-fontset-font
+   ft
+   (cons ?Α ?ω)
+   (font-spec :name "DejaVu Sans Mono" :size 14)
+   nil
+   'prepend))
 #+end_src
 
 ** Gentler font resizing
 #+end_src
 
 ** Gentler font resizing
@@ -650,18 +646,35 @@ Enable =winner-mode=.
 (winner-mode 1)
 #+end_src
 
 (winner-mode 1)
 #+end_src
 
-*** Close =*compilation*= on success
+*** Don’t display =*compilation*= on success
+
+From https://stackoverflow.com/a/17788551.
 
 #+begin_src emacs-lisp
 
 #+begin_src emacs-lisp
-(setq compilation-exit-message-function
-      (lambda (status code msg)
-        "Close the compilation window if successful."
-        ;; if M-x compile exits with 0
-         (when (and (eq status 'exit) (zerop code))
-           (bury-buffer)
-           (delete-window (get-buffer-window (get-buffer "*compilation*"))))
-         ;; return the result of compilation-exit-message-function
-         (cons msg code)))
+(defun amin--compilation-finish-function (buffer outstr)
+  (unless (string-match "finished" outstr)
+    (switch-to-buffer-other-window buffer))
+  t)
+
+(setq compilation-finish-functions #'amin--compilation-finish-function)
+
+(require 'cl)
+
+(defadvice compilation-start
+    (around inhibit-display
+            (command &optional mode name-function highlight-regexp))
+  (if (not (string-match "^\\(find\\|grep\\)" command))
+      (flet ((display-buffer)
+             (set-window-point)
+             (goto-char))
+        (fset 'display-buffer   'ignore)
+        (fset 'goto-char        'ignore)
+        (fset 'set-window-point 'ignore)
+        (save-window-excursion
+          ad-do-it))
+    ad-do-it))
+
+(ad-activate 'compilation-start)
 #+end_src
 
 *** Search for non-ASCII characters
 #+end_src
 
 *** Search for non-ASCII characters
@@ -1569,13 +1582,12 @@ Emacs package that displays available keybindings in popup
 (load-theme 'tangomod t)
 #+end_src
 
 (load-theme 'tangomod t)
 #+end_src
 
-** doom-modeline
+** smart-mode-line
 
 #+begin_src emacs-lisp
 
 #+begin_src emacs-lisp
-(use-package doom-modeline
-  :demand t
-  :config (setq doom-modeline-height 32)
-  :hook (after-init . doom-modeline-init))
+(use-package smart-mode-line
+  :config
+  (sml/setup))
 #+end_src
 
 ** doom-themes
 #+end_src
 
 ** doom-themes
@@ -1590,16 +1602,16 @@ Emacs package that displays available keybindings in popup
 (defun amin/lights-on ()
   "Enable my favourite light theme."
   (interactive)
 (defun amin/lights-on ()
   "Enable my favourite light theme."
   (interactive)
-  (progn
-    (mapc #'disable-theme custom-enabled-themes)
-    (load-theme 'tangomod t)))
+  (mapc #'disable-theme custom-enabled-themes)
+  (load-theme 'tangomod t)
+  (sml/apply-theme 'automatic))
 
 (defun amin/lights-off ()
   "Go dark."
   (interactive)
 
 (defun amin/lights-off ()
   "Go dark."
   (interactive)
-  (progn
-    (mapc #'disable-theme custom-enabled-themes)
-    (load-theme 'doom-tomorrow-night t)))
+  (mapc #'disable-theme custom-enabled-themes)
+  (load-theme 'doom-tomorrow-night t)
+  (sml/apply-theme 'automatic))
 
 (bind-keys
  ("s-t d" . amin/lights-off)
 
 (bind-keys
  ("s-t d" . amin/lights-off)