🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.help
Article #189093

Re: "Real" Vi and Edt emulation packages?

#189093
From: Kevin Gallagher
Date: Wed, 01 May 1991 18:15
102 lines
4142 bytes
Here is the latest code from our EDT emulation package that attempts
to replicate EDT's WORD command.  It consists of 5 functions.  Unless
something escaped our attention, cursor movement replicates EDT
behavior exactly, provided you make one small change to the syntax
tables: change TAB from a whitespace character to a symbol character.

Personally, when using Emacs, I think it is better to treat TAB as
whitespace, since most major modes are intelligent about their
handling of tabs and spaces.  So, I am inclining toward NOT modifying
the syntax tables in the final version of our emulation package.

I hope this helps point out what has to be done to take control of
cursor movement within Emacs.

;;;
;;; EDT WORD - Move by word in current direction.
;;;

(defun edt-one-word-forward ()
  "Move forward to first character of next word."
  (interactive)
  (if (eobp)
      (progn
	(error "End of buffer."))
      (progn
	(if (eolp)
	    (forward-char)
	(progn
	  (while (and 
		   (not (eolp))
		   (not (eobp))
		   (not (eq ?\  (char-syntax (following-char)))))
	    (forward-char))
	  (while (and 
		   (not (eolp))
		   (not (eobp))
		   (eq ?\  (char-syntax (following-char))))
	    (forward-char)))))))

(defun edt-one-word-backward ()
  "Move backward to first character of previous word."
  (interactive)
  (if (bobp)
      (progn
	(error "Beginning of buffer."))
      (progn
	(if (bolp)
	    (backward-char)
	(progn
	  (while (and 
		   (not (bolp))
		   (not (bobp))
		   (eq ?\  (char-syntax (preceding-char))))
	    (backward-char))
	  (while (and 
		   (not (bolp))
		   (not (bobp))
		   (not (eq ?\  (char-syntax (preceding-char)))))
	    (backward-char)))))))

(defun edt-word-forward (num)
  "Move forward to first character of next word.
Accepts a positive prefix argument for the number of words to move."
  (interactive "p")
  (if (> num 0)
      (while (> num 0)
	(edt-one-word-forward)
	(setq num (1- num)))
      (progn
	(error "Prefix must be positive."))))

(defun edt-word-backward (num)
  "Move backward to first character of previous word.
Accepts a positive prefix argument for the number of words to move."
  (interactive "p")
  (if (> num 0)
      (while (> num 0)
	(edt-one-word-backward)
	(setq num (1- num)))
      (progn
	(error "Prefix must be positive."))))

;;; The above four functions can stand alone as a set.  So, you should
;;; be able to load and play with them without any problems.  The
;;; following high-level function, which actually implements the EDT
;;; WORD command in our emulation package, is not independent of the
;;; other package components, so it won't run properly unless you
;;; write code to handle the variable edt-direction-string and the
;;; constant edt-forward-string.

(defun edt-word (num)
  "Move in current direction to first character of next word.
Accepts a positive prefix argument for the number of words to move."
  (interactive "p")
  (if (equal edt-direction-string edt-forward-string)
      (edt-word-forward num)
      (edt-word-backward num)))
-- 
----------------------------------------------------------------------------
Kevin Gallagher        kgallagh@digi.lonestar.org OR ...!uunet!digi!kgallagh
DSC Communications Corporation   Addr: MS 152, 1000 Coit Rd, Plano, TX 75075
----------------------------------------------------------------------------
Technical Details
Message-ID: <1991May1.181542.25539@digi.lonestar.org>
Path: arc1-ca.pugleaf.net!gmdzi!unido!math.fu-berlin.de!ira.uka.de!sol.ctr.columbia.edu!lll-winken!sun-barr!newstop!texsun!digi!kgallagh
References: <1991Apr27.170401.27827@m.cs.uiuc.edu>> <BILL.91Apr28174406@inls1.ucsd.edu> <1991Apr29.214622.11476@m.cs.uiuc.edu>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 103b8b,4aee8009378917a2
X-Google-Attributes: gid103b8b,public
X-Google-ArrivalTime: 1991-05-02 05:05:31 PST
Path: arc1-ca.pugleaf.net!gmdzi!unido!math.fu-berlin.de!ira.uka.de!sol.ctr.columbia.edu!lll-winken!sun-barr!newstop!texsun!digi!kgallagh
From: kgallagh@digi.lonestar.org (Kevin Gallagher)
Newsgroups: gnu.emacs.help
Subject: Re: "Real" Vi and Edt emulation packages?
Message-ID: <1991May1.181542.25539@digi.lonestar.org>
Date: 1 May 91 18:15:42 GMT
References: <1991Apr27.170401.27827@m.cs.uiuc.edu>> <BILL.91Apr28174406@inls1.ucsd.edu> <1991Apr29.214622.11476@m.cs.uiuc.edu>
Organization: DSC Communications Corp, Plano, TX
Lines: 102