[emacs] Assimilate (the awesome) expand-region 0.11.0-18-ged32924
[~bandali/configs] / init.org
index cd210db..3ae9946 100644 (file)
--- a/init.org
+++ b/init.org
@@ -646,18 +646,31 @@ Enable =winner-mode=.
 (winner-mode 1)
 #+end_src
 
-*** COMMENT Close =*compilation*= on success
+*** Don’t display =*compilation*= on success
+
+Based on https://stackoverflow.com/a/17788551, with changes to use
+=cl-letf= instead of the now obsolete =flet=.
 
 #+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)))
+(use-package compile
+  :config
+  (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-macs)
+
+  (defadvice compilation-start
+      (around inhibit-display
+              (command &optional mode name-function highlight-regexp))
+    (if (not (string-match "^\\(find\\|grep\\)" command))
+        (cl-letf (((symbol-function 'display-buffer) #'ignore))
+          (save-window-excursion ad-do-it))
+      ad-do-it))
+  (ad-activate 'compilation-start))
 #+end_src
 
 *** Search for non-ASCII characters
@@ -810,7 +823,8 @@ file.
     (let* ((file-tangle-start-time (current-time))
            (file (buffer-file-name))
            (file-nodir (file-name-nondirectory file))
-           (async-quiet-switch "-q"))
+           ;; (async-quiet-switch "-q")
+           )
       (async-start
        `(lambda ()
           (require 'org)
@@ -827,8 +841,7 @@ file.
                                                                   ',file-tangle-start-time)))
                              ""))
                   (when amin-async-tangle-post-compile
-                    (save-window-excursion
-                      (compile amin-async-tangle-post-compile))))
+                    (compile amin-async-tangle-post-compile)))
               (message "Tangling %s failed" ,file-nodir))))))))
 
 (add-to-list
@@ -898,8 +911,9 @@ There's no way I could top that, so I won't attempt to.
 
 #+begin_src emacs-lisp
 (use-package swiper
-  :bind (("C-s" . swiper)
-         ("C-r" . swiper)))
+  :bind (("C-s"   . swiper)
+         ("C-r"   . swiper)
+         ("C-S-s" . isearch-forward)))
 #+end_src
 
 **** Counsel
@@ -941,7 +955,7 @@ There's no way I could top that, so I won't attempt to.
 
   (defun amin|eshell-setup ()
     (make-local-variable 'company-idle-delay)
-    (setq company-idle-delay nil)
+    (defvar company-idle-delay nil)
     (bind-keys :map eshell-mode-map
                ("C-d"   . amin/eshell-quit-or-delete-char)
                ("C-S-l" . amin/eshell-clear)
@@ -980,6 +994,13 @@ There's no way I could top that, so I won't attempt to.
    '(("default"
       ("dired" (mode . dired-mode))
       ("org"   (mode . org-mode))
+      ("gnus"
+       (or
+        (mode . gnus-group-mode)
+        (mode . gnus-summary-mode)
+        (mode . gnus-article-mode)
+        ;; not really, but...
+        (mode . message-mode)))
       ("web"
        (or
         (mode . web-mode)
@@ -989,20 +1010,21 @@ There's no way I could top that, so I won't attempt to.
       ("shell"
        (or
         (mode . eshell-mode)
-        (mode . shell-mode)))
-      ("notmuch" (name . "\*notmuch\*"))
+        (mode . shell-mode)
+        (mode . term-mode)))
       ("programming"
        (or
         (mode . python-mode)
+        (mode . c-mode)
         (mode . c++-mode)
-        (mode . emacs-lisp-mode)))
+        (mode . emacs-lisp-mode)
+        (mode . scheme-mode)
+        (mode . haskell-mode)
+        (mode . lean-mode)))
       ("emacs"
        (or
         (name . "^\\*scratch\\*$")
-        (name . "^\\*Messages\\*$")))
-      ("slack"
-       (or
-        (name . "^\\*Slack*"))))))
+        (name . "^\\*Messages\\*$"))))))
   (ibuffer-formats
    '((mark modified read-only locked " "
            (name 18 18 :left :elide)
@@ -1968,6 +1990,13 @@ Hopefully temporary.
   (global-page-break-lines-mode))
 #+end_src
 
+** expand-region
+
+#+begin_src emacs-lisp
+(use-package expand-region
+  :bind ("C-=" . er/expand-region))
+#+end_src
+
 * Email
 
 #+begin_src emacs-lisp