comparison lisp/emulation/viper-cmd.el @ 26702:8be2b52389a5

* viper-cmd.el (viper-change-state): Use viper-ESC-moves-cursor-back to decide whether to move the cursor back.
author Michael Kifer <kifer@cs.stonybrook.edu>
date Sat, 04 Dec 1999 06:19:05 +0000
parents 76b6a75471e1
children 2ddbff6366e9
comparison
equal deleted inserted replaced
26701:cb2f5d1a71e4 26702:8be2b52389a5
221 (or (memq this-command '(self-insert-command)) 221 (or (memq this-command '(self-insert-command))
222 (memq (viper-event-key last-command-event) 222 (memq (viper-event-key last-command-event)
223 '(up down left right (meta f) (meta b) 223 '(up down left right (meta f) (meta b)
224 (control n) (control p) (control f) (control b))) 224 (control n) (control p) (control f) (control b)))
225 (viper-restore-cursor-color 'after-replace-mode))) 225 (viper-restore-cursor-color 'after-replace-mode)))
226
227
228 ;; Make sure we don't delete more than needed.
229 ;; This is executed at viper-last-posn-in-replace-region
230 (defsubst viper-trim-replace-chars-to-delete-if-necessary ()
231 (setq viper-replace-chars-to-delete
232 (max 0
233 (min viper-replace-chars-to-delete
234 ;; Don't delete more than to the end of repl overlay
235 (viper-chars-in-region
236 (viper-replace-end) viper-last-posn-in-replace-region)
237 ;; point is viper-last-posn-in-replace-region now
238 ;; So, this limits deletion to the end of line
239 (viper-chars-in-region (point) (viper-line-pos 'end))
240 ))))
241
226 242
227 (defun viper-replace-state-post-command-sentinel () 243 (defun viper-replace-state-post-command-sentinel ()
228 ;; Restoring cursor color is needed despite 244 ;; Restoring cursor color is needed despite
229 ;; viper-replace-state-pre-command-sentinel: When one jumps to another buffer 245 ;; viper-replace-state-pre-command-sentinel: When one jumps to another buffer
230 ;; in another frame, the pre-command hook won't change cursor color to 246 ;; in another frame, the pre-command hook won't change cursor color to
314 330
315 (if (> (length viper-last-insertion) 0) 331 (if (> (length viper-last-insertion) 0)
316 (viper-push-onto-ring viper-last-insertion 332 (viper-push-onto-ring viper-last-insertion
317 'viper-insertion-ring)) 333 'viper-insertion-ring))
318 334
319 (if viper-ex-style-editing 335 (if viper-ESC-moves-cursor-back
320 (or (bolp) (backward-char 1)))) 336 (or (bolp) (backward-char 1))))
321 )) 337 ))
322 338
323 ;; insert or replace 339 ;; insert or replace
324 ((memq new-state '(insert-state replace-state)) 340 ((memq new-state '(insert-state replace-state))
2232 (or (marker-position viper-last-posn-in-replace-region) 2248 (or (marker-position viper-last-posn-in-replace-region)
2233 (viper-replace-start)) 2249 (viper-replace-start))
2234 )) 2250 ))
2235 2251
2236 ))) 2252 )))
2237
2238 ;; Make sure we don't delete more than needed.
2239 ;; This is executed at viper-last-posn-in-replace-region
2240 (defsubst viper-trim-replace-chars-to-delete-if-necessary ()
2241 (setq viper-replace-chars-to-delete
2242 (max 0
2243 (min viper-replace-chars-to-delete
2244 ;; Don't delete more than to the end of repl overlay
2245 (viper-chars-in-region
2246 (viper-replace-end) viper-last-posn-in-replace-region)
2247 ;; point is viper-last-posn-in-replace-region now
2248 ;; So, this limits deletion to the end of line
2249 (viper-chars-in-region (point) (viper-line-pos 'end))
2250 ))))
2251 2253
2252 2254
2253 ;; Delete stuff between viper-last-posn-in-replace-region and the end of 2255 ;; Delete stuff between viper-last-posn-in-replace-region and the end of
2254 ;; viper-replace-overlay-marker, if viper-last-posn-in-replace-region is within 2256 ;; viper-replace-overlay-marker, if viper-last-posn-in-replace-region is within
2255 ;; the overlay and current point is before the end of the overlay. 2257 ;; the overlay and current point is before the end of the overlay.