Skip to content

Commit

Permalink
Merge pull request #289 from nanasess/fix-pixel-scroll
Browse files Browse the repository at this point in the history
Fix pixel scroll
  • Loading branch information
nanasess authored Nov 25, 2023
2 parents 74ec4b0 + dd7487f commit b1e9283
Showing 1 changed file with 33 additions and 21 deletions.
54 changes: 33 additions & 21 deletions .emacs.d/init.el
Original file line number Diff line number Diff line change
Expand Up @@ -123,31 +123,43 @@
(global-set-key (kbd "C-x <right>") 'find-file)
(global-set-key (kbd "C-x <end>") 'eval-last-sexp)

;; https://www.reddit.com/r/emacs/comments/wx7ytn/comment/ilue3ka/
;; https://www.reddit.com/r/emacs/comments/13accue/emacs_29_pixelscrollprecisionmode_seems_to_break/
(if (fboundp 'pixel-scroll-precision-mode)
(progn
(pixel-scroll-mode 1)
(pixel-scroll-precision-mode 1)
(setq pixel-scroll-precision-use-momentum t)
(setq scroll-step 1)
(setq pixel-scroll-precision-large-scroll-height 40.0)
(setq-default scroll-conservatively 10000)
(setq-default scroll-margin 5)

(setq pixel-scroll-precision-use-momentum t)
(setq pixel-scroll-precision-interpolate-mice t)
(setq pixel-scroll-precision-large-scroll-height 10.0)
(setq pixel-scroll-precision-interpolation-factor 1.0)
(setq pixel-scroll-precision-interpolate-page t)
(setq pixel-scroll-precision-interpolation-total-time 0.25)
(pixel-scroll-precision-mode t)

(defun smooth-scroll-half-page-down ()
"Smooth scroll down"
(defun +pixel-scroll-interpolate-down ()
"Interpolate a scroll downwards by one page."
(interactive)
(let ((half-height (/ (window-height) 2)))
(pixel-scroll-precision-interpolate (* 8 (- half-height)))))

(defun smooth-scroll-half-page-up ()
"Smooth scroll down"
(if pixel-scroll-precision-interpolate-page
(pixel-scroll-precision-interpolate (- (/ (window-text-height nil t) 2))
;; Don't use an
;; interpolation factor,
;; since we want exactly 1
;; page to be scrolled.
nil 1)
(cua-scroll-up)))

(defun +pixel-scroll-interpolate-up ()
"Interpolate a scroll upwards by one page."
(interactive)
(let ((half-height (/ (window-height) 2)))
(pixel-scroll-precision-interpolate (* 8 half-height))))
(if pixel-scroll-precision-interpolate-page
(pixel-scroll-precision-interpolate (/ (window-text-height nil t) 2)
nil 1)
(cua-scroll-down)))

;; scroll-up-command
(global-set-key (kbd "C-v") #'smooth-scroll-half-page-down)
(global-set-key (kbd "M-v") #'smooth-scroll-half-page-up)))
(global-set-key (kbd "C-v") '+pixel-scroll-interpolate-down)
(global-set-key (kbd "M-v") '+pixel-scroll-interpolate-up)))

(setq dired-bind-jump nil)
(setq dired-dwim-target t)
Expand Down Expand Up @@ -576,10 +588,10 @@
(defvar mkpasswd-command
"head -c 10 < /dev/random | uuencode -m - | tail -n 2 |head -n 1 | head -c10")
(autoload 'mkpasswd "mkpasswd" nil t)
(el-get-bundle emacs-id-manager
:type github
:autoloads "id-manager"
:pkgname "nanasess/emacs-id-manager")
;; (el-get-bundle emacs-id-manager
;; :type github
;; :autoloads "id-manager"
;; :pkgname "nanasess/emacs-id-manager")

(el-get-bundle nginx-mode)
(el-get-bundle po-mode)
Expand Down

0 comments on commit b1e9283

Please sign in to comment.