[英]Wrong type error in dbus method (GNU Emacs)
我正在編寫一個elisp文件,通過dbus將GNU Emacs與Zeitgeist集成。 由於缺乏關於emacs中dbus的良好文檔以及我缺乏高級elisp的經驗,我在我的方法zeitgeist-send
中遇到以下錯誤:
錯誤的類型參數:D-Bus,(zeitgeist-event-timestamp)
我嘗試通過在所有參數之前放置:string
糾正問題,但這給了我錯誤:
錯誤的類型參數:stringp,(zeitgeist-event-timestamp)
這沒有任何意義,因為我很肯定(zeitgeist-event-timestamp)的值是一個字符串。
如果需要,zeitgeist的dbus文檔就在這里 。 它的格式是asaasay
。
這是代碼:
(require 'dbus)
(defun zeitgeist-call (method &rest args)
"Call the zeitgeist method METHOD with ARGS over dbus"
(apply 'dbus-call-method
:session ; use the session (not system) bus
"org.gnome.zeitgeist.Engine" ; service name
"/org/gnome/zeitgeist/log/activity" ; path name
"org.gnome.zeitgeist.Log" ; interface name
method args))
(defun zeitgeist-event-timestamp ()
"Get the timestamp in zeitgeist format."
(let* ((now-time (current-time))
(hi (car now-time))
(lo (car (cdr now-time)))
(msecs (car (cdr (cdr now-time))))) ; This is *micro*seconds.
(number-to-string (+ (/ msecs 1000)
(* (+ lo (* hi 65536)) 1000))))) ; Convert system time to milliseconds.
(defun zeitgeist-event-interpretation (event)
"Get the Event Interpretation of EVENT."
(case event
('zeitgeist-open-event
"http://zeitgeist-project.com/ontologies/2010/01/27/zg#AccessEvent")
('zeitgeist-close-event
"http://zeitgeist-project.com/schema/1.0/core#CloseEvent")
('zeitgeist-create-event
"http://zeitgeist-project.com/schema/1.0/core#CreateEvent")
('zeitgeist-modify-event
"http://zeitgeist-project.com/schema/1.0/core#ModifyEvent")
(otherwise nil)))
(defun zeitgeist-send (event fileurl filemime)
"Send zeitgeist an event EVENT using the list FILEINFO."
(let ((event-interpretation (zeitgeist-event-interpretation event)))
(if (eq nil event-interpretation)
(message "YOU FAIL")
(zeitgeist-call "InsertEvents"
'(""
(zeitgeist-event-timestamp)
event-interpretation
"http://zeitgeist-project.com/schema/1.0/core#UserActivity"
"app://emacs.desktop")
'((fileurl
"http://www.semanticdesktop.org/ontologies/2007/03/22/nfo/#Document"
"http://www.semanticdesktop.org/ontologies/nfo/#FileDataObject"
fileurl
filemime
(file-name-sans-versions fileurl)
"")) ; Some black magic later
'(:array)))))
(defun zeitgeist-open-file ()
"Tell zeitgeist we openned a file!"
(if (eq nil (buffer-file-name))
(message "You are not on a file.")
(zeitgeist-send 'zeitgeist-open-event buffer-file-name "text/plain")))
(zeitgeist-open-file)
謝謝你的幫助! Patrick Niedzielski
我在郵件列表上問過,我發現自從我使用(引用...)而不是(list ...)以來,沒有評估變量和函數。 一個愚蠢的LISP錯誤。
此外,如果有人有興趣,我會將此補丁發送到Zeitgeist項目。
干杯,帕特里克
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.