Article View: fj.editor.xemacs
Article #317Re: スクロールの挙動
From: IMAI Hidetoshi
Date: Wed, 06 Jun 2001 18:19
Date: Wed, 06 Jun 2001 18:19
96 lines
5519 bytes
5519 bytes
今井です
難波さん、有沢さん、小野さん ありがとうございます。
有沢さんのやり方、難波さんのやり方のどちらでも、
smooth-scroll-up/down でマークしてからリージョンを
囲えることを確認しました。
修正したファイルは以下の様なものです。
------------------------------------------------------------
(defun current-line-in-window ()
"Returns line count of current line in current window. No arg."
(save-excursion
;; goto bol not to count \n at eol of this line...
(beginning-of-line)
(count-lines (point)
(save-excursion (move-to-window-line 0)
(point)))))
(defun smooth-scroll-up (arg)
"Moves cursor down keeping cursor within 1/3 to 2/3 area of current window.
Scroll the window in need.
It's convenient to bind this command to down arrow key."
(interactive "_p")
(let* ((height (1- (window-height)))
(parity (% height 2))
(top-edge (/ (1- height) 4))
(btm-edge (+ (1+ parity) (* top-edge 3)))
(c-line (current-line-in-window))
(bob-not-shown;; var. to duck ding.
(not (pos-visible-in-window-p (point-min)))))
(if
;; Case cursor is within central area:
(or (and (> arg 0)
(<= c-line btm-edge)
(< (- btm-edge c-line) arg))
(and (< arg 0)
(>= c-line top-edge)
;;(< (- c-line top-edge) (- arg)) ;; old code for next line.
(> (- top-edge c-line) arg)
bob-not-shown))
(scroll-up arg)
;; else if cursor is in peripheral area:
;; re-calibrating cursor to central area.
(progn
(if (and (> arg 0)
(> c-line btm-edge))
(scroll-up (+ arg (- c-line btm-edge))))
(if (and (< arg 0)
(< c-line top-edge)
bob-not-shown)
(scroll-up (+ arg (- c-line top-edge))))))
(line-move arg)
(setq this-command 'next-line)))
(defun smooth-scroll-down (arg)
"Moves cursor up keeping cursor within 1/3 to 2/3 area of current window.
Scroll the window in need.
It's convenient to bind this command to up arrow key."
(interactive "_p")
(smooth-scroll-up (- arg))
(setq this-command 'previous-line))
;カーソルの移動方法を変更する
(global-set-key "\C-p" 'smooth-scroll-down)
(global-set-key [up] 'smooth-scroll-down)
(global-set-key "\C-n" 'smooth-scroll-up)
(global-set-key [down] 'smooth-scroll-up)
------------------------------------------------------------
以前にカーソルをwindowの端まで移動できるようにするには
------------------------------------------------------------
(top-edge (/ (1- height) 4))
(btm-edge (+ (1+ parity) (* top-edge 3)))
------------------------------------------------------------
を
------------------------------------------------------------
(top-edge 0)
(btm-edge (- height 2))
------------------------------------------------------------
にすれば良いと教えていただいたのですが
こちらがまだうまく行きません。
ここで、top-edgeでカーソルの上限を、btm-edgeでカーソルの下限を
きめているだけだと思うのです。
ですから、下のように書き直すことで
カーソルの上限を一番上に、カーソルの下限をしたから2行目に
変更できると思ったのですが、実際にsmooth-scroll-up/down
を実行するとすぐにカーソルが、windowの中央に飛んでしまいます。
(つまり、xemacsの C-p C-n のデフォルトの動作をしてしまう。)
一応 (top-edge 1) とすることで上に移動するときは、上から2行目
まではカーソルが移動できるようになったのですが、下に移動すると
きはどのようにしても、カーソルが中央に飛んでしまいます。
もし、カーソルが window の一番上、一番下まで移動できる方法があ
れば教えてください。お願いします。
Technical Details
Message-ID:
<xl9k82ptqrw.wl@cal.infonets.hiroshima-u.ac.jp>Path:
arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!newsfeed.mesh.ad.jp!news-sv.sinet!east-news.csi.ad.jp!hiroshima-u!not-for-mailReferences:
<xl9d78jgki9.wl@cal.infonets.hiroshima-u.ac.jp> <9fj2mh$8o1$1@sn.asahi-net.email.ne.jp> <xl94rtuomm1.wl@cal.infonets.hiroshima-u.ac.jp> <9fk0do$48j$1@sn.asahi-net.email.ne.jp> <xl9snhehw1z.wl@cal.infonets.hiroshima-u.ac.jp> <9fkvf1$fu9$1@sn.asahi-net.email.ne.jp> <xl9puchj0a5.wl@cal.infonets.hiroshima-u.ac.jp> <9fler4$sia$1@sn.asahi-net.email.ne.jp> <9flg0i$sia$2@sn.asahi-net.email.ne.jp>Show Full Headers
Complete Article Headers
X-Google-Language: Japanese,JIS X-Google-Thread: 1107f7,bc01201f0ce88c8c X-Google-Attributes: gid1107f7,public X-Google-ArrivalTime: 2001-06-06 11:20:20 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!newsfeed.mesh.ad.jp!news-sv.sinet!east-news.csi.ad.jp!hiroshima-u!not-for-mail From: IMAI Hidetoshi <hidepin@infonets.hiroshima-u.ac.jp> Newsgroups: fj.editor.xemacs Subject: Re: スクロールの挙動 Date: Thu, 07 Jun 2001 03:19:31 +0900 Organization: Hiroshima University Lines: 101 Message-ID: <xl9k82ptqrw.wl@cal.infonets.hiroshima-u.ac.jp> References: <xl9d78jgki9.wl@cal.infonets.hiroshima-u.ac.jp> <9fj2mh$8o1$1@sn.asahi-net.email.ne.jp> <xl94rtuomm1.wl@cal.infonets.hiroshima-u.ac.jp> <9fk0do$48j$1@sn.asahi-net.email.ne.jp> <xl9snhehw1z.wl@cal.infonets.hiroshima-u.ac.jp> <9fkvf1$fu9$1@sn.asahi-net.email.ne.jp> <xl9puchj0a5.wl@cal.infonets.hiroshima-u.ac.jp> <9fler4$sia$1@sn.asahi-net.email.ne.jp> <9flg0i$sia$2@sn.asahi-net.email.ne.jp> NNTP-Posting-Host: cal.infonets.hiroshima-u.ac.jp Mime-Version: 1.0 (generated by SEMI 1.13.7 - "Awazu") Content-Type: text/plain; charset=ISO-2022-JP X-Trace: news.hiroshima-u.ac.jp 991851483 16921 133.41.33.61 (6 Jun 2001 18:18:03 GMT) X-Complaints-To: news-admin@hiroshima-u.ac.jp NNTP-Posting-Date: 6 Jun 2001 18:18:03 GMT In-Reply-To: <9flg0i$sia$2@sn.asahi-net.email.ne.jp> User-Agent: Wanderlust/2.4.1 (Stand By Me) SEMI/1.13.7 (Awazu) FLIM/1.13.2 (Kasanui) MULE XEmacs/21.1 (patch 14) (Cuyahoga Valley) (i386--freebsd)