emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/lisp/edmacro.el


From: Kim F . Storm
Subject: [Emacs-diffs] Changes to emacs/lisp/edmacro.el
Date: Thu, 30 Sep 2004 09:35:07 -0400

Index: emacs/lisp/edmacro.el
diff -c emacs/lisp/edmacro.el:1.32 emacs/lisp/edmacro.el:1.33
*** emacs/lisp/edmacro.el:1.32  Mon Sep  1 15:45:11 2003
--- emacs/lisp/edmacro.el       Thu Sep 30 13:27:35 2004
***************
*** 73,78 ****
--- 73,80 ----
  (eval-when-compile
   (require 'cl))
  
+ (require 'kmacro)
+ 
  ;;; The user-level commands for editing macros.
  
  ;;;###autoload
***************
*** 101,107 ****
    (interactive "kKeyboard macro to edit (C-x e, M-x, C-h l, or keys): \nP")
    (when keys
      (let ((cmd (if (arrayp keys) (key-binding keys) keys))
!         (mac nil))
        (cond (store-hook
             (setq mac keys)
             (setq cmd nil))
--- 103,110 ----
    (interactive "kKeyboard macro to edit (C-x e, M-x, C-h l, or keys): \nP")
    (when keys
      (let ((cmd (if (arrayp keys) (key-binding keys) keys))
!         (mac nil) (mac-counter nil) (mac-format nil)
!         kmacro)
        (cond (store-hook
             (setq mac keys)
             (setq cmd nil))
***************
*** 112,125 ****
--- 115,131 ----
                 (y-or-n-p "No keyboard macro defined.  Create one? ")
                 (keyboard-quit))
             (setq mac (or last-kbd-macro ""))
+            (setq keys nil)
             (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 keys nil)
             (setq mac (symbol-function cmd)))
            ((memq cmd '(view-lossage electric-view-lossage))
             (setq mac (recent-keys))
+            (setq keys nil)
             (setq cmd 'last-kbd-macro))
            ((null cmd)
             (error "Key sequence %s is not defined" (key-description keys)))
***************
*** 128,133 ****
--- 134,143 ----
            (t
             (setq mac cmd)
             (setq cmd nil)))
+       (when (setq kmacro (kmacro-extract-lambda mac))
+       (setq mac (car kmacro)
+             mac-counter (nth 1 kmacro)
+             mac-format (nth 2 kmacro)))
        (unless (arrayp mac)
        (error "Key sequence %s is not a keyboard macro"
               (key-description keys)))
***************
*** 153,163 ****
        (insert ";; Original keys: " fmt "\n")
        (unless store-hook
          (insert "\nCommand: " (if cmd (symbol-name cmd) "none") "\n")
!         (let ((keys (where-is-internal (or cmd mac) '(keymap))))
!           (if keys
!               (while keys
!                 (insert "Key: " (edmacro-format-keys (pop keys) 1) "\n"))
!             (insert "Key: none\n"))))
        (insert "\nMacro:\n\n")
        (save-excursion
          (insert fmtv "\n"))
--- 163,177 ----
        (insert ";; Original keys: " fmt "\n")
        (unless store-hook
          (insert "\nCommand: " (if cmd (symbol-name cmd) "none") "\n")
!         (let ((gkeys (where-is-internal (or cmd mac) '(keymap))))
!           (if (and keys (not (member keys gkeys)))
!               (setq gkeys (cons keys gkeys)))
!           (if gkeys
!               (while gkeys
!                 (insert "Key: " (edmacro-format-keys (pop gkeys) 1) "\n"))
!             (insert "Key: none\n")))
!         (when (and mac-counter mac-format)
!           (insert (format "Counter: %d\nFormat: \"%s\"\n" mac-counter 
mac-format))))
        (insert "\nMacro:\n\n")
        (save-excursion
          (insert fmtv "\n"))
***************
*** 217,222 ****
--- 231,237 ----
       "This command is valid only in buffers created by `edit-kbd-macro'"))
    (run-hooks 'edmacro-finish-hook)
    (let ((cmd nil) (keys nil) (no-keys nil)
+       (mac-counter nil) (mac-format nil) (kmacro nil)
        (top (point-min)))
      (goto-char top)
      (let ((case-fold-search nil))
***************
*** 231,236 ****
--- 246,252 ----
                        (setq cmd (and (not (equal str "none"))
                                       (intern str)))
                        (and (fboundp cmd) (not (arrayp (symbol-function cmd)))
+                            (not (setq kmacro (get cmd 'kmacro)))
                             (not (y-or-n-p
                                   (format "Command %s is already defined; %s"
                                           cmd "proceed? ")))
***************
*** 248,253 ****
--- 264,270 ----
                          (push key keys)
                          (let ((b (key-binding key)))
                            (and b (commandp b) (not (arrayp b))
+                                (not (kmacro-extract-lambda b))
                                 (or (not (fboundp b))
                                     (not (arrayp (symbol-function b))))
                                 (not (y-or-n-p
***************
*** 256,261 ****
--- 273,294 ----
                                               "proceed? ")))
                                 (keyboard-quit))))))
                    t)
+                  ((looking-at "Counter:[ \t]*\\([^ \t\n]*\\)[ \t]*$")
+                   (when edmacro-store-hook
+                     (error "\"Counter\" line not allowed in this context"))
+                   (let ((str (buffer-substring (match-beginning 1)
+                                                (match-end 1))))
+                     (unless (equal str "")
+                       (setq mac-counter (string-to-int str))))
+                   t)
+                  ((looking-at "Format:[ \t]*\"\\([^\n]*\\)\"[ \t]*$")
+                   (when edmacro-store-hook
+                     (error "\"Format\" line not allowed in this context"))
+                   (let ((str (buffer-substring (match-beginning 1)
+                                                (match-end 1))))
+                     (unless (equal str "")
+                       (setq mac-format str)))
+                   t)
                   ((looking-at "Macro:[ \t\n]*")
                    (goto-char (match-end 0))
                    nil)
***************
*** 285,291 ****
            (when cmd
              (if (= (length mac) 0)
                  (fmakunbound cmd)
!               (fset cmd mac)))
            (if no-keys
                (when cmd
                  (loop for key in (where-is-internal cmd '(keymap)) do
--- 318,327 ----
            (when cmd
              (if (= (length mac) 0)
                  (fmakunbound cmd)
!               (fset cmd
!                     (if (and mac-counter mac-format)
!                         (kmacro-lambda-form mac mac-counter mac-format)
!                       mac))))
            (if no-keys
                (when cmd
                  (loop for key in (where-is-internal cmd '(keymap)) do
***************
*** 294,300 ****
                (if (= (length mac) 0)
                    (loop for key in keys do (global-unset-key key))
                  (loop for key in keys do
!                       (global-set-key key (or cmd mac)))))))))
        (kill-buffer buf)
        (when (buffer-name obuf)
        (switch-to-buffer obuf))
--- 330,340 ----
                (if (= (length mac) 0)
                    (loop for key in keys do (global-unset-key key))
                  (loop for key in keys do
!                       (global-set-key key
!                                       (or cmd
!                                           (if (and mac-counter mac-format)
!                                               (kmacro-lambda-form mac 
mac-counter mac-format)
!                                             mac))))))))))
        (kill-buffer buf)
        (when (buffer-name obuf)
        (switch-to-buffer obuf))




reply via email to

[Prev in Thread] Current Thread [Next in Thread]