Emacs - dired open file
[dotfiles.git] / emacs.d / config.org
index aea8025..0854ef8 100644 (file)
@@ -112,6 +112,7 @@ Make a temp directory for all cache/history files
 
   ;; set temp file path for recentf and auto-save
   (setq recentf-save-file (concat sd-temp-directory "recentf"))
+  (setq recentf-max-saved-items 1000)
   (setq auto-save-list-file-prefix (concat sd-temp-directory "auto-save-list/.saves-"))
 #+END_SRC
 
@@ -704,8 +705,8 @@ let helm windows split inside current window
           ivy-wrap t)
     (set-face-attribute 'ivy-current-match nil :background "Orange" :foreground "black")
     (global-set-key (kbd "M-x") 'counsel-M-x)
-    (global-set-key (kbd "C-h f") 'counsel-describe-function)
-    (global-set-key (kbd "C-h v") 'counsel-describe-variable)
+    ;; (global-set-key (kbd "C-h f") 'counsel-describe-function)
+    ;; (global-set-key (kbd "C-h v") 'counsel-describe-variable)
     (global-set-key (kbd "C-x C-f") 'counsel-find-file)
     (define-key read-expression-map (kbd "C-r") 'counsel-expression-history)
     (global-set-key (kbd "C-c C-r") 'ivy-resume))
@@ -1421,9 +1422,10 @@ Toggle an eshell in split window below, refer [[http://www.howardism.org/Technic
 *** hydra install
 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
   (use-package hydra
-    :ensure t)
-  ;; disable new line in minibuffer when hint hydra
-  (setq hydra-lv nil)
+    :ensure t
+    ;; disable new line in minibuffer when hint hydra
+    :init
+    (setq hydra-lv nil))
 #+END_SRC
 
 *** Windmove Splitter
@@ -1486,7 +1488,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
@@ -1751,8 +1784,8 @@ Wiki [[http://stackoverflow.com/questions/3480173/show-keys-in-emacs-keymap-valu
 
 ** goto-last-change
 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
-  (use-package goto-last-change
-    :ensure t)
+  ;; (use-package goto-last-change
+  ;;   :ensure t)
 #+END_SRC
 
 ** Ag
@@ -1995,7 +2028,7 @@ here on Mac, just use "open" commands to pen =.pdf=,  =.html= and image files
           ("\\.csv\\'" "libreoffice")
           ("\\.tex\\'" "pdflatex" "latex")
           ("\\.\\(?:mp4\\|mkv\\|avi\\|rmvb\\|flv\\|ogv\\)\\(?:\\.part\\)?\\'" "mplayer")
-          ("\\.\\(?:mp3\\|flac\\)\\'" "rhythmbox")
+          ("\\.\\(?:mp3\\|flac\\|wav\\)\\'" "mplayer")
           ("\\.html?\\'" "open")
           ("\\.dmg\\'" "open")
           ("\\.cue?\\'" "audacious")))
@@ -2003,30 +2036,27 @@ here on Mac, just use "open" commands to pen =.pdf=,  =.html= and image files
 
   (defun sd/dired-start-process (cmd &optional file-list)
     (interactive
-     (let ((files (dired-get-marked-files
-                   t current-prefix-arg)))
+     (let ((files (dired-get-marked-files t current-prefix-arg)))
        (list
-        (unless (eq system-type 'windows-nt)
-          (dired-read-shell-command "& on %s: "
-                                    current-prefix-arg files))
+        (dired-read-shell-command "& on %s: " current-prefix-arg files)
         files)))
     
-    (if (eq system-type 'windows-nt)
-        (dolist (file file-list)
-          (w32-shell-execute "open" (expand-file-name file)))
-      (let (list-switch)
-        (start-process
-         cmd nil shell-file-name
-         shell-command-switch
-         (format
-          "nohup 1>/dev/null 2>/dev/null %s \"%s\""
-          cmd
-          ;; (if (and (> (length file-list) 1)
-          ;;          (setq list-switch
-          ;;                (cadr (assoc cmd ora-dired-filelist-cmd))))
-          ;;     (format "%s %s" cmd list-switch)
-          ;;   cmd)
-          (mapconcat #'expand-file-name file-list "\" \""))))))
+    ;; (let (list-switch))
+    (start-process
+     cmd nil shell-file-name
+     shell-command-switch
+     (format
+      "nohup 1>/dev/null 2>/dev/null %s \"%s\""
+      cmd
+      ;; (if (and (> (length file-list) 1)
+      ;;          (setq list-switch
+      ;;                (cadr (assoc cmd ora-dired-filelist-cmd))))
+      ;;     (format "%s %s" cmd list-switch)
+      ;;   cmd)
+      (mapconcat #'expand-file-name file-list "\" \""))))
+
+
+
 #+END_SRC
 
 ** dired-hacks