diff options
| -rw-r--r-- | lisp/net/dbus.el | 66 |
1 files changed, 59 insertions, 7 deletions
diff --git a/lisp/net/dbus.el b/lisp/net/dbus.el index b1bea55d982..fec9d3c7ab8 100644 --- a/lisp/net/dbus.el +++ b/lisp/net/dbus.el | |||
| @@ -2036,6 +2036,28 @@ either a method name, a signal name, or an error name." | |||
| 2036 | ;; Return the object. | 2036 | ;; Return the object. |
| 2037 | (list key key1))) | 2037 | (list key key1))) |
| 2038 | 2038 | ||
| 2039 | (defconst dbus-monitor-method-call | ||
| 2040 | (propertize "method-call" 'face 'font-lock-function-name-face) | ||
| 2041 | "Text to be inserted for D-Bus method-call in monitor.") | ||
| 2042 | |||
| 2043 | (defconst dbus-monitor-method-return | ||
| 2044 | (propertize "method-return" 'face 'font-lock-function-name-face) | ||
| 2045 | "Text to be inserted for D-Bus method-return in monitor.") | ||
| 2046 | |||
| 2047 | (defconst dbus-monitor-error (propertize "error" 'face 'font-lock-warning-face) | ||
| 2048 | "Text to be inserted for D-Bus error in monitor.") | ||
| 2049 | |||
| 2050 | (defconst dbus-monitor-signal | ||
| 2051 | (propertize "signal" 'face 'font-lock-type-face) | ||
| 2052 | "Text to be inserted for D-Bus signal in monitor.") | ||
| 2053 | |||
| 2054 | (defun dbus-monitor-goto-serial () | ||
| 2055 | "Goto D-Bus message with the same serial number." | ||
| 2056 | (interactive) | ||
| 2057 | (when (mouse-event-p last-input-event) (mouse-set-point last-input-event)) | ||
| 2058 | (when-let ((point (get-text-property (point) 'dbus-serial))) | ||
| 2059 | (goto-char point))) | ||
| 2060 | |||
| 2039 | (defun dbus-monitor-handler (&rest _args) | 2061 | (defun dbus-monitor-handler (&rest _args) |
| 2040 | "Default handler for the \"org.freedesktop.DBus.Monitoring.BecomeMonitor\" interface. | 2062 | "Default handler for the \"org.freedesktop.DBus.Monitoring.BecomeMonitor\" interface. |
| 2041 | It will be applied for all objects created by | 2063 | It will be applied for all objects created by |
| @@ -2045,6 +2067,9 @@ It will be applied for all objects created by | |||
| 2045 | ;; Move forward and backward between messages. | 2067 | ;; Move forward and backward between messages. |
| 2046 | (local-set-key [?n] #'forward-paragraph) | 2068 | (local-set-key [?n] #'forward-paragraph) |
| 2047 | (local-set-key [?p] #'backward-paragraph) | 2069 | (local-set-key [?p] #'backward-paragraph) |
| 2070 | ;; Follow serial links. | ||
| 2071 | (local-set-key (kbd "RET") #'dbus-monitor-goto-serial) | ||
| 2072 | (local-set-key [mouse-2] #'dbus-monitor-goto-serial) | ||
| 2048 | (let* ((inhibit-read-only t) | 2073 | (let* ((inhibit-read-only t) |
| 2049 | (point (point)) | 2074 | (point (point)) |
| 2050 | (eobp (eobp)) | 2075 | (eobp (eobp)) |
| @@ -2056,20 +2081,47 @@ It will be applied for all objects created by | |||
| 2056 | (path (dbus-event-path-name event)) | 2081 | (path (dbus-event-path-name event)) |
| 2057 | (interface (dbus-event-interface-name event)) | 2082 | (interface (dbus-event-interface-name event)) |
| 2058 | (member (dbus-event-member-name event)) | 2083 | (member (dbus-event-member-name event)) |
| 2059 | (arguments (dbus-event-arguments event))) | 2084 | (arguments (dbus-event-arguments event)) |
| 2085 | (time (time-to-seconds (current-time)))) | ||
| 2060 | (save-excursion | 2086 | (save-excursion |
| 2087 | ;; Check for matching method-call. | ||
| 2088 | (goto-char (point-max)) | ||
| 2089 | (when (and (or (= type dbus-message-type-method-return) | ||
| 2090 | (= type dbus-message-type-error)) | ||
| 2091 | (re-search-backward | ||
| 2092 | (format | ||
| 2093 | (concat | ||
| 2094 | "^method-call time=\\(\\S-+\\) " | ||
| 2095 | ".*sender=%s .*serial=\\(%d\\) ") | ||
| 2096 | destination serial) | ||
| 2097 | nil 'noerror)) | ||
| 2098 | (setq serial | ||
| 2099 | (propertize | ||
| 2100 | (match-string 2) 'dbus-serial (match-beginning 0) | ||
| 2101 | 'help-echo "RET, mouse-1, mouse-2: goto method-call" | ||
| 2102 | 'face 'link 'follow-link 'mouse-face 'mouse-face 'highlight) | ||
| 2103 | time (format "%f (%f)" time (- time (read (match-string 1))))) | ||
| 2104 | (set-text-properties | ||
| 2105 | (match-beginning 2) (match-end 2) | ||
| 2106 | `(dbus-serial ,(point-max) | ||
| 2107 | help-echo | ||
| 2108 | ,(format | ||
| 2109 | "RET, mouse-1, mouse-2: goto %s" | ||
| 2110 | (if (= type dbus-message-type-error) "error" "method-return")) | ||
| 2111 | face link follow-link mouse-face mouse-face highlight))) | ||
| 2112 | ;; Insert D-Bus message. | ||
| 2061 | (goto-char (point-max)) | 2113 | (goto-char (point-max)) |
| 2062 | (insert | 2114 | (insert |
| 2063 | (format | 2115 | (format |
| 2064 | (concat | 2116 | (concat |
| 2065 | "%s sender=%s -> destination=%s serial=%s " | 2117 | "%s time=%s sender=%s -> destination=%s serial=%s " |
| 2066 | "path=%s interface=%s member=%s\n") | 2118 | "path=%s interface=%s member=%s\n") |
| 2067 | (cond | 2119 | (cond |
| 2068 | ((= type dbus-message-type-method-call) "method-call") | 2120 | ((= type dbus-message-type-method-call) dbus-monitor-method-call) |
| 2069 | ((= type dbus-message-type-method-return) "method-return") | 2121 | ((= type dbus-message-type-method-return) dbus-monitor-method-return) |
| 2070 | ((= type dbus-message-type-error) "error") | 2122 | ((= type dbus-message-type-error) dbus-monitor-error) |
| 2071 | ((= type dbus-message-type-signal) "signal")) | 2123 | ((= type dbus-message-type-signal) dbus-monitor-signal)) |
| 2072 | sender destination serial path interface member)) | 2124 | time sender destination serial path interface member)) |
| 2073 | (dolist (arg arguments) | 2125 | (dolist (arg arguments) |
| 2074 | (pp (dbus-flatten-types arg) (current-buffer))) | 2126 | (pp (dbus-flatten-types arg) (current-buffer))) |
| 2075 | (insert "\n") | 2127 | (insert "\n") |