Emacs - hydra with winner-mode
[dotfiles.git] / emacs.d / config.org
index c80ebdb..f122389 100644 (file)
@@ -44,7 +44,7 @@ Set system PATH and emacs exec path
         (menu-bar-mode 1))
     (menu-bar-mode 0))
 
-  (setq debug-on-error t)
+  ;; (setq debug-on-error t)
   (setq inhibit-startup-message t)
 
   (defalias 'yes-or-no-p 'y-or-n-p)
@@ -730,6 +730,7 @@ let helm windows split inside current window
     (ivy-shrink-after-dispatching))
 
   (with-eval-after-load "ivy"
+    (define-key ivy-minibuffer-map (kbd "C-o") 'ivy-dispatching-done)
     (define-key ivy-minibuffer-map (kbd "C-k") #'sd/swith-buffer-other-window))
 #+END_SRC
 
@@ -738,10 +739,6 @@ stolen from [[https://github.com/mariolong/emacs.d/blob/f6a061594ef1b5d1f4750e9d
   (use-package swiper
     :ensure t
     ;; :init
-    ;(require 'ivy)
-    ;; (setq ivy-use-virtual-buffers nil)
-    ;; (setq ivy-wrap t)
-    ;(set-face-attribute 'ivy-current-match nil :background "Orange" :foreground "black")
     :config
     ;; (ivy-mode)
     (global-set-key (kbd "s-/") 'swiper)
@@ -1361,9 +1358,18 @@ set default eshell history folder
 
   ;; (add-hook 'eshell-mode-hook (lambda ()
   ;;                               (local-set-key (kbd "C-l") 'sd/eshell-clear-buffer)))
-  (add-hook 'eshell-mode-hook (apply-partially #'local-set-key (kbd "C-l") 'sd/eshell-clear-buffer))
   ;; (add-hook 'eshell-mode-map (lambda () (interactive)
   ;;                              (define-key eshell-mode-map (kbd "<tab>") 'completion-at-point)))
+
+  (defun sd/eshell-hook ()
+    (interactive)
+    (define-key eshell-mode-map (kbd "C-j") #'eshell-send-input)
+    (define-key eshell-mode-map (kbd "C-l") #'sd/eshell-clear-buffer))
+
+  (add-hook 'eshell-mode-hook #'sd/eshell-hook)
+
+
+  ;; (add-hook 'eshell-mode-hook (apply-partially #'local-set-key (kbd "C-l") 'sd/eshell-clear-buffer))
 #+END_SRC
 
 ** Toggle Eshell
@@ -1480,7 +1486,38 @@ Refer [[https://github.com/abo-abo/hydra/blob/master/hydra-examples.el][hydra-ex
     ("q" nil "quit")
     ("f" nil "quit"))
 
-  (global-set-key (kbd "C-'") 'sd/hydra-misc/body)
+  ;; (global-set-key (kbd "C-'") 'sd/hydra-misc/body)
+
+  (defun sd/exchange-win-layout ()
+    "Change the windos layout."
+    (interactive)
+    (when (equal (length (window-list)) 2)
+      (let ((current-layout (if (or (window-in-direction 'right) (window-in-direction 'left))
+                                'v
+                              'h))
+            (other-buf (window-buffer (or (window-in-direction 'right)
+                                          (window-in-direction 'left)
+                                          (window-in-direction 'below)
+                                          (window-in-direction 'above)))))
+        (delete-other-windows)
+        (if (eq current-layout 'v)
+            (split-window-below)
+          (split-window-right))
+        (other-window 1)
+        (switch-to-buffer other-buf))))
+
+  (defhydra sd/hydra-window-layout (:color red :colums nil)
+    "Window Layout"
+    ("m" sd/toggle-max-windows "Max-win" :exit t)
+    ("s" ace-swap-window "Swap" :exit t)
+    ("d" ace-delete-window "Delete"  :exit t)
+    ("x" sd/exchange-win-layout "eXchange"  :exit t)
+    ("u" winner-undo "window-Undo"  :exit t)
+    ("r" winner-redo "window-Redo"  :exit t))
+
+  (with-eval-after-load "evil"
+    (define-key evil-normal-state-map (kbd ";t") 'sd/hydra-window-layout/body))
+
 #+END_SRC
 
 *** hydra launcher
@@ -1607,6 +1644,7 @@ When see function by =C-h f=, and visit the source code, I would like the buffer
              ;; (eval . (when buffer-file-name
              ;;           (setq-local view-no-disable-on-exit t)
              ;;           (view-mode-enter)))
+             (projectile-enable-caching . nil)
              ))))
 
   ;; (dir-locals-set-directory-class (expand-file-name "/usr/local/share/emacs") 'emacs)
@@ -3128,7 +3166,7 @@ Use =ESC= to exit minibuffer. Also I map =Super-h= the same as =C-g=
 
 
   ;; https://emacs.stackexchange.com/questions/16497/how-to-exclude-files-from-projectile
-  (setq projectile-enable-caching t)
+  ;; (setq projectile-enable-caching t)
   (if (executable-find "rg")
       (progn
         (defconst modi/rg-arguments