Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!mips!spool.mu.edu!uunet!optilink!digi!kgallagh From: kgallagh@digi.lonestar.org (Kevin Gallagher) Newsgroups: comp.emacs Subject: Re: Followup to: "Real" Vi and Edt emulation packages? Message-ID: <1991Apr28.050310.23974@digi.lonestar.org> Date: 28 Apr 91 05:03:10 GMT References: <1991Apr26.213036.10363@ttsi.lonestar.org> Organization: DSC Communications Corp, Plano, TX Lines: 65 In article <1991Apr26.213036.10363@ttsi.lonestar.org> root@ttsi.lonestar.org (System) writes: >[stuff deleted] >Someone suggested diddling with the syntax table to get the behavior I >want. I give--what would the character class assignments be to get >the behavior of vi? I think I did, but I did not mean to suggest that mucking with the syntax table would suffice. This is because of how forward-word, kill-word, etc., are defined. For example, the description of kill-word is as follows: kill-word: Kill characters forward until encountering the end of a word. With argument, do this that many times. This is pretty simplistic stuff. Here's what it does: remember the current position of point if following character is not a word character then move forward until encountering next word character move forward until encountering next non-word character kill all characters from remembered position to point You want functions which have many more conditions under which they are supposed to terminate. Which means, to get the behavior you want, you will have to write your own forward-word, kill-word, etc., so they will stop where you want them to stop. It will take some time to write each of the functions you want, but you should find none of it very difficult to do. Emacs Lisp has all the tools needed. Here's a simple example of an attempt to emulate EDT's WORD command (in the forward direction): (defun edt-one-word-forward () "Move forward to first character of next word." (interactive) (if (eobp) (progn (beep) (message "End of buffer.")) (progn (if (eolp) (forward-char)) (while (and (not (eolp)) (not (eobp)) (eq 119 (char-syntax (following-char)))) (forward-char)) (while (and (not (eolp)) (not (eobp)) (not (eq 119 (char-syntax (following-char))))) (forward-char))))) It is not a 100% EDT. For example, it does not stop on every tab character they way EDT does. But, with an appropriately set up syntax table, its close. And, with a little work, it could be made to behave exactly like EDT. If you decide to write your own "better" vi emulation, be sure to consider using the Emacs functions skip-chars-forward and skip-chars-backward. They can be very handy at times. -- ---------------------------------------------------------------------------- Kevin Gallagher kgallagh@digi.lonestar.org OR ...!uunet!digi!kgallagh DSC Communications Corporation Addr: MS 152, 1000 Coit Rd, Plano, TX 75075 ----------------------------------------------------------------------------