summaryrefslogtreecommitdiff
path: root/subed-conf.el
blob: 0a3325360134762aab288e393a0889e865245f8c (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
;;; subed-conf.el --- Configurations of Subed        -*- lexical-binding: t; -*-

;; Copyright (C) 2021  Durand

;; Author: 李俊緯 <mmemmew@gmail.com>
;; Keywords: convenience, multimedia, data

;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program.  If not, see <https://www.gnu.org/licenses/>.

;;; Commentary:

;; My configurations of the superb package subed:
;; https://github.com/sachac/subed

;;; Code:

;;; Load package

(use-package "subed/subed" 'subed)

;;; Use a shorter name for the socket

(setq subed-mpv-socket-dir "/tmp/")

;;; Make some modifications so that mpv works

(defun durand-subed-mpv--socket ()
  "Path to mpv's RPC socket for a particular buffer.
See also `subed-mpv-socket-dir'."
  (unless (file-exists-p subed-mpv-socket-dir)
    (condition-case err
        (make-directory subed-mpv-socket-dir :create-parents)
      (file-error
       (error "%s" (mapconcat #'identity (cdr err) ": ")))))
  (concat (file-name-as-directory subed-mpv-socket-dir)
          (truncate-string-to-width
           (format "%s%s"
                   (let ((filename (file-name-sans-extension (subed--buffer-file-name))))
                     (substring (substring filename 0 (min (length filename) 20))))
                   (buffer-hash))
           15)))

(advice-add #'subed-mpv--socket :override #'durand-subed-mpv--socket)

;;; Normal brackets are easier to hit for me

(define-key subed-mode-map (vector 3 ?\()
  #'subed-copy-player-pos-to-start-time)

(define-key subed-mode-map (vector 3 ?\))
  #'subed-copy-player-pos-to-stop-time)

;;; Disable pausing when typing

(subed-disable-pause-while-typing t)

(provide 'subed-conf)
;;; subed-conf.el ends here