blob: 3d3d7b7039a616b7eb61acfb7eca8515f42fca72 (
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
;;; -*- lexical-binding: t; -*-
;;; Commentary:
;;; Code:
(use-package recentf
:init
(recentf-mode 1)
:custom
(recentf-max-saved-items 3500)
(recentf-keep '(recentf-keep-default-predicate remote-file-p))
(recentf-auto-cleanup 300))
(defun bd/zathura (file)
"Open FILE with zathura."
(start-process "zathura" nil "zathura" (expand-file-name file)))
(defun bd/mpv (file)
"Open FILE with mpv."
(start-process "mpv" nil "mpv" "--force-window=yes" (expand-file-name file)))
(defun bd/nsxiv (file)
"Open FILE with nsxiv."
(start-process "nsxiv" nil "nsxiv" (expand-file-name file)))
(defun bd/rom (file)
"Open FILE with an emulator."
(let ((command
(cdr (assoc (file-name-extension file)
'(("gba" . "mgba")
("z64" . "mupen64plus")
("n64" . "mupen64plus")
("sfc" . "bsnes"))))))
(start-process command nil command (expand-file-name file))))
(defun bd/external-find-file-wrapper (f &rest args)
"Wrapper around F (find-file), passing ARGS."
(defun runner (f)
(funcall f (car args))
(recentf-add-file (car args)))
(let ((ext (or (file-name-extension (car args)) "")))
(cond
((string-match (regexp-opt '("epub" "pdf")) ext)
(runner #'bd/zathura))
((string-match (regexp-opt '("mkv" "mov" "mp4" "webm" "m4v"
"wav" "mp3" "opus" "ogv" "flac"
"m4a")) ext)
(runner #'bd/mpv))
((string-match (regexp-opt '("jpg" "jpeg" "png" "webp"
"ico" "gif" "JPG" "PNG")) ext)
(runner #'bd/nsxiv))
((string-match (regexp-opt '("gba" "z64" "n64" "sfc")) ext)
(runner #'bd/rom))
(t (apply f args)))))
(advice-add #'find-file :around #'bd/external-find-file-wrapper)
(use-package dired
:bind
(("C-c d" . dired-jump))
:custom
(dired-listing-switches "-alhLG --time-style=long-iso --group-directories-first")
(dired-recursive-copies 'always)
(dired-recursive-deletes 'always)
(dired-auto-revert-buffer t)
(dired-dwim-target t)
(dired-guess-shell-alist-user
`((,(regexp-opt '(".pdf")) "pdftotext -nopgbrk -enc UTF-8 -eol unix -layout")
(,(regexp-opt '(".html")) "icecat &"))))
(use-package transmission
:bind
(:map transmission-mode-map
("R" . #'transmission-move)))
(provide 'bd--files)
;;; bd-files ends here
|