Setup auto-fill-chars.
[bpt/emacs.git] / lisp / edmacro.el
index 7f2d8d4..150160c 100644 (file)
@@ -88,6 +88,10 @@ Default nil means to write characters above \\177 in octal notation.")
   (define-key edmacro-mode-map "\C-c\C-c" 'edmacro-finish-edit)
   (define-key edmacro-mode-map "\C-c\C-q" 'edmacro-insert-key))
 
+(defvar edmacro-store-hook)
+(defvar edmacro-finish-hook)
+(defvar edmacro-original-buffer)
+
 ;;;###autoload
 (defun edit-kbd-macro (keys &optional prefix finish-hook store-hook)
   "Edit a keyboard macro.
@@ -112,6 +116,8 @@ With a prefix argument, format the macro in a more concise way."
             (setq cmd 'last-kbd-macro))
            ((eq cmd 'execute-extended-command)
             (setq cmd (read-command "Name of keyboard macro to edit: "))
+            (if (string-equal cmd "")
+                (error "No command name given"))
             (setq mac (symbol-function cmd)))
            ((eq cmd 'view-lossage)
             (setq mac (recent-keys))
@@ -687,10 +693,12 @@ If START or END is negative, it counts from the end."
                        (error "%s must prefix a single character, not %s"
                               (substring orig-word 0 prefix) word))
                       ((and (/= (logand bits ?\C-\^@) 0) (stringp word)
-                            (string-match "[@-_.a-z?]" word))
+                            ;; We used to accept . and ? here,
+                            ;; but . is simply wrong,
+                            ;; and C-? is not used (we use DEL instead).
+                            (string-match "[@-_a-z]" word))
                        (setq key (list (+ bits (- ?\C-\^@)
-                                          (if (equal word "?") 127
-                                            (logand (aref word 0) 31))))))
+                                          (logand (aref word 0) 31)))))
                       (t
                        (setq key (list (+ bits (aref word 0)))))))))
        (when key
@@ -710,41 +718,6 @@ If START or END is negative, it counts from the end."
                      collect (if (= (logand ch ?\M-\^@) 0)
                                  ch (+ ch 128))))
       res)))
-\f
-;;; The following probably ought to go in macros.el:
-
-;;;###autoload
-(defun insert-kbd-macro (macroname &optional keys)
-  "Insert in buffer the definition of kbd macro NAME, as Lisp code.
-Optional second arg KEYS means also record the keys it is on
-\(this is the prefix argument, when calling interactively).
-
-This Lisp code will, when executed, define the kbd macro with the same
-definition it has now.  If you say to record the keys, the Lisp code
-will also rebind those keys to the macro.  Only global key bindings
-are recorded since executing this Lisp code always makes global
-bindings.
-
-To save a kbd macro, visit a file of Lisp code such as your `~/.emacs',
-use this command, and then save the file."
-  (interactive "CInsert kbd macro (name): \nP")
-  (let (definition)
-    (if (string= (symbol-name macroname) "")
-       (progn
-         (setq definition (format-kbd-macro))
-         (insert "(setq last-kbd-macro"))
-      (setq definition (format-kbd-macro macroname))
-      (insert (format "(defalias '%s" macroname)))
-    (if (> (length definition) 50)
-       (insert " (read-kbd-macro\n")
-      (insert "\n  (read-kbd-macro "))
-    (prin1 definition (current-buffer))
-    (insert "))\n")
-    (if keys
-       (let ((keys (where-is-internal macroname '(keymap))))
-         (while keys
-           (insert (format "(global-set-key %S '%s)\n" (car keys) macroname))
-           (setq keys (cdr keys)))))))
 
 (provide 'edmacro)