emacs - swiper tidyup
[dotfiles.git] / emacs.d / config.org
index 690bbe6..bc97b89 100644 (file)
@@ -7,7 +7,6 @@
 Most config are just copied from [[https://github.com/howardabrams/dot-files][howardabrams]]'s and [[https://github.com/abo-abo/oremacs][abo-abo's]] dotfiles
 
 * Basic Settings
-
 ** Setting loading Path
 
 Set system PATH and emacs exec path
@@ -42,10 +41,8 @@ Set the emacs load path
 
 #+END_SRC       
 
-** Window Setting
-
-Disable scroll bar, tool-bar and menu-bar
-
+** General Setting
+*** scroll bar, tool-bar and menu-bar
 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
   (scroll-bar-mode 0)
   (tool-bar-mode 0)
@@ -60,38 +57,26 @@ Disable scroll bar, tool-bar and menu-bar
   (setq make-backup-files nil)
 #+END_SRC
 
-set custom file 
-
+*** Custom file 
 #+BEGIN_SRC emacs-lisp :tangle yes :results silent 
-
   (setq custom-file "~/.emacs.d/custom.el")
   (if (file-exists-p custom-file)
       (load custom-file))
-
 #+END_SRC
 
-Switch the focus to help window when it appears
-
+*** Switch the focus to help window when it appears
 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
-
   (setq help-window-select t)
-
 #+END_SRC
 
-Setting scroll right/left
-#+BEGIN_SRC emacs-lisp :tangle yes :results silent
-  ;  (global-set-key (kbd "C-,") 'scoll-left)
-  ;  (global-set-key (kbd "C-.") 'scoll-right)
-#+END_SRC
-
-Set default window size
+*** Set default window size
 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
   (setq initial-frame-alist
         '((width . 120)
           (height . 50)))
 #+END_SRC
 
-Stop auto save
+*** Stop auto save
 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
   (setq auto-save-default nil)
 
@@ -99,6 +84,22 @@ Stop auto save
   ;; (desktop-save-mode t)
 #+END_SRC
 
+*** Save minibuffer history
+#+BEGIN_SRC emacs-lisp :tangle yes :results silent
+  (savehist-mode 1)
+  (setq history-length 1000)
+#+END_SRC
+
+*** temp folder
+Make a temp directory for all cache/history files
+#+BEGIN_SRC emacs-lisp :tangle yes :results silent
+  (defconst sd-temp-directory
+    (file-name-as-directory "~/.emacs.d/temp"))
+
+  (unless (file-exists-p sd-temp-directory)
+    (mkdir sd-temp-directory))
+#+END_SRC
+
 * Package Management Tools
 
 ** Use-package
@@ -783,12 +784,12 @@ Some global bindings on =Super=, on Mac, it is =Command=
 ** Search Replace and highlight
 *** swiper
 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
-  (use-package swiper
-    :ensure t)
+  ;; (use-package swiper
+  ;;   :ensure t)
 
-  (ivy-mode 1)
-  (setq ivy-use-virtual-buffers t)
-  (global-set-key (kbd "s-/") 'swiper)
+  ;; (ivy-mode 1)
+  ;; (setq ivy-use-virtual-buffers t)
+  ;; (global-set-key (kbd "s-/") 'swiper)
 
   (use-package counsel
     :ensure t
@@ -811,10 +812,13 @@ Some global bindings on =Super=, on Mac, it is =Command=
   ;; (global-set-key (kbd "C-S-o") 'counsel-rhythmbox)
   ;; ;; (define-key read-expression-map (kbd "C-r") 'counsel-expression-history)
 
-  (set-face-attribute
-   'ivy-current-match nil
-   :background "Orange"
-   :foreground "black")
+  ;; (set-face-attribute
+  ;;  'ivy-current-match nil
+  ;;  :background "Orange"
+  ;;  :foreground "black")
+
+  ;; ivy-resume
+  ;; (define-key swiper-map (kbd "M-%") 'swiper-aa-replace)
 #+END_SRC
 
 *** =M-s= prefix
@@ -1266,6 +1270,12 @@ and Defined keys, using vi keybindings, Refer abo-abo's setting [[https://github
   (defalias 'ee 'find-files)
 #+END_SRC
 
+*** eshell temp directory
+set default eshell history folder
+#+BEGIN_SRC emacs-lisp :tangle yes :results silent
+  (setq eshell-directory-name (concat  sd-temp-directory "eshell"))
+#+END_SRC
+
 *** Eshell erase buffer
 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
   (defun sd/eshell-clear-buffer ()
@@ -2401,6 +2411,55 @@ Occur search key bindings
     (use-package moccur-edit))
 #+END_SRC
 
+*** Swiper
+stolen from [[https://github.com/mariolong/emacs.d/blob/f6a061594ef1b5d1f4750e9dad9dc97d6e122840/emacs-init.org][here]]
+#+BEGIN_SRC emacs-lisp :tangle yes :results silent
+  (use-package swiper
+    :ensure t
+    :init
+    (setq ivy-use-virtual-buffers t)
+    (set-face-attribute 'ivy-current-match nil :background "Orange" :foreground "black")
+    :config
+    (ivy-mode)
+    (global-set-key (kbd "s-/") 'swiper)
+    (define-key swiper-map (kbd "M-r") 'swiper-query-replace)
+    (define-key swiper-map (kbd "C-.") (lambda ()
+                                         (interactive)
+                                         (insert (format "%s" (with-ivy-window (thing-at-point 'word))))))
+    (define-key swiper-map (kbd "M-.") (lambda ()
+                                         (interactive)
+                                         (insert (format "%s" (with-ivy-window (thing-at-point 'symbol)))))))
+#+END_SRC
+
+* TODO Temp directory for cached/history/temp files
+#+BEGIN_SRC emacs-lisp :tangle yes :results silent
+  (use-package recentf
+    :config
+    (setq recentf-save-file (concat sd-temp-directory "recentf")))
+
+  (use-package projectile
+    :config
+    (setq projectile-cache-file (concat sd-temp-directory "projectile.cache")))
+
+  (use-package ido
+    :config
+    (setq ido-save-directory-list-file (concat sd-temp-directory "ido.last")))
+
+  (use-package savehist
+    :config
+    (setq savehist-file (concat sd-temp-directory "history")))
+
+  (use-package emms
+    :config
+    (setq emms-directory (concat sd-temp-directory "emms")))
+
+  (setq auto-save-list-file-prefix (concat sd-temp-directory "auto-save-list/.saves-")) 
+
+  (use-package smex
+    :config
+    (setq smex-save-file (concat sd-temp-directory "smex-items")))
+#+END_SRC
+
 * test
 #+BEGIN_SRC ditaa :file temp/hello-world.png :cmdline -r
 +--------------+