Change acdw/reading-mode to reading-mode

This commit is contained in:
Case Duckworth 2021-09-07 08:10:09 -05:00
parent 910c5df512
commit 5b7fbf4bc6
3 changed files with 67 additions and 57 deletions

32
init.el
View File

@ -26,8 +26,8 @@
(:option 0x0-default-server 'ttm))
(setup Info
(:hook variable-pitch-mode
acdw/reading-mode))
(:hook #'variable-pitch-mode
#'reading-mode))
(setup abbrev
(:option abbrev-file-name "~/Sync/abbrev.el"
@ -37,7 +37,8 @@
(setup acdw
(:also-load acdw-compat
acdw-lisp)
acdw-lisp
acdw-reading)
(acdw/require-private)
(:option user-full-name "Case Duckworth"
@ -62,10 +63,7 @@ AKA, DO NOT USE THIS FUNCTION!!!"
(car feature)
feature))
(car name))
name)))))))
(:global "C-x o" #'acdw/other-window-or-switch-buffer
"C-x O" #'acdw/other-window-or-switch-buffer-backward))
name))))))))
(setup (:straight-if affe
(and (or (executable-find "fd")
@ -610,8 +608,7 @@ AKA, DO NOT USE THIS FUNCTION!!!"
((t (:height 1.5))))
(:with-mode elfeed-show-mode
(:hook (defun elfeed-show@setup ()
(acdw/reading-mode)))
(:hook #'reading-mode)
;; see https://irreal.org/blog/?p=8885
(:bind "SPC" (defun elfeed-scroll-up-command (&optional arg)
@ -678,7 +675,7 @@ AKA, DO NOT USE THIS FUNCTION!!!"
"o" #'elpher-follow-current-link
"G" #'elpher-go-current)
(:hook #'acdw/reading-mode)
(:hook #'reading-mode)
(:autoload (elpher-bookmarks :interactive t)
(elpher-go :interactive t))
@ -726,7 +723,9 @@ AKA, DO NOT USE THIS FUNCTION!!!"
(:global "M-=" #'count-words
"C-w" #'kill-region-or-backward-word
"C-c d" #'acdw/insert-iso-date
"M-`" nil)
"M-`" nil
"C-x o" #'acdw/other-window-or-switch-buffer
"C-x O" #'acdw/other-window-or-switch-buffer-backward)
(:with-map toggle-map
(:bind "c" #'column-number-mode
@ -875,7 +874,7 @@ AKA, DO NOT USE THIS FUNCTION!!!"
(:option eww-search-prefix "https://duckduckgo.com/html?q="
url-privacy-level '(email agent cookies lastloc))
(:hook #'acdw/reading-mode))
(:hook #'reading-mode))
(setup (:straight-if exec-path-from-shell
(acdw/system :home))
@ -1174,11 +1173,12 @@ browser defined in `browse-url-secondary-browser-function'."
;; Setup for different modes.
;; There has /got/ to be an easier way here!
(let ((key ";"))
(dolist (key '(";" "o"))
(:with-mode special-mode (:bind key #'link-hint-open-link))
(:with-mode help-mode (:bind key #'link-hint-open-link))
(:with-feature helpful (:bind key #'link-hint-open-link))
(:with-mode Info-mode (:bind key #'link-hint-open-link))))
(:with-mode Info-mode (:bind key #'link-hint-open-link))
(:with-mode reading-mode (:bind key #'link-hint-open-link))))
(setup (:straight lua-mode)
(:file-match (rx ".lua" eos)))
@ -1224,7 +1224,7 @@ browser defined in `browse-url-secondary-browser-function'."
mastodon-client--token-file (acdw/dir "mastodon.plstore"))
(:hook #'hl-line-mode
#'acdw/reading-mode))
#'reading-mode))
(setup minibuffer
(:option enable-recursive-minibuffers t
@ -1862,7 +1862,7 @@ If used with a numeric prefix argument N, N backticks will be inserted."
(:option view-read-only t)
(:hook (defun acdw/read-view-mode ()
(acdw/reading-mode (if view-mode +1 -1)))))
(reading-mode (if view-mode +1 -1)))))
(setup (:straight visual-regexp)
(:global "M-%" #'vr/query-replace))

51
lisp/acdw-reading.el Normal file
View File

@ -0,0 +1,51 @@
;;; acdw-reading.el --- minor mode for reading -*- lexical-binding: t -*-
;; Copyright 2021 Case Duckworth <acdw@acdw.net>
;; 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.
;;; Code:
;;;###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 orig-indicate-empty-lines indicate-empty-lines
indicate-empty-lines nil
orig-indicate-buffer-boundaries indicate-buffer-boundaries
indicate-buffer-boundaries nil)
;; disable modes
(dolist (mode '(display-fill-column-indicator-mode))
(when (fboundp mode)
(funcall mode -1)))
;; enable modes
(dolist (mode '(olivetti-mode))
(when (fboundp mode)
(funcall mode +1))))
;; turn off
;; settings
(setq-local indicate-empty-lines orig-indicate-empty-lines
indicate-buffer-boundaries orig-indicate-buffer-boundaries)
;; enable modes
(dolist (mode '(display-fill-column-indicator-mode))
(when (fboundp mode)
(funcall mode +1)))
;; disable modes
(dolist (mode '(olivetti-mode))
(when (fboundp mode)
(funcall mode -1)))))
(provide 'acdw-reading)
;;; acdw-reading.el ends here

View File

@ -534,47 +534,6 @@ It's called 'require-private' for historical reasons."
name))
recentf-list)))
;;; Minor modes
(define-minor-mode acdw/reading-mode
"A mode for reading."
:init-value nil
:lighter " Read"
:keymap (let ((map (make-sparse-keymap)))
(when-let ((link-cmd (or (fbound-and-true-p #'ace-link)
(fbound-and-true-p #'link-hint-open-link))))
(define-key map (kbd ";") link-cmd)
(define-key map (kbd "o") link-cmd))
map)
(if acdw/reading-mode
(progn ;; turn on
;; settings
(setq-local orig-indicate-empty-lines indicate-empty-lines
indicate-empty-lines nil
orig-indicate-buffer-boundaries indicate-buffer-boundaries
indicate-buffer-boundaries nil)
;; disable modes
(dolist (mode '(display-fill-column-indicator-mode))
(when (fboundp mode)
(funcall mode -1)))
;; enable modes
(dolist (mode '(olivetti-mode))
(when (fboundp mode)
(funcall mode +1))))
;; turn off
;; settings
(setq-local indicate-empty-lines orig-indicate-empty-lines
indicate-buffer-boundaries orig-indicate-buffer-boundaries)
;; enable modes
(dolist (mode '(display-fill-column-indicator-mode))
(when (fboundp mode)
(funcall mode +1)))
;; disable modes
(dolist (mode '(olivetti-mode))
(when (fboundp mode)
(funcall mode -1)))))
;;; Sort setq...
;; https://emacs.stackexchange.com/questions/33039/