Mercurial > emacs
comparison lisp/emulation/viper-macs.el @ 12140:75379a19c5d5
Changed vip-*-frame-* to *-frame-*, incorporated overlay strings,
unread-command-events, removed support for emacs versions 19.28 and
xemacs 19.11 and earlier.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Fri, 09 Jun 1995 00:12:29 +0000 |
parents | d1f620273acb |
children | 3d339e94aece |
comparison
equal
deleted
inserted
replaced
12139:e16c06646396 | 12140:75379a19c5d5 |
---|---|
1 ;;; viper-macs.el -- functions implementing keyboard macros for Viper | 1 ;;; viper-macs.el -- functions implementing keyboard macros for Viper |
2 | 2 ;; Copyright (C) 1994, 1995 Free Software Foundation, Inc. |
3 ;; Copyright (C) 1995 Free Software Foundation, Inc. | |
4 | 3 |
5 ;; This file is part of GNU Emacs. | 4 ;; This file is part of GNU Emacs. |
6 | 5 |
7 ;; GNU Emacs is free software; you can redistribute it and/or modify | 6 ;; GNU Emacs is free software; you can redistribute it and/or modify |
8 ;; it under the terms of the GNU General Public License as published by | 7 ;; it under the terms of the GNU General Public License as published by |
43 "Vector of keys representing the name of currently running Viper kbd macro.") | 42 "Vector of keys representing the name of currently running Viper kbd macro.") |
44 (defvar vip-last-kbd-macro nil | 43 (defvar vip-last-kbd-macro nil |
45 "Vector of keys representing the name of last Viper keyboard macro.") | 44 "Vector of keys representing the name of last Viper keyboard macro.") |
46 | 45 |
47 (defconst vip-fast-keyseq-timeout 200 | 46 (defconst vip-fast-keyseq-timeout 200 |
48 "*Key sequences separated by this many miliseconds are interpreted as a macro, if such a macro is defined. | 47 "*Key sequence separated by no more than this many milliseconds is viewed as a macro, if such a macro is defined. |
49 This also controls ESC-keysequences generated by keyboard function keys.") | 48 This also controls ESC-keysequences generated by keyboard function keys.") |
50 | 49 |
51 | 50 |
52 (defvar vip-repeat-from-history-key 'f1 | 51 (defvar vip-repeat-from-history-key 'f1 |
53 "Prefix key for invocation of vip-repeat-from-history function, | 52 "Prefix key for invocation of vip-repeat-from-history function, |
60 | 59 |
61 | 60 |
62 | 61 |
63 ;;; Code | 62 ;;; Code |
64 | 63 |
64 ;; Ex map command | |
65 (defun ex-map () | 65 (defun ex-map () |
66 "Ex map command." | |
67 (let ((mod-char "") | 66 (let ((mod-char "") |
68 macro-name macro-body map-args ins) | 67 macro-name macro-body map-args ins) |
69 (save-window-excursion | 68 (save-window-excursion |
70 (set-buffer vip-ex-work-buf) | 69 (set-buffer vip-ex-work-buf) |
71 (if (looking-at "!") | 70 (if (looking-at "!") |
91 (vip-display-macro macro-name) | 90 (vip-display-macro macro-name) |
92 (if ins "Insert" "Vi"))) | 91 (if ins "Insert" "Vi"))) |
93 )) | 92 )) |
94 | 93 |
95 | 94 |
95 ;; Ex unmap | |
96 (defun ex-unmap () | 96 (defun ex-unmap () |
97 "Ex unmap." | |
98 (let ((mod-char "") | 97 (let ((mod-char "") |
99 temp macro-name ins) | 98 temp macro-name ins) |
100 (save-window-excursion | 99 (save-window-excursion |
101 (set-buffer vip-ex-work-buf) | 100 (set-buffer vip-ex-work-buf) |
102 (if (looking-at "!") | 101 (if (looking-at "!") |
176 (if macro-body | 175 (if macro-body |
177 (cond ((vip-char-array-p macro-body) | 176 (cond ((vip-char-array-p macro-body) |
178 (setq macro-body (vip-char-array-to-macro macro-body))) | 177 (setq macro-body (vip-char-array-to-macro macro-body))) |
179 ((vectorp macro-body) nil) | 178 ((vectorp macro-body) nil) |
180 (t (error "map: Invalid syntax in macro definition")))) | 179 (t (error "map: Invalid syntax in macro definition")))) |
181 (cons macro-name macro-body) | 180 (setq cursor-in-echo-area nil)(sit-for 0) ; this overcomes xemacs tty bug |
182 )) | 181 (cons macro-name macro-body))) |
183 | 182 |
184 | 183 |
185 | 184 |
186 ;; read arguments for ex-unmap | 185 ;; read arguments for ex-unmap |
187 (defun ex-unmap-read-args (variant) | 186 (defun ex-unmap-read-args (variant) |
442 | 441 |
443 | 442 |
444 | 443 |
445 ;; macro name must be a vector of vip-style keys | 444 ;; macro name must be a vector of vip-style keys |
446 (defun vip-unrecord-kbd-macro (macro-name state) | 445 (defun vip-unrecord-kbd-macro (macro-name state) |
446 "Delete macro MACRO-NAME from Viper STATE. | |
447 MACRO-NAME must be a vector of vip-style keys. This command is used by Viper | |
448 internally, but the user can also use it in ~/.vip to delete pre-defined macros | |
449 supplied with Viper. The best way to avoid mistakes in macro names to be passed | |
450 to this function is to use vip-describe-kbd-macros and copy the name from | |
451 there." | |
447 (let* (state-name keymap | 452 (let* (state-name keymap |
448 (macro-alist-var | 453 (macro-alist-var |
449 (cond ((eq state 'vi-state) | 454 (cond ((eq state 'vi-state) |
450 (setq state-name "Vi state" | 455 (setq state-name "Vi state" |
451 keymap vip-vi-kbd-map) | 456 keymap vip-vi-kbd-map) |
519 (vector (vip-key-to-emacs-key (aref macro-name 0))) | 524 (vector (vip-key-to-emacs-key (aref macro-name 0))) |
520 nil)) | 525 nil)) |
521 )) | 526 )) |
522 )) | 527 )) |
523 | 528 |
524 ;; Checks if MACRO-ALIST has an entry for a macro name starting with | 529 ;; Check if MACRO-ALIST has an entry for a macro name starting with |
525 ;; CHAR. If not, this indicates that the binding for this char | 530 ;; CHAR. If not, this indicates that the binding for this char |
526 ;; in vip-vi/insert-kbd-map can be released. | 531 ;; in vip-vi/insert-kbd-map can be released. |
527 (defun vip-can-release-key (char macro-alist) | 532 (defun vip-can-release-key (char macro-alist) |
528 (let ((lis macro-alist) | 533 (let ((lis macro-alist) |
529 (can-release t) | 534 (can-release t) |
749 (car elt)))) | 754 (car elt)))) |
750 macro-alist)) | 755 macro-alist)) |
751 (setq candidates (delq nil candidates)))) | 756 (setq candidates (delq nil candidates)))) |
752 | 757 |
753 | 758 |
754 ;; if seq of key symbols can be converted to a string--do so. Otherwise, do | 759 ;; if seq of Viper key symbols (representing a macro) can be converted to a |
755 ;; nothing. | 760 ;; string--do so. Otherwise, do nothing. |
756 (defun vip-display-macro (macro-name) | 761 (defun vip-display-macro (macro-name) |
757 (cond ((vip-char-symbol-sequence-p macro-name) | 762 (cond ((vip-char-symbol-sequence-p macro-name) |
758 (mapconcat 'symbol-name macro-name "")) | 763 (mapconcat 'symbol-name macro-name "")) |
759 ((vip-char-array-p macro-name) | 764 ((vip-char-array-p macro-name) |
760 (mapconcat 'char-to-string macro-name "")) | 765 (mapconcat 'char-to-string macro-name "")) |
761 (t macro-name))) | 766 (t macro-name))) |
762 | 767 |
763 (defun vip-events-to-macro (event-seq) | 768 (defun vip-events-to-macro (event-seq) |
764 (vconcat (mapcar 'vip-event-key event-seq))) | 769 (vconcat (mapcar 'vip-event-key event-seq))) |
765 | 770 |
766 ;; convert strings of characters or arrays of characters to Viper macro form | 771 ;; convert strings or arrays of characters to Viper macro form |
767 (defun vip-char-array-to-macro (array) | 772 (defun vip-char-array-to-macro (array) |
768 (let ((vec (vconcat array)) | 773 (let ((vec (vconcat array)) |
769 macro) | 774 macro) |
770 (if vip-xemacs-p | 775 (if vip-xemacs-p |
771 (setq macro (mapcar 'character-to-event vec)) | 776 (setq macro (mapcar 'character-to-event vec)) |