comparison lisp/viper/viper.el @ 100:4be1180a9e89 r20-1b2

Import from CVS: tag r20-1b2
author cvs
date Mon, 13 Aug 2007 09:15:11 +0200
parents 6a378aca36af
children cf808b4c4290
comparison
equal deleted inserted replaced
99:2d83cbd90d8d 100:4be1180a9e89
6 ;; Keywords: emulations 6 ;; Keywords: emulations
7 ;; Author: Michael Kifer <kifer@cs.sunysb.edu> 7 ;; Author: Michael Kifer <kifer@cs.sunysb.edu>
8 8
9 ;; Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc. 9 ;; Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
10 10
11 (defconst viper-version "2.92 of January 10, 1997" 11 (defconst viper-version "2.93 of February 13, 1997"
12 "The current version of Viper") 12 "The current version of Viper")
13 13
14 ;; This file is part of GNU Emacs. 14 ;; This file is part of GNU Emacs.
15 15
16 ;; GNU Emacs is free software; you can redistribute it and/or modify 16 ;; GNU Emacs is free software; you can redistribute it and/or modify
1306 ;; Invoked by EVENT. COM is the command part obtained so far. 1306 ;; Invoked by EVENT. COM is the command part obtained so far.
1307 (defun vip-prefix-arg-value (event com) 1307 (defun vip-prefix-arg-value (event com)
1308 (let (value func) 1308 (let (value func)
1309 ;; read while number 1309 ;; read while number
1310 (while (and (vip-characterp event) (>= event ?0) (<= event ?9)) 1310 (while (and (vip-characterp event) (>= event ?0) (<= event ?9))
1311 (setq value (+ (* (if (vip-characterp value) value 0) 10) (- event ?0))) 1311 (setq value (+ (* (if (integerp value) value 0) 10) (- event ?0)))
1312 (setq event (vip-read-event-convert-to-char))) 1312 (setq event (vip-read-event-convert-to-char)))
1313 1313
1314 (setq prefix-arg value) 1314 (setq prefix-arg value)
1315 (if com (setq prefix-arg (cons prefix-arg com))) 1315 (if com (setq prefix-arg (cons prefix-arg com)))
1316 (while (eq event ?U) 1316 (while (eq event ?U)
1329 ;; last. If com is not nil, the vip-digit-argument command was called 1329 ;; last. If com is not nil, the vip-digit-argument command was called
1330 ;; from within vip-prefix-arg command, such as `d', `w', etc., i.e., 1330 ;; from within vip-prefix-arg command, such as `d', `w', etc., i.e.,
1331 ;; the user typed, say, d2. In this case, `com' would be `d', `w', 1331 ;; the user typed, say, d2. In this case, `com' would be `d', `w',
1332 ;; etc. 1332 ;; etc.
1333 ;; If vip-digit-argument was invoked by vip-escape-to-vi (which is 1333 ;; If vip-digit-argument was invoked by vip-escape-to-vi (which is
1334 ;; indicated by the fact that the current state is not vi-state, 1334 ;; indicated by the fact that the current state is not vi-state),
1335 ;; then `event' represents the vi command to be executed (e.g., `d', 1335 ;; then `event' represents the vi command to be executed (e.g., `d',
1336 ;; `w', etc). Again, last-command-char must make emacs believe that 1336 ;; `w', etc). Again, last-command-char must make emacs believe that
1337 ;; this is the command we typed. 1337 ;; this is the command we typed.
1338 (setq last-command-char (or com event)) 1338 (setq last-command-char (or com event))
1339 (setq func (vip-exec-form-in-vi 1339 (setq func (vip-exec-form-in-vi
1391 (progn 1391 (progn
1392 (setq cmd-info (cons value com)) 1392 (setq cmd-info (cons value com))
1393 (while (= char ?U) 1393 (while (= char ?U)
1394 (vip-describe-arg cmd-info) 1394 (vip-describe-arg cmd-info)
1395 (setq char (read-char))) 1395 (setq char (read-char)))
1396 ;; `char' is a movement command or a digit arg command---so we execute 1396 ;; `char' is a movement cmd, a digit arg cmd, or a register cmd---so we
1397 ;; it at the very end 1397 ;; execute it at the very end
1398 (or (vip-movement-command-p char) 1398 (or (vip-movement-command-p char)
1399 (vip-digit-command-p char) 1399 (vip-digit-command-p char)
1400 (vip-regsuffix-command-p char)
1400 (error "")) 1401 (error ""))
1401 (setq mv-or-digit-cmd 1402 (setq mv-or-digit-cmd
1402 (vip-exec-form-in-vi 1403 (vip-exec-form-in-vi
1403 (` (key-binding (char-to-string (, char))))))) 1404 (` (key-binding (char-to-string (, char)))))))
1404 1405
3891 "Run `vip-minibuffer-exit-hook' just before exiting the minibuffer." 3892 "Run `vip-minibuffer-exit-hook' just before exiting the minibuffer."
3892 (run-hooks 'vip-minibuffer-exit-hook)) 3893 (run-hooks 'vip-minibuffer-exit-hook))
3893 3894
3894 (defadvice find-file (before vip-add-suffix-advice activate) 3895 (defadvice find-file (before vip-add-suffix-advice activate)
3895 "Use `read-file-name' for reading arguments." 3896 "Use `read-file-name' for reading arguments."
3896 (interactive (list (read-file-name "Find file: " 3897 (interactive (cons (read-file-name "Find file: " nil default-directory)
3897 nil default-directory)))) 3898 ;; if Mule and prefix argument, ask for coding system
3899 (if (or (boundp 'MULE) ; mule integrated Emacs 19
3900 (featurep 'mule)) ; mule integrated XEmacs 20
3901 (list
3902 (and current-prefix-arg
3903 (read-coding-system "Coding-system: "))))
3904 )))
3898 3905
3899 (defadvice find-file-other-window (before vip-add-suffix-advice activate) 3906 (defadvice find-file-other-window (before vip-add-suffix-advice activate)
3900 "Use `read-file-name' for reading arguments." 3907 "Use `read-file-name' for reading arguments."
3901 (interactive (list (read-file-name "Find file in other window: " 3908 (interactive (cons (read-file-name "Find file in other window: "
3902 nil default-directory)))) 3909 nil default-directory)
3910 ;; if Mule and prefix argument, ask for coding system
3911 (if (or (boundp 'MULE) ; mule integrated Emacs 19
3912 (featurep 'mule)) ; mule integrated XEmacs 20
3913 (list
3914 (and current-prefix-arg
3915 (read-coding-system "Coding-system: "))))
3916 )))
3903 3917
3904 (defadvice find-file-other-frame (before vip-add-suffix-advice activate) 3918 (defadvice find-file-other-frame (before vip-add-suffix-advice activate)
3905 "Use `read-file-name' for reading arguments." 3919 "Use `read-file-name' for reading arguments."
3906 (interactive (list (read-file-name "Find file in other frame: " 3920 (interactive (cons (read-file-name "Find file in other frame: "
3907 nil default-directory)))) 3921 nil default-directory)
3922 ;; if Mule and prefix argument, ask for coding system
3923 (if (or (boundp 'MULE) ; mule integrated Emacs 19
3924 (featurep 'mule)) ; mule integrated XEmacs 20
3925 (list
3926 (and current-prefix-arg
3927 (read-coding-system "Coding-system: "))))
3928 )))
3908 3929
3909 (defadvice read-file-name (around vip-suffix-advice activate) 3930 (defadvice read-file-name (around vip-suffix-advice activate)
3910 "Tell `exit-minibuffer' to run `vip-file-add-suffix' as a hook." 3931 "Tell `exit-minibuffer' to run `vip-file-add-suffix' as a hook."
3911 (let ((vip-minibuffer-exit-hook 'vip-file-add-suffix)) 3932 (let ((vip-minibuffer-exit-hook 'vip-file-add-suffix))
3912 ad-do-it)) 3933 ad-do-it))
4994 (defvar makefile-mode-hook) 5015 (defvar makefile-mode-hook)
4995 (add-hook 'makefile-mode-hook 'viper-mode) 5016 (add-hook 'makefile-mode-hook 'viper-mode)
4996 5017
4997 (defvar help-mode-hook) 5018 (defvar help-mode-hook)
4998 (add-hook 'help-mode-hook 'viper-mode) 5019 (add-hook 'help-mode-hook 'viper-mode)
5020 (vip-modify-major-mode 'help-mode 'vi-state vip-help-modifier-map)
4999 5021
5000 (defvar awk-mode-hook) 5022 (defvar awk-mode-hook)
5001 (add-hook 'awk-mode-hook 'viper-mode) 5023 (add-hook 'awk-mode-hook 'viper-mode)
5002 5024
5003 (defvar html-mode-hook) 5025 (defvar html-mode-hook)