~thecashewtrader/dotfiles

66995d33d97cd7b859deb7a494ef69638c07544c — thecashewtrader 4 months ago 2dcaf23
add Bionic Reading
1 files changed, 53 insertions(+), 0 deletions(-)

M Emacs.org
M Emacs.org => Emacs.org +53 -0
@@ 198,6 198,59 @@ display correctly:

#+end_src

** Bionic Reading
#+begin_src elisp

(defvar-local bionic-overlays nil
  "The overlays for bionicification in the current buffer.")

;;;###autoload
(defun bionic-word ()
  "Bionicify the word at point"
  (interactive)
  (let* ((bounds (bounds-of-thing-at-point 'word))
         (beg (car bounds))
         (end (cdr bounds))
         (whole-len (- end beg)))
    (cond
     ((>= whole-len 2)
      (let* ((half-len (/ whole-len 2))
             (real-len (if (or (> whole-len 6) (= whole-len 3))
                           (+ half-len 1)
                         half-len))
             (ov (make-overlay beg (+ beg real-len))))
        (overlay-put ov 'face 'bold)
        (push ov bionic-overlays)))
     ((> (- end beg) 1)
      (let ((ov (make-overlay beg (+ beg 1))))
        (overlay-put ov 'face 'bold)
        (push ov bionic-overlays)))
     (t nil))))

;;;###autoload
(defun bionic-buffer ()
  "Bionicify all the visible parts of the current buffer."
  (interactive)
  (if (not (null bionic-overlays))
      (bionic-debuffer))
  (save-excursion
    (goto-char (point-min))
    (while (not (= (point) (point-max)))
      (if (looking-at "\\w")
          (bionic-word))
      (forward-to-word 1))))

;;;###autoload
(defun bionic-debuffer ()
  "Undo the bionicification."
  (interactive)
  (dolist (ov bionic-overlays)
    (delete-overlay ov)))

(provide 'bionic-reading)

#+end_src

* Completions
** Vertico
#+begin_src elisp