emacs - pdf-tools mappings
[dotfiles.git] / emacs.d / config.org
index 63cf180..300360d 100644 (file)
@@ -1400,19 +1400,47 @@ Color for Man-mode
     (define-key org-tree-slide-mode-map [escape] 'org-tree-slide-move-previous-tree))
 #+END_SRC
 
+** pdf-tools
+#+BEGIN_SRC bash
+  brew install poppler
+#+END_SRC
+
+#+BEGIN_SRC emacs-lisp :tangle yes :results silent
+  (use-package pdf-tools
+    :ensure t
+    :init
+    ;; run to complete the installation
+    (pdf-tools-install)
+    :config
+    (add-to-list 'auto-mode-alist '("\.pdf$" . pdf-view-mode))
+    (define-key pdf-outline-buffer-mode-map (kbd "C-o") nil)
+    (define-key pdf-outline-buffer-mode-map (kbd "i") 'outline-toggle-children)
+    (define-key pdf-outline-buffer-mode-map (kbd "j") 'next-line)
+    (define-key pdf-outline-buffer-mode-map (kbd "k") 'previous-line))
+#+END_SRC
+
 * Dired
 ** Dired config
 =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
+  (defun sd/dired-key-map ()
+    "My keybindings for dired"
+    (interactive)
+    (define-key dired-mode-map (kbd "SPC") 'scroll-up-command)
+    (define-key dired-mode-map (kbd "S-SPC") 'scroll-down-command)
+    (define-key dired-mode-map (kbd "C-o") nil)
+    (define-key dired-mode-map (kbd "M-s") nil)
+    (define-key dired-mode-map (kbd "l") 'dired-isearch-filenames)
+    (define-key dired-mode-map (kbd "H") 'dired-omit-mode)
+    (define-key dired-mode-map (kbd "DEL") (lambda () (interactive) (find-alternate-file ".."))))
+
   (use-package dired
     :config
     (require 'dired-x)
     (setq dired-omit-mode t)
     (setq dired-omit-files (concat dired-omit-files "\\|^\\..+$"))
     (add-hook 'dired-mode-hook (lambda ()
-                                 (define-key dired-mode-map (kbd "C-o") nil)
-                                 (define-key dired-mode-map (kbd "H") 'dired-omit-mode)
-                                 (define-key dired-mode-map (kbd "DEL") (lambda () (interactive) (find-alternate-file "..")))
+                                 (sd/dired-key-map)
                                  (dired-omit-mode))))
 #+END_SRC
 
@@ -2522,17 +2550,17 @@ stolen from [[https://github.com/mariolong/emacs.d/blob/f6a061594ef1b5d1f4750e9d
     (set-mark (line-end-position)))
 
   (defhydra sd/expand-selected (:color red :columns nil
-                                       ;; :post (deactivate-mark)
+                                       :post (deactivate-mark)
                                        )
     "Selected"
     ;; select
     ;; ("e"  er/expand-region "+")
-    ("SPC"  er/expand-region "+")
+    ("SPC" er/expand-region "+")
     ;; ("c"  er/contract-region "-")
-    ("S-SPC"  er/contract-region "-")
-    ("r"  (lambda ()
-            (interactive)
-            (er/contract-region 0))
+    ("S-SPC" er/contract-region "-")
+    ("r" (lambda ()
+           (interactive)
+           (er/contract-region 0))
      "reset")
 
     ("i'" er/mark-inside-quotes "in")
@@ -2545,21 +2573,15 @@ stolen from [[https://github.com/mariolong/emacs.d/blob/f6a061594ef1b5d1f4750e9d
     ("o{" er/mark-inside-pairs nil)
     ("o(" er/mark-inside-pairs nil)
 
-    ("p"  er/mark-paragraph "paragraph")
+    ("p" er/mark-paragraph "paragraph")
 
-    ("l"  sd/mark-line "line")
-    ("u"  er/mark-url "url")
-    ("f"  er/mark-defun "fun")
-    ("n"  er/mark-next-accessor "next")
+    ("l" sd/mark-line "line")
+    ("u" er/mark-url "url")
+    ("f" er/mark-defun "fun")
+    ("n" er/mark-next-accessor "next")
 
     ("x" exchange-point-and-mark "exchange")
 
-    ;; Move
-    ;; ("h" backward-char nil)
-    ;; ("j" next-line nil)
-    ;; ("k" previous-line nil)
-    ;; ("l" foreward-char nil)
-
     ;; Search
     ;; higlight
 
@@ -2567,13 +2589,14 @@ stolen from [[https://github.com/mariolong/emacs.d/blob/f6a061594ef1b5d1f4750e9d
     ("d" kill-region "delete" :exit t)
 
     ("y" kill-ring-save "yank" :exit t)
-    ;; ("M-SPC" nil "quit" :exit t)
-    ("C-SPC" nil "quit" :exit t)
-    ("q" nil "quit" :exit t))
+    ("M-SPC" nil "quit" :exit t)
+    ;; ("C-SPC" "quit" :exit t)
+    ("q" deactivate-mark "quit" :exit t))
 
-  (global-set-key (kbd "C-SPC") (lambda ()
+  (global-set-key (kbd "M-SPC") (lambda ()
                                   (interactive)
                                   (set-mark-command nil)
+                                  ;; (er/expand-region 1)
                                   (er/mark-word)
                                   (sd/expand-selected/body)))
 #+END_SRC