[comp.emacs] vip-mode under GNU Emacs 18.41 and 18.44

a88245@tansei.UUCP (06/12/87)

The vi emulating package vip.el under GNU Emacs 18.41 and 18.44 contains
a rather seriou bug.  Namely the keys "f", "t", "F", "T" do not work as
expected in vi mode.  This bug can be fixed by changing the definition of
vi-find-char as follows:

(defun vi-find-char (arg char forward offset)
  "(ARG CHAR FORWARD OFFSET)  Find ARG's occurence of CHAR on the
current line.  If FORWARD then search is forward, otherwise backward.
OFFSET is used to adjust point after search."
  (let ((arg (if forward arg (- arg))) point)
    (save-excursion
      (save-restriction
	(if (> arg 0)
	    (narrow-to-region
	     ;; forward search begins here
	     (if (eolp) (error "") (point))
	     ;; forward search ends here
	     (progn (next-line 1) (beginning-of-line) (point)))
	  (narrow-to-region
	   ;; backward search begins from here
	   (if (bolp) (error "") (point))
	   ;; backward search ends here
	   (progn (beginning-of-line) (point))))
	;; if arg > 0, point is forwarded before search.
	(if (> arg 0) (goto-char (1+ (point-min)))
	  (goto-char (point-max)))
 	(let ((case-fold-search nil))
 	  (if (> arg 0)
 	      (search-forward (char-to-string char) nil 0 arg)
 	    (search-backward (char-to-string char) nil 0 (- arg))))
 	(setq point (point))
	(if (or (and (> arg 0) (= point (point-max)))
		(and (< arg 0) (= point (point-min))))
	    (error ""))))
    (goto-char (+ point (if (> arg 0) (if offset -2 -1) (if offset 1 0))))))

You can either modify the file vip.el or you can insert the above function
definition in your .vip file.  The above bug has been introduced because I
developed the vi package under GNU Emacs 17.64, and I used a function which
is now obsolete.

I am told that this bug is fixed in GNU Emacs 18.45.

I thank John Rigby at Utah for reporting the bug.

** masahiko **