[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Need help on writing an Emacs extension to help reading text content wit
Need help on writing an Emacs extension to help reading text content with timer
Wed, 29 Jan 2020 23:19:41 +0800
mu4e 1.3.2; emacs 27.0.50
When I read a long paragraph, move around text, leave for a while, then get back
to read it will lost the position. So I want to combine package =Spritz (speed
read)= and =beacon=. Make the cursor move animation like =beacon=, and switch
into read-only state, and move around the cursor. Or use =overlay= for simplity.
Make the cursor big and obvious like =beacon=. The inner core logic is like
After reading spray.el source code, I use following code loginc:
- ~(run-with-timer 0 (/ 60.0 spray-wpm) 'spray--update)~
- ~make-overlay~ + ~overlay-put~
And here is my source code:
(defcustom amread-wps 2
"Read words per second."
(defvar amread--running nil)
(defvar amread--overlay nil)
(defun amread--update ()
"Moving amread cursor forward."
(let* ((begin (point))
(length (+ (skip-chars-forward "^\s\t\n—") (skip-chars-forward "—")))
;; create the overlay if does not exist
(setq amread--overlay (make-overlay begin end)))
;; move forward overlay
;; (delete-overlay amread--overlay)
(move-overlay amread--overlay begin end))
'face '((foreground-color . "white")
(background-color . "dark green")))
(defun amread-start ()
"Start / resume amread."
(run-with-timer 0 (/ 1.0 amread-wps) #'amread--update)))
(defun amread-stop ()
(setq amread--running nil)
(let ((map (make-sparse-keymap)))
(define-key map (kbd "q") 'amread-stop)
(define-key map [remap keyaobrd-quit] 'amread-stop)
"Keymap for amread-mode buffers.")
"I'm reading qmode."
But the problem is that I can't stop this timer with defined keybinding =[q]=
with minor mode toggle command =amread-mode=.
I don't know where is the problem. can someone help me to review my code?
BTW, if someone can have better solution to integrate =beacon.el= package, it
might be an alternative solution, will looks better with animation. Even though
using property on words is simple and clean.
[ stardiviner ]
I try to make every word tell the meaning what I want to express.
IRC(freenode): stardiviner, Matrix: stardiviner
- Need help on writing an Emacs extension to help reading text content with timer,