🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: fj.editor.mule
Article #506

Re: 物理行単位でのカーソル移動について

#506
From: Inaba Hiroto
Date: Sat, 29 May 1999 00:00
241 lines
8522 bytes
This is a multi-part message in MIME format.
--------------1701AF4A89A4355EDA5272E1
Content-Type: text/plain; charset=iso-2022-jp
Content-Transfer-Encoding: 7bit

$B0pMU$G$9!#(B

Inaba Hiroto wrote:

> IIJIMA 'Delmonta' Hiromitsu wrote:

> >         Emacs(Mule) $B>e$G!"%+!<%=%k$rJ*M}9T!J2hLL>e$N(B 1 $B9T!KC10L$G(B
> >         $B0\F0$9$k%^%/%m$K!"$$$$$b$N$O$J$$$G$7$g$&$+!#(B
> 
> window-lines.el$B$H$$$&$b$N$,$"$j$^$9(I!(B $B<+J,$,(Bsave$B$7$?$b$N$O(B
> 
> ;; basic cursor moving commands based on window lines
> ;; Copyright (C) 1990 enami tsugutomo (enami@ptgd.sony.co.jp)
>         $B!'(B
> ;; $Id: window-lines.el,v 1.15 90/04/26 19:54:59 enami Rel $

$B$3$l$K$D$$$F!"8+$D$1$i$l$J$$$H$N%a!<%k$r$"$kJ}$+$i$$$?$@$-$^$7$?!#(B

$BB>$K$b6=L#$r;}$?$l$?J}$b$$$k$+$b$7$l$^$;$s$7!"(BGPL$B$K$h$j:FG[I[2DG=!"(B
$B$+$DC;$$$b$N$G$9$N$G!"$3$N5-;v$K$D$1$FAw$j$^$9(I!(B

# $B:#$J$i(Bminor mode$B$H$7$F<BAu$9$Y$-$J$s$G$7$g$&$M!#C/$+$K(BVersion Up$B$7$F(B
# $BD:$1$l$P$H$N4|BT$b9~$a$F$$$^$9(I!(B
--
			$B0pMU(B $B9@?M(B  <inaba@st.rim.or.jp>
--------------1701AF4A89A4355EDA5272E1
Content-Type: text/plain; charset=iso-2022-jp; name="window-lines.el"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline; filename="window-lines.el"

;; basic cursor moving commands based on window lines
;; Copyright (C) 1990 enami tsugutomo (enami@ptgd.sony.co.jp)

;; This file is not a part of GNU Emacs.

;; This file is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY.  No author or distributor
;; accepts responsibility to anyone for the consequences of using it
;; or for whether it serves any particular purpose or works at all,
;; unless he says so in writing.  Refer to the GNU Emacs General Public
;; License for full details.

;; Everyone is granted permission to copy, modify and redistribute
;; This file, but only under the conditions described in the
;; GNU Emacs General Public License.   A copy of this license is
;; supposed to have been given to you along with GNU Emacs so you
;; can know your rights and responsibilities.  It should be in a
;; file named COPYING.  Among other things, the copyright notice
;; and this notice must be preserved on all copies.

;;
;; $Id: window-lines.el,v 1.15 90/04/26 19:54:59 enami Rel $
;;

(defvar cursor-move-window-line nil "*T if cursor move on window lines.")=


(defun window-line-move (arg)
  (if (not (memq last-command
		 ;; Do you think also need next-line and previous-line ? =

		 '(window-next-line window-previous-line) ))
      ;; update temporary-goal-column
      (setq temporary-goal-column
	    (if (and track-eol (eolp))
		9999
	      (current-window-column) )))
  ;; move vertically
  (forward-window-line arg)
  ;; adjust column
  (move-to-window-column (or goal-column temporary-goal-column))
  nil)

=0C
;;;
;;; basic functions
;;;
(defun beginning-of-window-line ()
  "Goto beginning of current window line."
  (vertical-motion 0))

(defun end-of-window-line ()
  "Goto beginning of current window line."
  (if (eobp)
      nil				; already on eol.
    (vertical-motion 1)
    ;; never back if last line ends without LFD.
    (if (or (not (eobp))
	    (=3D (current-column) 0))	; If !0, it means was on last line
					; and reach to end of buffer
					; Attention that not on the eob
					; at first.
	(forward-char -1) )))

(defun current-window-column ()
  "Return the horisontal position of point on window."
  (let* ((ccol (current-column))
	 ;; left column
	 (lcol (save-excursion
		 ;; moves left edge of current line
		 (beginning-of-window-line)
		 (current-column) )))
    ;; if selective-display some times become negative, incorrect value
    ;; is returne but no way to get correct value, I think ... :-<
    (- ccol lcol) ))

(defun move-to-window-column (col)
  "Move point to column COLUMN in the current window line."
  (let* ((beg (progn
		(beginning-of-window-line)
		(current-column)))
	 (lim (save-excursion
		(end-of-window-line)
		(current-window-column) )))
    (and (< col 0) (setq col 0))
    (and (< lim col)
	 (< 0 lim)			; for selective display. DOUBTFUL.
	 (setq col lim))
    (move-to-column (+ beg col)) ))

(defun forward-window-line (args)
  "Move ARGS line on window with preserving current window column."
  (if (/=3D args 0)
      (let* ((cwcol (current-window-column)))
	(vertical-motion args)
	(move-to-window-column cwcol) )))

=0C
;;;
;;; editing commands
;;;
(defun window-next-line (arg)
  "Move ARGs line down.  Almost same as next-line but move on window line=
=2E"
  (interactive "p")
  (if (and cursor-move-window-line (not truncate-lines))
      (if (/=3D arg 1)
	  (window-line-move arg)
	;; arg is 1. special case.
	(let* ((point (point)))
	  (window-line-move 1)
	  ;; (window-line-move 1) doesn't move if on the last line.
	  (if (/=3D point (point))
	      nil
	    ;; on the last line
	    (end-of-window-line)
	    (insert ?\n) )))
    (setq this-command 'next-line)	;for line-move
    (next-line arg) ))
	   =

(defun window-previous-line (arg)
  "Move ARGs line up.  Almost same as previous-line but move on window li=
ne."
  (interactive "p")
  (if (and cursor-move-window-line (not truncate-lines))
      (window-line-move (- arg))
    (setq this-command 'previous-line)	;for line-move
    (previous-line arg) ))

(defun window-beginning-or-end-of-line (new org arg)
  (if (not cursor-move-window-line)
      (funcall org arg)
    ;; first move (1- arg) line forward
    (forward-window-line (1- arg))
    (funcall new)))

(defun window-beginning-of-line (arg)
  "Move to beginning of line.  See also the documentation of
beginning-of-line."
  (interactive "p")
  (window-beginning-or-end-of-line
   'beginning-of-window-line 'beginning-of-line arg))

(defun window-end-of-line (arg)
  "Move to end of line.  See also the documentation of end-of-line."
  (interactive "p")
  (window-beginning-or-end-of-line
   'end-of-window-line 'end-of-line arg))
=0C
;;
;; minor mode definitions
;;
(or (assq 'cursor-move-window-line minor-mode-alist)
    (setq minor-mode-alist
	  (cons '(cursor-move-window-line " WLine")
		minor-mode-alist) ))

(defvar window-line-mode-hook
  (list (function
	 (lambda ()
	   (and cursor-move-window-line
		(mapcar
		 (function (lambda (pair) =

			     (apply (function substitute-all-key-definition)
				    pair) ))
		 '((next-line  window-next-line)
		   (previous-line window-previous-line)
		   (beginning-of-line window-beginning-of-line)
		   (end-of-line window-end-of-line)) )))))
  "List of hook variable which value is called as no arg function
when window-line-mode is executed.")

(defun substitute-all-key-definition (olddef newdef)
  "Replace OLDDEF with NEWDEF by defining local key map."
  (let* (map key (keys (where-is-internal olddef (current-local-map))))
    (while keys
      (setq key (car keys)
	    keys (cdr keys))
      (local-set-key key newdef) )))

(defun window-line-mode (&optional arg)
  "Toggle window line mode. With positive ARGument, turn on, else off.
At the end, window-line-mode-hook is called.  See run-hooks for hook vari=
able."
  (interactive "P")
  (make-local-variable 'cursor-move-window-line)
  (setq cursor-move-window-line
	(if (null arg)
	    (not cursor-move-window-line)
	  (< 0 (prefix-numeric-value arg)) ))
  (set-buffer-modified-p (buffer-modified-p)) ; update mode-line
  (run-hooks 'window-line-mode-hook) )

=0C
(mapcar (function
      (lambda (args)
	(global-set-key (car args) (cdr args))))
     '(("\C-a" . window-beginning-of-line)
       ("\C-e" . window-end-of-line)
       ("\C-n" . window-next-line)
       ("\C-p" . window-previous-line)
       ))

--------------1701AF4A89A4355EDA5272E1--
Technical Details
Message-ID: <374EBE76.DF4BE88@st.rim.or.jp>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <37495C02.DAD1FBA9@komaba.ecc.u-tokyo.ac.jp> <3749751C.AA83D771@st.rim.or.jp>

Show Full Headers
Complete Article Headers
X-Google-Language: Japanese,JIS
X-Google-Thread: 10eba4,b6f49b20dffed084
X-Google-Attributes: gid10eba4,public
From: Inaba Hiroto <inaba@st.rim.or.jp>
Subject: Re: 物理行単位でのカーソル移動について
Date: 1999/05/29
Message-ID: <374EBE76.DF4BE88@st.rim.or.jp>
X-Deja-AN: 483157266
References: <37495C02.DAD1FBA9@komaba.ecc.u-tokyo.ac.jp> <3749751C.AA83D771@st.rim.or.jp>
Content-Type: multipart/mixed; boundary="------------1701AF4A89A4355EDA5272E1"
Organization: RIMNET
Mime-Version: 1.0
Newsgroups: fj.editor.mule