Function: ex-map-read-args
ex-map-read-args is a byte-compiled function defined in
viper-macs.el.gz.
Signature
(ex-map-read-args VARIANT)
Source Code
;; Defined in /usr/src/emacs/lisp/emulation/viper-macs.el.gz
;; read arguments for ex-map
(defun ex-map-read-args (variant)
(let ((cursor-in-echo-area t)
(key-seq [])
temp key event message
macro-name macro-body args)
(condition-case nil
(setq args (concat (ex-get-inline-cmd-args ".*map[!]*[ \t]?" "\n\C-m")
" nil nil ")
temp (read-from-string args)
macro-name (car temp)
macro-body (car (read-from-string args (cdr temp))))
(error
(signal
'error
'("map: Macro name and body must be a quoted string or a vector"))))
;; We expect macro-name to be a vector, a string, or a quoted string.
;; In the second case, it will emerge as a symbol when read from
;; the above read-from-string. So we need to convert it into a string
(if macro-name
(cond ((vectorp macro-name) nil)
((stringp macro-name)
(setq macro-name (vconcat macro-name)))
(t (setq macro-name (vconcat (prin1-to-string macro-name)))))
(message ":map%s <Macro Name>" variant)(sit-for 2)
(while
(not (member key
'(?\C-m ?\n (control m) (control j) return linefeed)))
(setq key-seq (vconcat key-seq (if key (vector key) [])))
;; the only keys available for editing are these-- no help while there
(if (member
key
'(?\b ?\d '^? '^H (control h) (control \?) backspace delete))
(setq key-seq (seq-subseq key-seq 0 (- (length key-seq) 2))))
(setq message
(format
":map%s %s"
variant (if (> (length key-seq) 0)
(prin1-to-string (viper-display-macro key-seq))
"")))
(message "%s" message)
(setq event (read-key))
;;(setq event (viper-read-event))
(setq key
(if (viper-mouse-event-p event)
(progn
(message "%s (No mouse---only keyboard keys, please)"
message)
(sit-for 2)
nil)
(viper-event-key event)))
)
(setq macro-name key-seq))
(if (= (length macro-name) 0)
(error "Can't map an empty macro name"))
(setq macro-name (viper-fixup-macro macro-name))
(if (viper-char-array-p macro-name)
(setq macro-name (viper-char-array-to-macro macro-name)))
(if macro-body
(cond ((viper-char-array-p macro-body)
(setq macro-body (viper-char-array-to-macro macro-body)))
((vectorp macro-body) nil)
(t (error "map: Invalid syntax in macro definition"))))
(setq cursor-in-echo-area nil)(sit-for 0) ; this overcomes xemacs tty bug
(cons macro-name macro-body)))