summaryrefslogtreecommitdiff
path: root/lisp/init-ace.el
blob: 1635e31db90bbf19a72f5cf8b38004f606df8bff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
(require-package 'ace-jump-mode)
(require-package 'ace-link)
(require-package 'ace-window)

;;; Ace Jump

(key-chord-define-global ";a" 'ace-jump-mode)

(setq ace-jump-mode-scope 'frame)

;;; Ace Link

(ace-link-setup-default)

(after 'org
 (define-key org-mode-map (kbd "C-c m o") 'ace-link-org))

(defun km/ace-link-dired ()
  "Ace jump to files in dired buffers."
  (interactive)
  (ali-generic
      (km/ali--dired-collect-references)
    (org-open-file (dired-get-filename))))

(defun km/ali--dired-collect-references ()
  (let ((end (window-end))
        points)
    (save-excursion
      (goto-char (window-start))
      (while (< (point) end)
        (-when-let (pos (dired-next-line 1))
          (push pos points)))
      (nreverse points))))

(after 'dired
  ;; This overrides the binding for `dired-find-file-other-window', which
  ;; is rebound to 'r'.
  (define-key dired-mode-map "o" 'km/ace-link-dired)
  (define-key dired-mode-map "r" 'dired-find-file-other-window))

;;; Ace Window

(define-key window-map "a" 'ace-window)
(setq aw-keys '(?a ?s ?d ?f ?g ?h ?j ?k ?l)
      aw-scope 'global)

(key-chord-define-global ",w" 'ace-window)

(provide 'init-ace)