Created
November 28, 2025 01:56
-
-
Save shayelkin/3ee068cb70c513ca4ea7c5dbab9f64a6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;; Following is inspired by MLScroll (https://github.com/jdtsmith/mlscroll), intended | |
| ;; to replace mood-line-segment-scroll in mood-line (https://git.tty.dog/hpet_dog/mood-line). | |
| (defun window-scroll-percentage () | |
| "Return current position in window, as a fraction, accounting for window height." | |
| (let* ((end (window-end)) | |
| (total (point-max))) | |
| (if (< end total) | |
| (let* ((start (window-start))) | |
| (/ (float start) (+ (- total end) start))) | |
| 1))) | |
| ;; MLScroll tries to be smart about optimizing, the above, but | |
| ;; (benchmark-run 10000 (window-scroll-percentage)) is less than 0.007 on | |
| ;; Emacs 30 and my current MacBook Air M2. | |
| (defun mood-line-segment-scroll-bar (width) | |
| "Draws a bar of total WIDTH, showing the current scroll position in the window, | |
| to be used in mood-line" | |
| (let* ((pos (round (* width (window-scroll-percentage))))) | |
| (concat | |
| (make-string pos ?▒) | |
| (make-string (- width pos ) ? )))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment