i implementing plugin, lot of project types remembered. example: angular, meteor, ember, rails ...
and keyed arguments used. function creates hash table provided keys , values, , assign hash table hash table.
code below:
(defun jst-remember-project-type (type &rest args) "let jst remember 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)
and have lot of redundant functions this. want these kind of functions automatically generated macro.
actually, list of keys , table needed. else can generated. don't know how write macro.
(defmacro jst-remember-keyed (keys table) "this macro helps jst-remember functions." (let (label value question here keys)))
how convert variable :symbol , convert :symbol variable easily?
(make-symbol "fuck") fuck ;; error occurs (let (((make-symbol "fuck") "diao")) (message fuck) ) ;; error occurs
thanks lot!
untested:
(require 'cl) (defun jst-remember-project-type (type &rest args) "let jst remember project type." (if (gethash type jst-known-project-types) (error "redefined jst project type.""") (let ((table (make-hash-table :test #'equal))) (loop (label value) on args #'cddr (puthash label value table)) (puthash type table jst-known-project-types))))
Comments
Post a Comment