
(defun edit-last-kbd-macro (&optional prefix buffer hook) "\
Edit the most recently defined keyboard macro." (interactive "P") (byte-code "Ĉ	
%" [last-kbd-macro prefix buffer hook nil MacEdit-edit-macro (lambda (x arg) (byte-code "	" [last-kbd-macro x] 2))] 6))

(defun edit-kbd-macro (cmd &optional prefix buffer hook in-hook out-hook) "\
Edit a keyboard macro which has been assigned a name by name-last-kbd-macro.
(See also edit-last-kbd-macro.)" (interactive "CCommand name: 
P") (byte-code "ƈ' 	 	\" K
! DEE&" [cmd in-hook out-hook prefix buffer hook nil MacEdit-edit-macro funcall lambda (x arg) fset quote x] 8))

(defun read-kbd-macro (start &optional end) "\
Read the region as a keyboard macro definition.
The region is interpreted as spelled-out keystrokes, e.g., `M-x abc RET'.
The resulting macro is installed as the \"current\" keyboard macro.

Symbols:  RET, SPC, TAB, DEL, LFD, NUL; C-key; M-key.  (Must be uppercase.)
          REM marks the rest of a line as a comment.
          Whitespace is ignored; other characters are copied into the macro." (interactive "r") (byte-code "È; !, 
\"!	\"# 	\", 	O" [start last-kbd-macro end nil MacEdit-parse-keys buffer-substring string-match "\\`(" ")\\'" 2 -2] 8))

(defun MacEdit-print-macro (macro-str local-map) (byte-code " ֎! d >` ?` :B @\"c[ =N c[ ![ \"cɉ?x c
!c
`; c!c`= #`= #`=  U \"  #+`=YcY XK=
GW
Y
X>GV<=-!P5O  #!)Vc!!c`=a c YyXZ YX\"Z\\ YX\"Z\\!!YXWV\"c	!#*`>%@ !A \"B  `C =9D E \"`F NNG !_@ !cH jI c!A cJ !K L \"M OGV^HN UD \":HO >D  :HP U c !!c:HQ UD E \":HR U 	c!c!:HS U&#D  :HT U:D U \"K A \"UTOV))) )." [save-map print-escape-newlines t key-symbol key-str key-last prefix-arg this-prefix local-map nil macro-str c-u argstartchar char str ch ch2 obarray cust int nl current-local-map ((byte-code "!" [save-map use-local-map] 2)) use-local-map MacEdit-peek-char MacEdit-read-key (digit-argument negative-argument universal-argument) format "prefix-arg (%d)
" - "prefix-arg -
" numberp "prefix-arg %d
" "type \"" MacEdit-insert-string "\"
" "" digit-argument MacEdit-prefix-arg negative-argument 45 universal-argument 4 MacEdit-read-char * self-insert-command "insert " 32 126 60 (backward-delete-char delete-backward-char backward-delete-char-untabify) 0 char-to-string -1 insert "\"" MacEdit-unread-chars quoted-insert "quoted-insert
" 48 55 8 "type \"\\%03o\"
" (isearch-forward isearch-backward isearch-forward-regexp isearch-backward-regexp) symbol-name "
" MacEdit-isearch-argument execute-extended-command MacEdit-read-argument commandp MacEdit-print funcall 30 " # " MacEdit-get-interactive string-match "\\`\\*" 1 97 (98 66 68 102 70 110 115 83 120 88) 99 67 107 78 118 user-variable-p] 59))

(defun MacEdit-prefix-arg (char c-u value) (byte-code "	! 	W 	[	=  ( U: [ ! H YH Xj 	!V 	W \"Z\\ ; t C 	! 	\" U ʉ!)" [sign value nil char c-u prefix-arg 1 numberp 0 -1 - 45 MacEdit-read-char 48 57 * 10 MacEdit-unread-chars] 9))

(defun MacEdit-insert-string (str) (byte-code "GW HV 
W% 
Zc
Wp 
U7 cm 
UB cm 
UM cm 
UX cm 
Uc cm 
\\!!\" 
W 
U 
U 
!\" TGW HY 
\" 
\" 
W ƈ 	OcS 
> 
\"c 
Z!\"T +" [i j ch str t 0 nil 127 160 128 "\\M-" 32 8 "\\b" 9 "\\t" 10 "\\n" 13 "\\r" 27 "\\e" insert "\\C-" char-to-string downcase 64 34 92 "\\" /= (127 255) format "\\%03o"] 14))

(defun MacEdit-lookup-key (map) (byte-code "	 	
\" 
\"

!$ 
O	\":- Ɖ5 Ή!H 
O \":Q ƉY ΉGGVl s GV GSH\"	," [loc map macro-str glob loc-str glob-str nil key-symbol key-str key-last lookup-key current-global-map integerp 0 "" logand 127] 11))

(defun MacEdit-read-argument (&optional obarray pred) (byte-code "= != GW% >% = GO=[ [ 
#		;Z 	GGVZ 	) =y =n G	Xy GG\\ P O
 PGO
 
#		; 	!! 	 !! \" cc!c) GV c!c," [str min-bsp exec key-symbol str-base key-last macro-str key-str obarray comp pred "" 0 execute-extended-command nil MacEdit-lookup-key current-global-map self-insert-command 60 (backward-delete-char delete-backward-char backward-delete-char-untabify) 9 try-completion -1 commandp intern insert "
" "execute-extended-command
" "type \"" MacEdit-insert-string "\"
"] 12))

(defun MacEdit-isearch-argument nil (byte-code " c 
X ?c 
=?c 
=c 
=c 
=c 
=c 
	=c 

=c 
=c 
=c ?c 
\"c 
Y 

=o   
! !QG 
W 
Y 
= 
	= 
=? G	X GT 
!P O 
=GU
!P = P GV c!c ˉ
!GVc!c+" [str min-bsp ch search-exit-option search-exit-char search-repeat-char search-reverse-char search-delete-char search-yank-word-char search-yank-line-char search-quote-char "" 0 nil MacEdit-read-char 127 13 9 /= 32 MacEdit-peek-char char-to-string -1 23 "" "type \"" MacEdit-insert-string "\"
" MacEdit-read-argument MacEdit-unread-chars "\\e\"
"] 15))

(defun MacEdit-read-key nil (byte-code " ! 	
GO" [key-symbol macro-str key-str MacEdit-lookup-key current-local-map nil] 5))

(defun MacEdit-peek-char nil (byte-code "GV
 H" [macro-str 0] 2))

(defun MacEdit-read-char nil (byte-code "GV HO" [macro-str 0 1 nil] 4))

(defun MacEdit-unread-chars (chars) (byte-code "! ! 	P" [chars macro-str integerp char-to-string] 4))

(defun MacEdit-dump (mac) (byte-code "!c	 \"" [nil mac set-mark-command "

" MacEdit-print-macro current-local-map] 5))

(defun MacEdit-parse-keys (str) (byte-code "GW # !!!O	
GV7 
HU7 
HUE 
Oςz 
GVi 
HUi 
HUi 
HUi 
HUy 
OPςz 
\"A 
\" # G ņ 
GU 
HU 
HU 
H\"! 
Q 	+" [pos mac part str 0 "" nil string-match "[^ 	
]+" match-end match-beginning 2 1 45 77 "" 4 67 3 "C-" assoc (("NUL" . " ") ("RET" . "") ("LFD" . "
") ("TAB" . "	") ("ESC" . "") ("SPC" . " ") ("DEL" . "") ("C-?" . "") ("C-2" . " ") ("C-SPC" . " ")) equal "REM" "
" char-to-string logand 31] 14))

(defun MacEdit-read-macro (&optional map) (byte-code "  !m?5!-!& !-!6 !P!-!g !!
Vc 
\"UT !!
\"B )-!s !-! !p!!iW !-! !p!!iW !-! !Sb!!\"!!-!*!!!N \"&! !\" \" !# #!%!Q!)+-!! 	)" [map macro-str val func arg cust keys t current-local-map "" skip-chars-forward " 	
" looking-at "#" "prefix-arg[ 	]*-[ 	]*
" MacEdit-append-chars "-" "prefix-arg[ 	]*\\(-?[0-9]+\\)[ 	]*
" "" MacEdit-match-string 1 "prefix-arg[ 	]*(\\([0-9]+\\))[ 	]*
" string-to-int % 4 0 error "Bad prefix argument value" / "prefix-arg" "Bad prefix argument syntax" "insert " forward-char 7 read forward-line -1 "type " 5 "keys \\(.*\\)
" match-end MacEdit-parse-keys buffer-substring match-beginning "\\([-a-zA-z0-9_]+\\)[ 	]*\\(.*\\)
" intern 2 MacEdit-read funcall commandp "Not an Emacs command" equal string-match "\\`#" "Unexpected argument to command" where-is-internal current-global-map "x" symbol-name "
" "Syntax error"] 54))

(defun MacEdit-append-chars (chars) (byte-code "	P" [macro-str chars] 2))

(defun MacEdit-match-string (n) (byte-code "! !!\" ć" [n match-beginning buffer-substring match-end ""] 6))

(defun MacEdit-get-interactive (func) (byte-code "9 N	 	 K!)I !=E 8:. 81 8
!=D 
8;D 
8)I ˇ" [func cust int MacEdit-interactive MacEdit-get-interactive car-safe lambda 2 3 interactive 1 ""] 5))

(put (quote search-forward) (quote MacEdit-interactive) "s")

(put (quote search-backward) (quote MacEdit-interactive) "s")

(put (quote word-search-forward) (quote MacEdit-interactive) "s")

(put (quote word-search-backward) (quote MacEdit-interactive) "s")

(put (quote re-search-forward) (quote MacEdit-interactive) "s")

(put (quote re-search-backward) (quote MacEdit-interactive) "s")

(put (quote switch-to-buffer) (quote MacEdit-interactive) "B")

(put (quote kill-buffer) (quote MacEdit-interactive) "B")

(put (quote rename-buffer) (quote MacEdit-interactive) "B
B")

(put (quote goto-char) (quote MacEdit-interactive) "N")

(put (quote global-set-key) (quote MacEdit-interactive) "k
C")

(put (quote global-unset-key) (quote MacEdit-interactive) "k")

(put (quote local-set-key) (quote MacEdit-interactive) "k
C")

(put (quote local-unset-key) (quote MacEdit-interactive) "k")

(defun MacEdit-edit-macro (mac repl &optional prefix buffer hook arg) (byte-code "; !p!  \"=  !q !ȉ߉	
!	!!! 
r s 
| } %!#!\"!eb!!!!!," [mac oldbuf from-calc local buf buffer MacEdit-mode-map buffer-read-only nil major-mode mode-name MacEdit-original-buffer MacEdit-replace-function repl MacEdit-replace-argument arg MacEdit-finish-hook hook error "Not a keyboard macro" get-buffer-window "*Calculator*" lookup-key current-global-map "#" calc-dispatch current-local-map get-buffer-create "*Edit Macro*" kill-all-local-variables use-local-map MacEdit-mode "Edit Macro" make-local-variable erase-buffer insert "# Keyboard Macro Editor.  Press " "M-# M-#" "C-c C-c" " to finish; press " "M-# x" "C-x k RET" " to cancel.
" "# Original keys: " key-description "

" message "Formatting keyboard macro..." MacEdit-print-macro switch-to-buffer forward-line 3 recenter (4) set-buffer-modified-p "Formatting keyboard macro...done" run-hooks MacEdit-format-hook] 25))

(defun MacEdit-finish-edit nil (interactive) (byte-code "ˈ! ! ! ! =# !p eb p p !!
!V 
q )!	
!d 
!	#)!	! \"-" [major-mode buf str func MacEdit-replace-function arg MacEdit-replace-argument hook MacEdit-finish-hook mac MacEdit-original-buffer nil boundp MacEdit-mode error "This command is valid only in buffers created by edit-kbd-macro." buffer-string buffer-modified-p message "Compiling keyboard macro..." run-hooks MacEdit-compile-hook MacEdit-read-macro buffer-name current-local-map switch-to-buffer funcall "Compiling keyboard macro...done" kill-buffer] 20))

(defun MacEdit-cancel-edit nil (interactive) (byte-code "= ! !" [major-mode nil MacEdit-mode set-buffer-modified-p MacEdit-finish-edit message "(Cancelled)"] 4))

(defun MacEdit-mode nil "\
Keyboard Macro Editing mode.  Press C-c C-c to save and exit.
To abort the edit, just kill this buffer with C-x k RET.

The keyboard macro is represented as a series of M-x style command names.
Keystrokes which do not correspond to simple M-x commands are written as
\"type\" commands.  When you press C-c C-c, MacEdit converts each command
back into a suitable keystroke sequence; \"type\" commands are converted
directly back into keystrokes." (interactive) (byte-code "!" [nil error "This mode can be enabled only by edit-kbd-macro or edit-last-kbd-macro."] 2))

(put (quote MacEdit-mode) (quote mode-class) (quote special))

(defvar MacEdit-mode-map nil)

(if MacEdit-mode-map nil (setq MacEdit-mode-map (make-sparse-keymap)) (define-key MacEdit-mode-map "" (quote MacEdit-finish-edit)))
