Mercurial > emacs
comparison lisp/emulation/viper-cmd.el @ 73486:db25befb2938
2006-10-23 Michael Kifer <kifer@cs.stonybrook.edu>
* viper-cmd.el (viper-prefix-arg-com): define gg as G0
* viper-ex.el (ex-read): quote file argument.
* ediff-diff.el (ediff-same-file-contents): expand file names.
* ediff-mult.el (ediff-append-custom-diff): quote shell file arguments.
author | Michael Kifer <kifer@cs.stonybrook.edu> |
---|---|
date | Mon, 23 Oct 2006 19:20:15 +0000 |
parents | 54ea774c3eed |
children | 2e5f946f7726 7eeafaaa9eab |
comparison
equal
deleted
inserted
replaced
73485:1b4c217a4d9d | 73486:db25befb2938 |
---|---|
404 (viper-normalize-minor-mode-map-alist) | 404 (viper-normalize-minor-mode-map-alist) |
405 (viper-adjust-keys-for new-state) | 405 (viper-adjust-keys-for new-state) |
406 (viper-set-mode-vars-for new-state) | 406 (viper-set-mode-vars-for new-state) |
407 (viper-refresh-mode-line) | 407 (viper-refresh-mode-line) |
408 ) | 408 ) |
409 | |
410 | 409 |
411 | 410 |
412 (defun viper-adjust-keys-for (state) | 411 (defun viper-adjust-keys-for (state) |
413 "Make necessary adjustments to keymaps before entering STATE." | 412 "Make necessary adjustments to keymaps before entering STATE." |
414 (cond ((memq state '(insert-state replace-state)) | 413 (cond ((memq state '(insert-state replace-state)) |
1261 (setq char (read-char)))) | 1260 (setq char (read-char)))) |
1262 (t | 1261 (t |
1263 (setq com char) | 1262 (setq com char) |
1264 (setq char (read-char)))))) | 1263 (setq char (read-char)))))) |
1265 | 1264 |
1266 (if (atom com) | 1265 (if (atom com) |
1267 ;; `com' is a single char, so we construct the command argument | 1266 ;; `com' is a single char, so we construct the command argument |
1268 ;; and if `char' is `?', we describe the arg; otherwise | 1267 ;; and if `char' is `?', we describe the arg; otherwise |
1269 ;; we prepare the command that will be executed at the end. | 1268 ;; we prepare the command that will be executed at the end. |
1270 (progn | 1269 (progn |
1271 (setq cmd-info (cons value com)) | 1270 (setq cmd-info (cons value com)) |
1272 (while (viper= char ?U) | 1271 (while (viper= char ?U) |
1273 (viper-describe-arg cmd-info) | 1272 (viper-describe-arg cmd-info) |
1274 (setq char (read-char))) | 1273 (setq char (read-char))) |
1275 ;; `char' is a movement cmd, a digit arg cmd, or a register cmd---so we | 1274 ;; `char' is a movement cmd, a digit arg cmd, or a register cmd---so |
1276 ;; execute it at the very end | 1275 ;; we execute it at the very end |
1277 (or (viper-movement-command-p char) | 1276 (or (viper-movement-command-p char) |
1278 (viper-digit-command-p char) | 1277 (viper-digit-command-p char) |
1279 (viper-regsuffix-command-p char) | 1278 (viper-regsuffix-command-p char) |
1280 (viper= char ?!) ; bang command | 1279 (viper= char ?!) ; bang command |
1281 (error "")) | 1280 (viper= char ?g) ; the gg command (like G0) |
1282 (setq cmd-to-exec-at-end | 1281 (error "")) |
1283 (viper-exec-form-in-vi | 1282 (setq cmd-to-exec-at-end |
1284 `(key-binding (char-to-string ,char))))) | 1283 (viper-exec-form-in-vi |
1285 | 1284 `(key-binding (char-to-string ,char))))) |
1286 ;; as com is non-nil, this means that we have a command to execute | 1285 |
1287 (if (viper-memq-char (car com) '(?r ?R)) | 1286 ;; as com is non-nil, this means that we have a command to execute |
1288 ;; execute apropriate region command. | 1287 (if (viper-memq-char (car com) '(?r ?R)) |
1289 (let ((char (car com)) (com (cdr com))) | 1288 ;; execute apropriate region command. |
1290 (setq prefix-arg (cons value com)) | 1289 (let ((char (car com)) (com (cdr com))) |
1291 (if (viper= char ?r) | 1290 (setq prefix-arg (cons value com)) |
1292 (viper-region prefix-arg) | 1291 (if (viper= char ?r) |
1293 (viper-Region prefix-arg)) | 1292 (viper-region prefix-arg) |
1294 ;; reset prefix-arg | 1293 (viper-Region prefix-arg)) |
1295 (setq prefix-arg nil)) | 1294 ;; reset prefix-arg |
1296 ;; otherwise, reset prefix arg and call appropriate command | 1295 (setq prefix-arg nil)) |
1297 (setq value (if (null value) 1 value)) | 1296 ;; otherwise, reset prefix arg and call appropriate command |
1298 (setq prefix-arg nil) | 1297 (setq value (if (null value) 1 value)) |
1299 (cond | 1298 (setq prefix-arg nil) |
1300 ;; If we change ?C to ?c here, then cc will enter replacement mode | 1299 (cond |
1301 ;; rather than deleting lines. However, it will affect 1 less line than | 1300 ;; If we change ?C to ?c here, then cc will enter replacement mode |
1302 ;; normal. We decided to not use replacement mode here and follow Vi, | 1301 ;; rather than deleting lines. However, it will affect 1 less line |
1303 ;; since replacement mode on n full lines can be achieved with nC. | 1302 ;; than normal. We decided to not use replacement mode here and |
1304 ((equal com '(?c . ?c)) (viper-line (cons value ?C))) | 1303 ;; follow Vi, since replacement mode on n full lines can be achieved |
1305 ((equal com '(?d . ?d)) (viper-line (cons value ?D))) | 1304 ;; with nC. |
1306 ((equal com '(?d . ?y)) (viper-yank-defun)) | 1305 ((equal com '(?c . ?c)) (viper-line (cons value ?C))) |
1307 ((equal com '(?y . ?y)) (viper-line (cons value ?Y))) | 1306 ((equal com '(?d . ?d)) (viper-line (cons value ?D))) |
1308 ((equal com '(?< . ?<)) (viper-line (cons value ?<))) | 1307 ((equal com '(?d . ?y)) (viper-yank-defun)) |
1309 ((equal com '(?> . ?>)) (viper-line (cons value ?>))) | 1308 ((equal com '(?y . ?y)) (viper-line (cons value ?Y))) |
1310 ((equal com '(?! . ?!)) (viper-line (cons value ?!))) | 1309 ((equal com '(?< . ?<)) (viper-line (cons value ?<))) |
1311 ((equal com '(?= . ?=)) (viper-line (cons value ?=))) | 1310 ((equal com '(?> . ?>)) (viper-line (cons value ?>))) |
1312 (t (error ""))))) | 1311 ((equal com '(?! . ?!)) (viper-line (cons value ?!))) |
1313 | 1312 ((equal com '(?= . ?=)) (viper-line (cons value ?=))) |
1314 (if cmd-to-exec-at-end | 1313 ;; gg acts as G0 |
1315 (progn | 1314 ((equal (car com) ?g) (viper-goto-line 0)) |
1316 (setq last-command-char char) | 1315 (t (error ""))))) |
1317 (setq last-command-event | 1316 |
1318 (viper-copy-event | 1317 (if cmd-to-exec-at-end |
1319 (if viper-xemacs-p (character-to-event char) char))) | 1318 (progn |
1320 (condition-case nil | 1319 (setq last-command-char char) |
1321 (funcall cmd-to-exec-at-end cmd-info) | 1320 (setq last-command-event |
1322 (error | 1321 (viper-copy-event |
1323 (error ""))))) | 1322 (if viper-xemacs-p (character-to-event char) char))) |
1324 )) | 1323 (condition-case nil |
1324 (funcall cmd-to-exec-at-end cmd-info) | |
1325 (error | |
1326 (error ""))))) | |
1327 )) | |
1325 | 1328 |
1326 (defun viper-describe-arg (arg) | 1329 (defun viper-describe-arg (arg) |
1327 (let (val com) | 1330 (let (val com) |
1328 (setq val (viper-P-val arg) | 1331 (setq val (viper-P-val arg) |
1329 com (viper-getcom arg)) | 1332 com (viper-getcom arg)) |
1731 ((viper= char ?C) | 1734 ((viper= char ?C) |
1732 (upcase-region (min viper-com-point (point)) | 1735 (upcase-region (min viper-com-point (point)) |
1733 (max viper-com-point (point)))) | 1736 (max viper-com-point (point)))) |
1734 ((viper= char ?g) | 1737 ((viper= char ?g) |
1735 (push-mark viper-com-point t) | 1738 (push-mark viper-com-point t) |
1739 ;; execute the last emacs kbd macro on each line of the region | |
1736 (viper-global-execute)) | 1740 (viper-global-execute)) |
1737 ((viper= char ?q) | 1741 ((viper= char ?q) |
1738 (push-mark viper-com-point t) | 1742 (push-mark viper-com-point t) |
1739 (viper-quote-region)) | 1743 (viper-quote-region)) |
1740 ((viper= char ?s) | 1744 ((viper= char ?s) |
3994 ;; Search contents of buffer defined by one of Viper's motion commands. | 3998 ;; Search contents of buffer defined by one of Viper's motion commands. |
3995 ;; Repeatable via `n' and `N'. | 3999 ;; Repeatable via `n' and `N'. |
3996 (defun viper-buffer-search-enable (&optional c) | 4000 (defun viper-buffer-search-enable (&optional c) |
3997 (cond (c (setq viper-buffer-search-char c)) | 4001 (cond (c (setq viper-buffer-search-char c)) |
3998 ((null viper-buffer-search-char) | 4002 ((null viper-buffer-search-char) |
4003 ;; ?g acts as a default value for viper-buffer-search-char | |
3999 (setq viper-buffer-search-char ?g))) | 4004 (setq viper-buffer-search-char ?g))) |
4000 (define-key viper-vi-basic-map | 4005 (define-key viper-vi-basic-map |
4001 (cond ((viper-characterp viper-buffer-search-char) | 4006 (cond ((viper-characterp viper-buffer-search-char) |
4002 (char-to-string viper-buffer-search-char)) | 4007 (char-to-string viper-buffer-search-char)) |
4003 (t (error "viper-buffer-search-char: wrong value type, %S" | 4008 (t (error "viper-buffer-search-char: wrong value type, %S" |