我想我从字面上遵循了这个例子,但它不起作用。如果我使用defimage
宏,则不会创建图像描述符,但是当我使用时,create-image
它会使用所有相同的参数。以下是我尝试过的:
(defimage test ((:type png :file "/home/wvxvw/Projects/haxe-mode/trunk/ede/etc/images/interface.png")))
test ; nil
(defimage test (:type png :file "/home/wvxvw/Projects/haxe-mode/trunk/ede/etc/images/interface.png"))
test ; nil
(insert-image test) ; error
(setq test (create-image "/home/wvxvw/Projects/haxe-mode/trunk/ede/etc/images/interface.png" 'png nil))
(image :type png :file "/home/wvxvw/Projects/haxe-mode/trunk/ede/etc/images/interface.png")
(insert-image test) ; shows image
有什么提示吗?
编辑:
虽然上面的代码应该说明问题,但我尝试运行的实际代码涉及更多。发布它以防万一:
(require 'cl)
(defvar haxe-images-dir
(concat (file-name-directory load-file-name) "etc/images/"))
(defmacro haxe-define-images (images)
(append
'(progn)
(loop for image in images
collect
`(defimage ,(intern (concat "haxe-" image "-icon"))
((:type png :file
(concat haxe-images-dir ,(concat image ".png"))))))))
(haxe-define-images
("private" "public" "static" "instance" "inline"
"volatile" "variable" "class" "interface" "macro"
"enum" "deftype" "function"))
编辑2:
这就是它最终的工作方式。也许我编译了一些代码部分,因此从不同的地方加载了一些这样的谜团......
(require 'cl)
(require 'haxe-project)
(defmacro haxe-define-images (images)
(append
`(progn)
(loop for image in images
with images-root = (concat haxe-install-dir "etc/images/")
collect
`(defimage ,(intern (concat "haxe-" image "-icon"))
((:type png :file
,(concat images-root image ".png")))))))
(haxe-define-images
("private" "public" "static" "instance" "inline"
"volatile" "variable" "class" "interface" "macro"
"enum" "deftype" "function"))