emacs - toggle-project-eshell
[dotfiles.git] / emacs.d / config.org
index 7ee4310..0dbf2d5 100644 (file)
@@ -314,14 +314,13 @@ improve color for org-mode
 #+END_SRC
 
 ** page-break-lines
-
 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
-
   (use-package page-break-lines
     :ensure t
     :config
-    (turn-on-page-break-lines-mode))
-
+    (global-page-break-lines-mode)
+    ;; (turn-on-page-break-lines-mode)
+    )
 #+END_SRC
 
 ** rainbow-mode
@@ -340,9 +339,7 @@ Enable rainbow mode in emacs lisp mode
 * Mode-line
 
 ** clean mode line
-
-clean mode line, Refer to [[https://www.masteringemacs.org/article/hiding-replacing-modeline-strings][Marstering Emacs]]
-
+clean mode line, Refer to [[https://www.masteringemacs.org/article/hiding-replacing-modeline-strings][Marstering Emacs]], some greek character see [[http://xahlee.info/math/math_unicode_greek.html][math_unicode_greek]]
 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
   (defvar mode-line-cleaner-alist
     `((auto-complete-mode . " α")
@@ -365,13 +362,17 @@ clean mode line, Refer to [[https://www.masteringemacs.org/article/hiding-replac
       (org-indent-mode . "")
       ;; default is  Fly
       (flyspell-mode . "")
-      (irony-mode . "I")
+      (irony-mode . "")
+      (page-break-lines-mode . "")
       ;; Major modes
       (lisp-interaction-mode . "λ")
       (hi-lock-mode . "")
       (python-mode . "Py")
       (emacs-lisp-mode . "EL")
-      (eshell-mode . "ε")
+      (eshell-mode . "𝞔")
+      (dired-mode . "𝞓")
+      (ibuffer-mode . "𝞑")
+      (org-mode . "𝞞")
       (nxhtml-mode . "nx"))
     "Alist for `clean-mode-line'.
 
@@ -397,9 +398,7 @@ clean mode line, Refer to [[https://www.masteringemacs.org/article/hiding-replac
 #+END_SRC
 
 ** Powerline mode
-
 Install powerline mode [[https://github.com/milkypostman/powerline][powerline]]
-
 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
   (use-package powerline
     :ensure t
@@ -525,7 +524,7 @@ set height in mode line
 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
   (use-package ido
     :ensure t
-    :init (setq ido-enable-flex-matching t
+    :init (setq ido-enable-flex-matching nil
                 ido-ignore-extensions t
                 ido-use-virtual-buffers t
                 ido-everywhere t)
@@ -542,9 +541,9 @@ set height in mode line
 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
   (use-package flx-ido
     :ensure t
-    :init (setq ido-enable-flex-matching t
+    :init (setq ido-enable-flex-matching nil
                 ido-use-faces nil)
-    :config (flx-ido-mode 1))
+    :config (flx-ido-mode nil))
 #+END_SRC
 
 ** IDO-vertically
@@ -1070,7 +1069,7 @@ Toggle an eshell in split window below, refer [[http://www.howardism.org/Technic
                     nil nil)
       ret))
 
-  (defun sd/toggle-eshell-here ()
+  (defun sd/toggle-project-eshell ()
     "Toggle a eshell buffer vertically"
     (interactive)
     (if (sd/window-has-eshell)
@@ -1081,26 +1080,34 @@ Toggle an eshell in split window below, refer [[http://www.howardism.org/Technic
                 (delete-window)))
           (select-window (sd/window-has-eshell)))
       (progn
-        (let ((dir default-directory))
+        (split-window-vertically (- (/ (window-total-height) 3)))
+        (other-window 1)
+        (if (projectile-project-p)
+            (projectile-run-eshell)
+          (eshell))
+        ;; (let ((dir default-directory))
         
-          (split-window-vertically (- (/ (window-total-height) 3)))
-          (other-window 1)
-          (unless (and (boundp 'eshell-buffer-name) (get-buffer eshell-buffer-name))
-            (eshell))
-          (switch-to-buffer eshell-buffer-name)
-          (goto-char (point-max))
-          (eshell-kill-input)
-          (insert (format "cd %s" dir))
-          (eshell-send-input)))))
+        ;;   (split-window-vertically (- (/ (window-total-height) 3)))
+        ;;   (other-window 1)
+        ;;   (unless (and (boundp 'eshell-buffer-name) (get-buffer eshell-buffer-name))
+        ;;     (eshell))
+        ;;   (switch-to-buffer eshell-buffer-name)
+        ;;   (goto-char (point-max))
+        ;;   (eshell-kill-input)
+        ;;   (insert (format "cd %s" dir))
+        ;;   (eshell-send-input))
+        )))
 
   ;; (global-unset-key (kbd "M-`"))
-  (global-set-key (kbd "s-e") 'sd/toggle-eshell-here)
+  (global-set-key (kbd "s-e") 'sd/toggle-project-eshell)
 #+END_SRC
 
 ** exec-path-from-shell
 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
   (use-package exec-path-from-shell
     :ensure t
+    :init
+    (setq exec-path-from-shell-check-startup-files nil)
     :config
     (exec-path-from-shell-initialize))
 #+END_SRC
@@ -1449,7 +1456,7 @@ Color for Man-mode
     (define-key dired-mode-map (kbd "h") 'dired-summary)
     (define-key dired-mode-map (kbd "r") 'revert-buffer)
     (define-key dired-mode-map (kbd "l") 'dired-display-file)
-    (define-key dired-mode-map [C-backspace] 'sd/dired-high-level-dir)
+    (define-key dired-mode-map [C-backspace] 'dired-up-directory)
     (define-key dired-mode-map (kbd "?") 'describe-mode)
     (define-key dired-mode-map (kbd "z") #'sd/dired-get-size)
     (define-key dired-mode-map (kbd "C-d") 'dired-kill-subdir)
@@ -1547,6 +1554,34 @@ here on Mac, just use "open" commands to pen =.pdf=,  =.html= and image files
           ("\\.html?\\'" "open")
           ("\\.dmg\\'" "open")
           ("\\.cue?\\'" "audacious")))
+
+
+  (defun sd/dired-start-process (cmd &optional file-list)
+    (interactive
+     (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))
+        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 "\" \""))))))
 #+END_SRC
 
 ** dired-hacks
@@ -1712,6 +1747,7 @@ to call =compilation=  interactively.
   (use-package flycheck
     :ensure t)
 #+END_SRC
+
 *** irony
 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
   (use-package irony
@@ -2185,7 +2221,9 @@ Use =ESC= to exit minibuffer. Also I map =Super-h= the same as =C-g=
     :ensure t
     :init
     (setq projectile-enable-caching t)
-    (setq projectile-switch-project-action 'projectile-dired)
+    (setq projectile-switch-project-action (lambda ()
+                                             (projectile-dired)
+                                             (sd/project-switch-action)))
     (setq projectile-cache-file (concat sd-temp-directory "projectile.cache"))
     :config
     (add-to-list 'projectile-globally-ignored-files "GTAGS")
@@ -2199,9 +2237,23 @@ Use =ESC= to exit minibuffer. Also I map =Super-h= the same as =C-g=
     (:map projectile-mode-map
           ("s-t" . projectile-persp-switch-project)))
 
-  ;; projectile-find-file
-  ;; projectile-switch-buffer
-  ;; projectile-find-file-other-window
+  ;; (defun sd/change-default-directory (buffer dir)
+  ;;   "change defafult directory of buffer to dir"
+  ;;   (with-current-buffer buffer
+  ;;     (cd dir)))
+
+  ;; change default-directory of scratch buffer to projectile-project-root 
+  (defun sd/project-switch-action ()
+    "Change default-directory of scratch buffer to current projectile-project-root directory"
+    (interactive)
+    (dolist (buffer (buffer-list))
+      (if (string-match (concat "scratch.*" (projectile-project-name))
+                        (buffer-name buffer))
+          (let ((root (projectile-project-root)))
+            (with-current-buffer buffer
+              (cd root)))
+        ;; (sd/change-default-directory buffer (projectile-project-root))
+        )))
 #+END_SRC
 
 *** project config =super= keybindings
@@ -2347,7 +2399,7 @@ Most use =C-o C-o= to switch buffers; =C-o x, v= to split window; =C-o o= to del
     ("C-o" ido-switch-buffer nil :exit t)
     ("d" sd/project-or-dired-jump nil :exit t)
     ("b" ibuffer nil :exit t)
-    ("e" eshell nil :exit t)
+    ("e" sd/toggle-project-eshell nil :exit t)
     ("m" bookmark-jump-other-window nil :exit t)
     ("M" bookmark-set nil :exit t)
     ("g" magit-status nil :exit t)