help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Highlighting parentheses when matching parentheses resides outside v


From: Emanuel Berg
Subject: Re: Highlighting parentheses when matching parentheses resides outside visible window
Date: Wed, 26 Oct 2022 19:50:09 +0200
User-agent: Gnus/5.13 (Gnus v5.13)

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]