forked from blastura/dot-emacs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
aj-read-only-keymap-hooks.el
33 lines (27 loc) · 1 KB
/
aj-read-only-keymap-hooks.el
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
(add-hook 'find-file-hook
'(lambda ()
(toggle-read-only 1)
(message "Read-only")))
(defvar aj-read-only-mode-map
(let ((map (make-keymap)))
(suppress-keymap map)
;; (define-key map [mouse-2] 'dired-mouse-find-file-other-window)
;; (define-key map [follow-link] 'mouse-face)
(define-key map "n" 'next-line)
(define-key map "p" 'previous-line)
(define-key map "f" 'forward-char)
(define-key map "b" 'backward-char)
(define-key map "a" 'move-beginning-of-line)
(define-key map "e" 'move-end-of-line)
(define-key map "v" 'scroll-up)
(define-key map "k" 'kill-line)
(define-key map (kbd "SPC") 'set-mark-command)
map)
"Local keymap for read-only buffers.")
(defadvice toggle-read-only (after aj-read-only-toggle-keymap())
"Toggle keymap for read-only buffers"
(if buffer-read-only
(use-local-map aj-read-only-mode-map)
(use-local-map nil)))
(ad-activate 'toggle-read-only)
(provide 'aj-read-only-keymap-hooks)