emacs: disable dbus and gvfs backends

This commit is contained in:
2026-05-06 14:59:52 -07:00
parent 32cb3944cc
commit e28cbee448
4 changed files with 148 additions and 9 deletions

View File

@@ -3649,9 +3649,8 @@ I don't use iedit directly, but it is used by [[*emr][emr]] and I need to disabl
:ensure nil
:commands tramp
:init
;; Avoid TRAMP's GVFS backend on sessions where org.gtk.vfs.Daemon is not
;; activatable. Buffer/recent-file completion can otherwise trigger noisy
;; DBus ServiceUnknown errors while inspecting TRAMP candidates.
;; Avoid TRAMP's GVFS backend entirely. It depends on D-Bus/GVFS desktop
;; services, while this config uses ordinary TRAMP methods.
(setq tramp-gvfs-methods nil)
:config
(setq tramp-default-method "scp")
@@ -3668,12 +3667,9 @@ I don't use iedit directly, but it is used by [[*emr][emr]] and I need to disabl
#+END_SRC
** dbus
#+BEGIN_SRC emacs-lisp
(with-eval-after-load 'dbus
;; This hook reports even handled DBus errors in the echo area. That is
;; usually noise in this config, especially during completion paths which may
;; probe optional desktop services.
(remove-hook 'dbus-event-error-functions
#'dbus-notice-synchronous-call-errors))
;; D-Bus is disabled by lisp/dbus.el, which shadows Emacs' built-in dbus.el.
;; Keep the event hook empty in case another environment loads the real library.
(setq dbus-event-error-functions nil)
#+END_SRC
** narrow-indirect
#+BEGIN_SRC emacs-lisp

View File

@@ -10,6 +10,15 @@
(defun emacs-directory-filepath (filename)
(expand-file-name filename user-emacs-directory))
(add-to-list 'load-path (emacs-directory-filepath "lisp"))
;; Treat this Emacs as if it was built without D-Bus. The local
;; lisp/dbus.el shim prevents `require' from loading the built-in dbus.el,
;; whose top-level form eagerly opens system and session bus connections.
(setq features (delq 'dbusbind features))
(setq dbus-compiled-version nil
dbus-runtime-version nil)
(load-file (expand-file-name "elpaca-installer.el" user-emacs-directory))
;; Elpaca's initial queue logger can fire during self-bootstrap before its

View File

@@ -0,0 +1,93 @@
;;; dbus.el --- Disabled D-Bus shim -*- lexical-binding: t; -*-
;;; Commentary:
;; This file intentionally shadows Emacs' built-in net/dbus.el. Loading the
;; built-in library initializes D-Bus connections at top level, which is noisy
;; and fragile in this configuration.
;;; Code:
(setq features (delq 'dbusbind features))
(setq dbus-compiled-version nil
dbus-runtime-version nil)
(unless (boundp 'dbus-error)
(define-error 'dbus-error "D-Bus disabled in this Emacs config"))
(defvar dbus-debug nil)
(defvar dbus-event-error-functions nil)
(defvar dbus-registered-objects-table (make-hash-table :test #'equal))
(defconst dbus-service-dbus "org.freedesktop.DBus")
(defconst dbus-path-dbus "/org/freedesktop/DBus")
(defconst dbus-path-local "/org/freedesktop/DBus/Local")
(defconst dbus-interface-dbus "org.freedesktop.DBus")
(defconst dbus-interface-peer "org.freedesktop.DBus.Peer")
(defconst dbus-interface-introspectable "org.freedesktop.DBus.Introspectable")
(defconst dbus-interface-properties "org.freedesktop.DBus.Properties")
(defconst dbus-interface-objectmanager "org.freedesktop.DBus.ObjectManager")
(defconst dbus-interface-monitoring "org.freedesktop.DBus.Monitoring")
(defconst dbus-interface-local "org.freedesktop.DBus.Local")
(defconst dbus-service-emacs "org.gnu.Emacs")
(defconst dbus-path-emacs "/org/gnu/Emacs")
(defconst dbus-interface-emacs "org.gnu.Emacs")
(defconst dbus-error-dbus "org.freedesktop.DBus.Error")
(defconst dbus-error-failed "org.freedesktop.DBus.Error.Failed")
(defconst dbus-error-service-unknown "org.freedesktop.DBus.Error.ServiceUnknown")
(defmacro dbus-ignore-errors (&rest body)
"Execute BODY, suppressing `dbus-error' unless `dbus-debug' is non-nil."
(declare (indent 0) (debug t))
`(condition-case err
(progn ,@body)
(dbus-error (when dbus-debug (signal (car err) (cdr err))))))
(defun imalison:dbus-disabled (&rest _args)
"Signal that D-Bus is intentionally unavailable in this config."
(signal 'dbus-error '("D-Bus disabled in this Emacs config")))
(dolist (function
'(dbus-call-method
dbus-call-method-asynchronously
dbus-send-signal
dbus-method-return-internal
dbus-method-error-internal
dbus-register-service
dbus-unregister-service
dbus-register-signal
dbus-register-method
dbus-unregister-object
dbus-register-property
dbus-register-monitor
dbus-init-bus
dbus-ping
dbus-introspect
dbus-introspect-xml
dbus-get-property
dbus-set-property
dbus-get-all-properties
dbus-get-all-managed-objects))
(defalias function #'imalison:dbus-disabled))
(defun dbus-list-activatable-names (&optional _bus) nil)
(defun dbus-list-names (&optional _bus) nil)
(defun dbus-list-known-names (&optional _bus) nil)
(defun dbus-list-queued-owners (&rest _args) nil)
(defun dbus-get-name-owner (&rest _args) nil)
(defun dbus-list-hash-table () nil)
(defun dbus-event-bus-name (_event) nil)
(defun dbus-event-message-type (_event) nil)
(defun dbus-event-serial-number (_event) nil)
(defun dbus-event-service-name (_event) nil)
(defun dbus-event-destination-name (_event) nil)
(defun dbus-event-path-name (_event) nil)
(defun dbus-event-interface-name (_event) nil)
(defun dbus-event-member-name (_event) nil)
(defun dbus-event-handler (_event) nil)
(defun dbus-event-arguments (_event) nil)
(provide 'dbus)
;;; dbus.el ends here

View File

@@ -0,0 +1,41 @@
;;; tramp-gvfs.el --- Disabled TRAMP GVFS backend -*- lexical-binding: t; -*-
;;; Commentary:
;; This file intentionally shadows Emacs' built-in net/tramp-gvfs.el. The real
;; backend depends on D-Bus and GVFS desktop services; this config uses ordinary
;; TRAMP methods instead.
;;; Code:
(require 'tramp)
(defconst tramp-gvfs-enabled nil
"Non-nil when the disabled GVFS backend is available.")
(defvar tramp-gvfs-methods nil
"Disabled list of TRAMP methods handled through GVFS.")
(setq tramp-gvfs-methods nil)
(defconst tramp-goa-methods nil
"Disabled list of GNOME Online Accounts TRAMP methods.")
(defvar tramp-media-methods nil
"Disabled list of media-device TRAMP methods.")
(setq tramp-media-methods nil)
(defvar tramp-gvfs-file-name-handler-alist nil
"Disabled GVFS file name handler alist.")
(defun tramp-gvfs-file-name-p (_filename)
"Return nil because the GVFS backend is disabled."
nil)
(defun tramp-gvfs-file-name-handler (operation &rest args)
"Signal an unsupported OPERATION for the disabled GVFS backend."
(signal 'file-error
(list "TRAMP GVFS backend disabled in this Emacs config"
operation args)))
(provide 'tramp-gvfs)
;;; tramp-gvfs.el ends here