emacs/lisp/dconf-mode.el

44 lines
1.3 KiB
EmacsLisp
Raw Normal View History

2022-06-19 16:32:08 -08:00
;;; dconf-mode.el --- Edit dconf settings in an emacs buffer
;;;###autoload
(add-to-list 'auto-mode-alist '("\\.gsets" . dconf-mode))
2022-06-19 15:26:59 -08:00
;;; Commentary:
2022-06-19 16:32:08 -08:00
2022-06-19 15:26:59 -08:00
;; I haven't completely given up on GNOME. This is a little wrapper I've ported
;; from my vim config to modify and save the running GNOME state to files.
;; The relevant vim settings:
;; autocmd BufReadPre *.gsets silent !dconf dump /org/gnome/%:t:r/ > %
;; autocmd BufReadPost *.gsets set ft=dosini
;; autocmd BufWritePost *.gsets silent !cat % | dconf load /org/gnome/%:t:r/
;;; Code:
(defun dconf-load-current-file ()
"Load the current file into dconf's live registry."
(interactive)
(shell-command
(concat "cat " buffer-file-name
2022-06-19 16:32:08 -08:00
" | dconf load /org/gnome/" (file-name-base buffer-file-name) "/")))
(defun dconf-dump-current-file ()
"Load dconf's live registry into the current file."
(interactive)
(erase-buffer)
(shell-command
(concat "dconf dump /org/gnome/" (file-name-base buffer-file-name) "/")
(current-buffer)))
2022-06-19 15:26:59 -08:00
(if (string-match "*.gsets" buffer-file-name)
(progn
2022-06-19 16:32:08 -08:00
;; (add-hook) ;BufReadPre
2022-06-19 15:26:59 -08:00
(conf-windows-mode) ;BufReadPost might be default
)
)
2022-06-19 16:32:08 -08:00
(define-derived-mode dconf-mode conf-mode "Dconf"
(add-hook after-save-hook
#'dconf-load-current-file)
)
(provide 'dconf-mode)
;;; dconf-mode.el ends here