Closed Ypot closed 2 years ago
Hello @Ypot!
Wish: to read always in the lower half of the window. So my eyes always look downward, and it's more comfortable.
I am not sure I understand exactly how you imagine it. Do you mean that you have 1 window open and when you enable logos-focus-mode
it keeps the cursor in the lower part of the screen?
Wanted solution: a key combination that scrolls half window and positions the cursor in the middle of the window, like
C-l
does. Now we could use the new logos-keymap, I suppose.
Have you tried either scroll-lock-mode
or logos-scroll-lock
? If you do C-l
to centre the cursor and then enable logos-focus-mode
with scrolling locked, the focused line will stay in the centre.
I suggest you set logos-scroll-lock
to t
and then try this after activating logos-focus-mode
(assuming I understood your idea):
(defun my-logos-lower-third-scroll ()
"Keep the cursor in the lower third of the window."
(interactive)
;; You can change the `3` to whatever fraction works for you.
(let ((height (truncate (window-height) 3)))
(move-to-window-line (- height))))
Add this command to logos-focus-mode-map
.
Thanks, Prot. Effectively, I think I didn't express myself at all.
I will share a video where the cursor will show the lines I want to read, but it shouldn't be necessary to move the cursor manually to get this effect:
Evaluating a function scroll-half-window-ahead:
Maybe this, then? I bind it to the Down arrow, but you can use something different:
(defun my-logos-half-page-scroll ()
"Keep the cursor centered and scroll half window down."
(interactive)
(let ((height (truncate (window-height) 2)))
(forward-line height)
(recenter nil)))
(define-key logos-focus-mode-map (kbd "<down>") #'my-logos-half-page-scroll)
EDIT: Minor correction to code.
Hi, it doesn't work for me.
I don't know elisp, but I have studied your code (a little):
forward-line
doesn't seem to be the ideal function, because it counts lines from the "point".
Wouldn't this be better?
(scroll-up-command height)
And, I don't know why yet, but the height variable doesn't seem to work either. Sometimes it scrolls half window, other times it scrolls full window.
I think I got it (or almost):
(defun my-logos-half-page-scroll ()
"Keep the cursor centered and scroll half window down."
(interactive)
(move-to-window-line -1)
(scroll-up-command 1)
(recenter)
(next-line 1))
(define-key logos-focus-mode-map (kbd "C-v") #'my-logos-half-page-scroll)
or better this?:
(defun my-logos-half-page-scroll ()
"Keep the cursor centered and scroll half window down."
(interactive)
(move-to-window-line -1)
(forward-line 1))
(define-key logos-focus-mode-map (kbd "C-v") #'my-logos-half-page-scroll)
I can't decide which of your two suggestions is better for you. I would personally prefer the latter, as the recentring throws me off and disorients me.
Thanks for your help, I couldn't have done it by myself. I will keep this, by now:
(defun my-logos-half-page-scroll ()
"Keep the cursor centered and scroll half window down."
(interactive)
(move-to-window-line -1)
(next-line 2))
You are welcome! It looks good.
Hi Prot. Reading your last change log, makes irresistible to ask you about this.
C-l
does. Now we could use the new logos-keymap, I suppose.;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; (defun scroll-half-window-ahead () ;; ;; ;; "Scroll ahead half window" ;; ;; ;; (interactive) ;; ;; ;; (scroll-up-command (/(count-screen-lines) 2)) ;; ;; (move-to-window-line nil)) ;; ;; (global-set-key "\C-v" 'scroll-half-window-ahead) ;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Note: If you prefer to use the mail list, or other way for this kind of suggestions, let me know, I will adapt myself.