summary refs log tree commit diff stats
path: root/lisp/acdw-reading.el
blob: e3d5716221f1e3993d0eb897684253651b35a1f4 (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
;;; acdw-reading.el --- minor mode for reading -*- lexical-binding: t -*-

;; Copyright 2021 Case Duckworth <(rot13-string "npqj@npqj.arg")>
;; This file is NOT part of GNU Emacs.

;;; License:

;; Everyone is permitted to do whatever with this software, without
;; limitation.  This software comes without any warranty whatsoever,
;; but with two pieces of advice:
;; - Don't hurt yourself.
;; - Make good choices.

;;; Commentary:

;; here is my attempt at a reading mode.

;;; Code:

(defvar-local //indicate-empty-lines nil)
(defvar-local //indicate-buffer-boundaries nil)

;;;###autoload
(define-minor-mode reading-mode
  "A mode for reading."
  :init-value nil
  :lighter " Read"
  :keymap (make-sparse-keymap)
  (if reading-mode
      (progn ;; turn on
        ;; settings
        (setq-local //indicate-empty-lines indicate-empty-lines
                    indicate-empty-lines nil
                    //indicate-buffer-boundaries indicate-buffer-boundaries
                    indicate-buffer-boundaries nil)
        ;; disable modes
        (dolist (mode '(display-fill-column-indicator-mode
                        blink-cursor-mode))
          (when (fboundp mode)
            (set (make-local-variable
                  (intern (format "//%s" mode)))
                 (and (boundp mode)
                      (symbol-value mode)))
            (funcall mode -1)))
        ;; enable modes
        (dolist (mode '(olivetti-mode))
          (when (fboundp mode)
            (set (make-local-variable
                  (intern (format "//%s" mode)))
                 (and (boundp mode)
                      (symbol-value mode)))
            (funcall mode +1))))
    ;; turn off
    ;; restore settings
    (setq-local indicate-empty-lines //indicate-empty-lines
                indicate-buffer-boundaries //indicate-buffer-boundaries)
    ;; restore modes
    (dolist (mode '(display-fill-column-indicator-mode
                    olivetti-mode
                    blink-cursor-mode))
      (when (fboundp mode)
        (funcall mode (if (symbol-value (intern (format "//%s" mode)))
                          +1
                        -1))))))

(provide 'acdw-reading)
;;; acdw-reading.el ends here