all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Emanuel Berg <incal@dataswamp.org>
To: help-gnu-emacs@gnu.org
Subject: Re: Highlighting parentheses when matching parentheses resides outside visible window
Date: Wed, 26 Oct 2022 19:50:09 +0200	[thread overview]
Message-ID: <87k04ma2zy.fsf@dataswamp.org> (raw)
In-Reply-To: rSRb2IvJcJIZafYkNT8Q5W_TVo-qOfmU4ythbX86scfTTEl94ucla_LJmBwQl3wRLo-9CLOqWjifnjxJwJGSf8iII6WdHEFqr64S-z50DFk=@protonmail.com

Heime wrote:

> I use the arrow keys do a mouse scroll up. With mouse scroll
> up, the position of the cursor moves as the window
> gets updated.

M-i and M-k one line at a time ...

Civilized scrolling!

Get up get down get high get no no no where ...
https://www.youtube.com/watch?v=61nxcJ32mVg

;;; -*- lexical-binding: t -*-
;;
;; this file:
;;   https://dataswamp.org/~incal/emacs-init/scroll.el

(require 'cl-lib)

(setq scroll-conservatively 10000)
(setq auto-window-vscroll nil)

;; scroll the current window
(defun scroll-up-1 ()
  (interactive)
  (scroll-down 1) )
(defun scroll-down-1 ()
  (interactive)
  (scroll-up 1) )

;; automatic scrolling
(defun start-automatic-scroll-down ()
  (interactive)
  (let ((win))
    (cl-loop do
             (setq win (window-end))
             (scroll-down-1)
             (sleep-for 1) ; put speed here in seconds
             (redisplay)
             until (= win (window-end)) )))
;; (start-automatic-scroll-down)
;;                              ^ test here; abort with C-g

;; scroll up/down the other window
(defun scroll-up-other-window ()
  (interactive)
  (scroll-other-window-down 1) )
(defun scroll-down-other-window ()
  (interactive)
  (scroll-other-window 1) )

;; scroll one pane of text
(defun get-window-lines ()
  (let*((edges  (window-inside-edges))
        (top    (nth 1 edges))
        (bottom (nth 3 edges))
        (lines  (- bottom top)) )
    (if (member major-mode '(Buffer-menu-mode package-menu-mode w3m-mode))
        (1- lines)
      lines) ))

(defun scroll-up-pane ()
  (interactive)
  (scroll-down (get-window-lines) ))
(defun scroll-down-pane ()
  (interactive)
  (scroll-up (get-window-lines)) )

;; scroll horizontally
(put 'scroll-left  'disabled nil)
(put 'scroll-right 'disabled nil)
(setq hscroll-margin 1)
(setq hscroll-step   1)

(defun scroll-left-1 ()
  (interactive)
  (scroll-right 1 0) ) ; yes, "the opposite" here
(defun scroll-right-1 ()
  (interactive)
  (scroll-left 1 0) )  ; ditto

(defun set-pane-scroll-keys (map)
  "Set MAP keys for vertical scrolling in panes."
  (define-key map "I" #'scroll-up-pane)
  (define-key map "K" #'scroll-down-pane) )

(defun set-scroll-keys (map &optional horizontally)
  "Set MAP keys for scrolling, vertically and HORIZONTALLY.
Also invoke `set-pane-scroll-keys'."
  (when horizontally
    (define-key map "j"    #'scroll-left-1)
    (define-key map "l"    #'scroll-right-1) )
  (define-key map   "i"    #'scroll-up-1)
  (define-key map   "\M-i" #'scroll-up-1)
  (define-key map   "k"    #'scroll-down-1)
  (define-key map   "\M-k" #'scroll-down-1)
  (set-pane-scroll-keys map) )

(defun set-vertical-keys (map &optional button n-and-p)
  (let*((keys (if button
                  (list #'backward-button #'forward-button)
                (list #'previous-line #'forward-line) ))
        (up   (car  keys))
        (down (cadr keys)) )
    (define-key map "i" up)
    (define-key map "k" down)
    (when n-and-p
      (define-key map "p" up)
      (define-key map "n" down) )))

(provide 'scroll)

-- 
underground experts united
https://dataswamp.org/~incal




  parent reply	other threads:[~2022-10-26 17:50 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-25 11:22 Highlighting parentheses when matching parentheses resides outside visible window Heime
2022-10-25 11:40 ` Eli Zaretskii
2022-10-25 12:01   ` Heime
2022-10-25 12:44     ` Eli Zaretskii
2022-10-25 22:41   ` Heime
2022-10-26 11:09     ` Eli Zaretskii
2022-10-26 17:05       ` Heime
2022-10-26 17:37         ` Eli Zaretskii
2022-10-26 17:48           ` Heime
2022-10-26 17:58             ` Eli Zaretskii
2022-10-26 18:03               ` Heime
2022-10-26 18:23               ` Heime
2022-10-26 18:39                 ` Eli Zaretskii
2022-10-26 19:14                   ` Heime
2022-10-27  5:16                     ` Eli Zaretskii
2022-10-27  5:46                       ` Heime
2022-10-26 17:50         ` Emanuel Berg [this message]
2022-10-25 12:22 ` Jean Louis
2022-10-25 13:10 ` Stefan Monnier via Users list for the GNU Emacs text editor
2022-10-26 10:21 ` Daniel Martín

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87k04ma2zy.fsf@dataswamp.org \
    --to=incal@dataswamp.org \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.