Elisp:如何缩短这个函数

Elisp: how to make this function short

我正在实现一个插件,很多项目类型都是 remembered。例如:angular、流星、ember、rails ...

并且使用了键控参数。该函数使用提供的键和值创建一个散列 table,并将散列 table 分配给另一个散列 table.

代码如下:

    (defun jst-remember-project-type (type &rest args)
      "Let JST remember another project type."
      (let (label value testing-framework spec-dir config-file source-dir
                  command-ci command-browser spec-to-target target-to-spec
                  dominating-files browser-url table)
        (while (not (= 0 (length args)))
          (setq label (pop args))
          (setq value (pop args))
          (and (equal :testing-framework label) (setq testing-framework value))
          (and (equal :spec-dir label) (setq spec-dir value))
          (and (equal :source-dir label) (setq source-dir value))
          (and (equal :config-file label) (setq config-file value))
          (and (equal :command-ci label) (setq command-ci value))
          (and (equal :command-browser label) (setq command-browser value))
          (and (equal :browser-url label) (setq browser-url value))
          (and (equal :spec-to-target label) (setq spec-to-target value))
          (and (equal :target-to-spec label) (setq target-to-spec value))
          (and (equal :dominating-files label) (setq dominating-files value)))
        (if (gethash type jst-known-project-types)
            (error "Redefined JST project type.")
          (setq table (make-hash-table :test 'equal))
          (puthash :testing-framework testing-framework table)
          (puthash :spec-dir spec-dir table)
          (puthash :config-file config-file table)
          (puthash :source-dir spec-dir table)
          (puthash :command-ci command-ci table)
          (puthash :command-browser command-browser table)
          (puthash :spec-to-target spec-to-target table)
          (puthash :target-to-spec target-to-spec table)
          (puthash :dominating-files dominating-files table)
          (puthash :browser-url browser-url table)
          (puthash type table jst-known-project-types))) nil)

而且我有很多像这样的冗余功能。我想要这些由宏自动生成的函数。

实际上,只需要一个键列表和一个table。其他一切都可以生成。但是我不知道怎么写宏

    (defmacro jst-remember-keyed (keys table)
      "This macro helps with jst-remember functions."
      (let (label value QUESTION HERE keys)))

如何轻松地将 :symbol 转换为变量并从变量转换为 :symbol?

    (make-symbol "fuck")
    fuck ;; Error occurs

    (let (((make-symbol "fuck") "Diao"))
      (message fuck)
      ) ;; Error occurs

非常感谢!

未测试:

(require 'cl)
(defun jst-remember-project-type (type &rest args)
  "Let JST remember another project type."
  (if (gethash type jst-known-project-types)
      (error "Redefined JST project type.""")
    (let ((table (make-hash-table :test #'equal)))
      (loop for (label value) on args by #'cddr
            do (puthash label value table))
      (puthash type table jst-known-project-types))))