Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: edb38eb767
Fetching contributors…

Cannot retrieve contributors at this time

48 lines (40 sloc) 1.574 kB
;;一行ずつスクロール
(defun sane-next-line (arg)
"Goto next line by ARG steps with scrolling sanely if needed."
(interactive "p")
;;(let ((newpt (save-excursion (line-move arg) (point))))
(let ((newpt (save-excursion (next-line arg) (point))))
(while (null (pos-visible-in-window-p newpt))
(if (< arg 0) (scroll-down 1) (scroll-up 1)))
(goto-char newpt)
(setq this-command 'next-line)
()))
(defun sane-forward-line (arg)
"Goto next line by ARG steps with scrolling sanely if needed."
(interactive "p")
;;(let ((newpt (save-excursion (line-move arg) (point))))
(let ((newpt (save-excursion (forward-line arg) (point))))
(while (null (pos-visible-in-window-p newpt))
(if (< arg 0) (scroll-down 1) (scroll-up 1)))
(goto-char newpt)
(setq this-command 'next-line)
()))
(defun sane-previous-line (arg)
"Goto previous line by ARG steps with scrolling back sanely if needed."
(interactive "p")
(sane-next-line (- arg))
(setq this-command 'previous-line)
())
(defun sane-newline (arg)
"Put newline\(s\) by ARG with scrolling sanely if needed."
(interactive "p")
(let ((newpt (save-excursion (newline arg) (indent-according-to-mode) (point))))
(while (null (pos-visible-in-window-p newpt)) (scroll-up 1))
(goto-char newpt)
(setq this-command 'newline)
()))
(global-set-key [up] 'sane-previous-line)
(global-set-key [down] 'sane-next-line)
(global-set-key "\C-m" 'sane-newline)
(define-key global-map "\C-n" 'sane-next-line)
(define-key global-map "\C-p" 'sane-previous-line)
Jump to Line
Something went wrong with that request. Please try again.