首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >dbus方法中的错误类型错误(GNU Emacs)

dbus方法中的错误类型错误(GNU Emacs)
EN

Stack Overflow用户
提问于 2010-07-01 19:05:25
回答 1查看 338关注 0票数 4

我正在编写一个elisp文件,以便在dbus上集成GNU和时代精神。由于emacs中缺乏关于dbus的良好文档,以及缺乏高级elisp方面的经验,我的方法zeitgeist-send出现了以下错误

错误类型参数: D-Bus,(时代精神-事件-时间戳)

我试图纠正这个问题,将:string放在所有论点之前,但这给了我一个错误:

错误类型的参数:字符串,(时代精神-事件-时间戳)

这是没有意义的,因为我确信(zeitgeist-事件-时间戳)的值是一个字符串。

如果需要,时代论的dbus文档是这里。它的格式是asaasay

以下是代码:

代码语言:javascript
复制
(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)

谢谢你的帮助!帕特里克·尼德齐斯基

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2010-07-02 20:15:18

我问了邮件列表,我发现因为我使用(引号.)而不是(列表.),没有计算变量和函数。一个愚蠢的口齿错误。

另外,如果有人感兴趣,我会把这个补丁发送到时代精神项目。

干杯,帕特里克

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3160874

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档