Emacs - some dired mapping
authorPeng Li <seudut@gmail.com>
Thu, 21 Sep 2017 05:15:12 +0000 (13:15 +0800)
committerPeng Li <seudut@gmail.com>
Tue, 26 Sep 2017 18:29:07 +0000 (02:29 +0800)
emacs.d/config.org
emacs.d/emacs-evil.org

index 2c89c18..ec33c49 100644 (file)
@@ -1727,28 +1727,6 @@ as a http download client tool
                                   (car (last (split-string url "/" t))))))))))
 #+END_SRC
 
-** Elscreen
-Fix one elscreen issue when startup emacs https://github.com/knu/elscreen/issues/6
-#+BEGIN_SRC emacs-lisp :tangle yes :results silent
-  ;; (use-package elscreen
-  ;;   :ensure t
-  ;;   :init
-  ;;   (setq elscreen-tab-display-control nil)
-  ;;   :config
-  ;;   ;; (elscreen-start)
-  ;;   (set-face-attribute 'elscreen-tab-current-screen-face nil :foreground "black" :background "yellow")
-  ;;   (set-face-attribute 'elscreen-tab-other-screen-face nil :foreground "black" :background "disabledControlTextColor" :underline nil)
-  ;;   ;; (global-unset-key (kbd)); M-TAB switch screen
-  ;;   ;; (global-set-key (kbd "s-`") '(lambda () (interactive) (elscreen-goto 0)))
-  ;;   ;; (dotimes (i 8)
-  ;;   ;;   (global-set-key (kbd (concat "s-" (number-to-string (+ i 1))))
-  ;;   ;;                   `(lambda () (interactive) (elscreen-goto ,(+ i 1)))))
-  ;;   ;; (global-set-key (kbd "s-t") 'elscreen-create)
-  ;;   ;; (global-set-key (kbd "s-n") 'elscreen-next)
-  ;;   ;; (global-set-key (kbd "s-p") 'elscreen-previous)
-  ;;   )
-#+END_SRC
-
 * Dired
 ** Dired basic
 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
@@ -1760,6 +1738,28 @@ Fix one elscreen issue when startup emacs https://github.com/knu/elscreen/issues
     (setq-default dired-details-hidden-string "--- ")
     (dired-details-install))
 #+END_SRC
+
+** Dired functions
+#+BEGIN_SRC emacs-lisp :tangle yes :results silent
+  (defun sd/dired-next-line (count)
+    "Move to next line, and always focus on the file name."
+    (interactive "p")
+    (dired-next-line count)
+    (dired-move-to-filename))
+
+  (defun sd/dired-previous-line (count)
+    "Move to previous line, and always focus on the file name."
+    (interactive "p")
+    (dired-previous-line count)
+    (dired-move-to-filename))
+
+  (defun sd/dired-up-directory ()
+    "Go to up directory"
+    (interactive)
+    (let ((old (current-buffer)))
+      (dired-up-directory)
+      (kill-buffer old)))
+#+END_SRC
 ** Dired bindings
 =C-o= is defined as a global key for window operation, here unset it in dired mode
 #+BEGIN_SRC emacs-lisp :tangle yes :results silent
@@ -2454,21 +2454,6 @@ Set the environments vairables in compilation mode
     (define-key compilation-mode-map (kbd "q") (lambda () (interactive) (quit-window t)))
     (define-key compilation-mode-map (kbd "r") #'recompile))
 
-
-  ;; (loop for (mode . program) in '(
-  ;;                                 (lua-mode-hook . "lua")
-  ;;                                 (perl-mode-hook . "perl")
-  ;;                                 (python-mode-hook . "python")
-  ;;                                 (shell-mode-hook . "sh"))
-  ;;       do (add-hook mode `(lambda ()
-  ;;                           (unless (or (file-exists-p "makefile")
-  ;;                                       (file-exists-p "Makefile"))
-  ;;                             (set (make-local-variable 'compile-command)
-  ;;                                  (concat ,program
-  ;;                                          " "
-  ;;                                          (if buffer-file-name
-  ;;                                              (shell-quote-argument buffer-file-name))))))))
-
   ;; here note dynamic binding the value of vv, otherwise it will resport error when run the hook.
   ;; https://emacs.stackexchange.com/questions/10394/scope-in-lambda
   (dolist (vv '(
index 814ab75..ca30b23 100644 (file)
@@ -35,7 +35,8 @@ https://www.emacswiki.org/emacs/Evil.
 
   (add-hook 'prog-mode-hook #'(lambda ()
                                 (modify-syntax-entry ?_ "w")
-                                (modify-syntax-entry ?- "w")))
+                                ;; (modify-syntax-entry ?- "w")
+                                ))
 #+END_SRC
 
 ** Initial mode and state config
@@ -201,8 +202,9 @@ Let the search highlight persistent, https://stackoverflow.com/questions/2576803
     (evil-define-key 'normal dired-mode-map (kbd "K") 'diredp-prev-subdir)
     (evil-define-key 'normal dired-mode-map (kbd "l") 'dired-display-file)
     (evil-define-key 'normal dired-mode-map (kbd "f") 'dired-narrow)
-    (evil-define-key 'normal dired-mode-map (kbd "j") 'dired-next-line)
-    (evil-define-key 'normal dired-mode-map (kbd "k") 'dired-previous-line)
+    (evil-define-key 'normal dired-mode-map (kbd "j") 'sd/dired-next-line)
+    (evil-define-key 'normal dired-mode-map (kbd "k") 'sd/dired-previous-line)
+    (evil-define-key 'normal dired-mode-map (kbd "h") 'sd/dired-up-directory)
     (evil-define-key 'normal dired-mode-map [C-backspace] 'dired-up-directory)
     ;; file and folder deletion
     (evil-define-key 'normal dired-mode-map (kbd "m") 'dired-mark)