Function: ghostel--handle-notification

ghostel--handle-notification is a natively compiled function defined in ghostel.el.

Signature

(ghostel--handle-notification TITLE BODY)

Documentation

Dispatch TITLE and BODY to ghostel-notification-function.

Called synchronously from the native VT parser; the user handler is invoked off the callpath via run-at-time so a slow backend
(DBus, osascript, etc.) can't stall terminal output. The
originating ghostel buffer is made current for the handler, so buffer-name etc. report the terminal buffer and not whatever was current when the timer happened to fire. Errors in the handler are caught and logged — an unhandled error in a timer callback does not crash the process filter, but it does produce a backtrace in batch runs.

Source Code

;; Defined in /nix/store/1252krff0gb2kisjcpp45m50cpdskfrl-emacs-packages-deps/share/emacs/site-lisp/ghostel.el
(defun ghostel--handle-notification (title body)
  "Dispatch TITLE and BODY to `ghostel-notification-function'.
Called synchronously from the native VT parser; the user handler
is invoked off the callpath via `run-at-time' so a slow backend
\(DBus, osascript, etc.) can't stall terminal output.  The
originating ghostel buffer is made current for the handler, so
`buffer-name' etc. report the terminal buffer and not whatever was
current when the timer happened to fire.  Errors in the handler
are caught and logged — an unhandled error in a timer callback
does not crash the process filter, but it does produce a backtrace
in batch runs."
  (when ghostel-notification-function
    (let ((buf (current-buffer))
          (fn ghostel-notification-function))
      (run-at-time
       0 nil
       (lambda ()
         (when (buffer-live-p buf)
           (with-current-buffer buf
             ;; Only `error' is caught here — `quit' (C-g) is allowed
             ;; to propagate so a user can interrupt a hung handler.
             ;; Emacs' timer machinery swallows a propagated quit.
             (condition-case err
                 (funcall fn title body)
               (error
                (message "ghostel: notification handler error: %s"
                         (error-message-string err)))))))))))