在Emacs-22上使用macroexpand-1

时间:2018-11-14 12:04:45

标签: emacs macros emacs22

我正在开发一种可从Emacs-22使用的名为leaf的软件包,我想在测试时使用macroexpand-1

但是macroexpand-1尚未在Emacs-22和Emacs-26中定义,因此无法定义代码,因为即使我尝试定义基于C的autoload-do-load函数也是如此。

在Emacs-22中是否无法使用macroexpand-1?实施提示 macroexpand-1的另一种方法是Elisp。

(Emacs-22与/usr/bin/emacs的macOS捆绑在一起)

1 个答案:

答案 0 :(得分:0)

请参阅PR。 https://github.com/conao3/leaf.el/pull/36/commits/47cf0b7c8d6b83b21800d01c594cef8e8d531e57

(when (not (fboundp 'autoload-do-load))
  (defun autoload-do-load (fundef &optional funname macro-only)
    (if (or (not (consp fundef)) (not (eql 'autoload (car fundef))))
        fundef
      (let ((kind (nth 4 fundef)))
        (if (and (eql macro-only 'macro)
                 (not (or (eql kind t)
                          (eql kind 'macro))))
            fundef)
        (if purify-flag
            (error "Attempt to autoload %s while preparing to dump" (symbol-name funnname)))
        (unwind-protect
            (let ((ignore-errors (if (or (eql kind t) (eql kind 'macro)) nil macro_only)))
              (load (cadr fundef) ignore-errors t nil t))
          ;; FIXME: revert partially performed defuns
          ())
        (if (or (not funname) ignore-errors)
            nil
          (let ((fun (indirect-function funname, nil)))
            (if (equal fun fundef)
                (error "Autoloading file %s failed to define function %s"
                       (caar load-history)
                       (symbol-name funname))
              fun)))))))