diff options
author | Case Duckworth | 2022-10-17 21:41:28 -0500 |
---|---|---|
committer | Case Duckworth | 2022-10-17 21:41:28 -0500 |
commit | aab5bfd074e57d06a79e39d7c7c4760e1f385a06 (patch) | |
tree | 7b111190a44458a970355f7a327cc5278c850293 /lisp/reading.el | |
parent | asoi (diff) | |
download | emacs-aab5bfd074e57d06a79e39d7c7c4760e1f385a06.tar.gz emacs-aab5bfd074e57d06a79e39d7c7c4760e1f385a06.zip |
Bankruptcy 9
Diffstat (limited to 'lisp/reading.el')
-rw-r--r-- | lisp/reading.el | 85 |
1 files changed, 0 insertions, 85 deletions
diff --git a/lisp/reading.el b/lisp/reading.el deleted file mode 100644 index a0d22f4..0000000 --- a/lisp/reading.el +++ /dev/null | |||
@@ -1,85 +0,0 @@ | |||
1 | ;;; reading.el --- minor mode for reading -*- lexical-binding: t; -*- | ||
2 | |||
3 | ;;; Code: | ||
4 | |||
5 | (defgroup reading nil | ||
6 | "Group for Reading mode customizations." | ||
7 | :prefix "reading-" | ||
8 | :group 'convenience) | ||
9 | |||
10 | (defcustom reading-vars '((indicate-empty-lines . nil) | ||
11 | (indicate-buffer-boundaries . nil)) | ||
12 | "Alist of variables to set in function `reading-mode'. | ||
13 | The car of each cell is the variable name, and the cdr is the | ||
14 | value to set it to." | ||
15 | :type '(alist :key-type variable | ||
16 | :value-type sexp)) | ||
17 | |||
18 | (defcustom reading-modes '((display-fill-column-indicator-mode . -1) | ||
19 | (blink-cursor-mode . -1)) | ||
20 | "Alist of modes to set in function `reading-mode'. | ||
21 | The car of each cell is the function name, and the cdr is the | ||
22 | value to call it with." | ||
23 | :type '(alist :key-type function | ||
24 | :value-type sexp)) | ||
25 | |||
26 | ;;; Internal | ||
27 | |||
28 | (defvar reading--remembered-template "reading--remembered-%s-value" | ||
29 | "The template passed to `format' for remembered modes and variables.") | ||
30 | |||
31 | (defun reading--remember (things func) | ||
32 | "Apply FUNC to THINGS, remembering their previous value for later." | ||
33 | (declare (indent 1)) | ||
34 | (unless (listp things) | ||
35 | (setq things (list things))) | ||
36 | (dolist (thing things) | ||
37 | (set (make-local-variable | ||
38 | (intern (format reading--remembered-template thing))) | ||
39 | (and (boundp thing) | ||
40 | (symbol-value thing))) | ||
41 | (funcall func thing))) | ||
42 | |||
43 | (defun reading--recall (things func) | ||
44 | "Recall previously remembered THINGS by applying FUNC to them. | ||
45 | FUNC should be a function with the signature (THING REMEMBERED-SETTING)." | ||
46 | (declare (indent 1)) | ||
47 | (unless (listp things) | ||
48 | (setq things (list things))) | ||
49 | (dolist (thing things) | ||
50 | (with-demoted-errors "reading--recall: %S" | ||
51 | (let ((value (symbol-value | ||
52 | (intern | ||
53 | (format reading--remembered-template thing))))) | ||
54 | (funcall func thing value))))) | ||
55 | |||
56 | ;;; Mode | ||
57 | |||
58 | ;;;###autoload | ||
59 | (defvar reading-mode-map (make-sparse-keymap) | ||
60 | "Keymap for `reading-mode'.") | ||
61 | |||
62 | ;;;###autoload | ||
63 | (define-minor-mode reading-mode | ||
64 | "A mode for reading." | ||
65 | :lighter " Read" | ||
66 | (if reading-mode | ||
67 | ;; turn on | ||
68 | (progn | ||
69 | (reading--remember (mapcar #'car reading-vars) | ||
70 | (lambda (var) | ||
71 | (set (make-local-variable var) | ||
72 | (cdr (assoc var reading-vars))))) | ||
73 | (reading--remember (mapcar #'car reading-modes) | ||
74 | (lambda (mode) | ||
75 | (funcall mode (cdr (assoc mode reading-modes)))))) | ||
76 | ;; turn off | ||
77 | (reading--recall (mapcar #'car reading-vars) | ||
78 | (lambda (var orig-val) | ||
79 | (set (make-local-variable var) orig-val))) | ||
80 | (reading--recall (mapcar #'car reading-modes) | ||
81 | (lambda (mode orig-setting) | ||
82 | (funcall mode (if orig-setting +1 -1)))))) | ||
83 | |||
84 | (provide 'reading) | ||
85 | ;;; reading.el ends here | ||