commit 0be884003fea3139157ef11603717abc02572c28 Author: MitchMarq42 Date: Sat Jan 20 08:26:34 2024 -0900 add all files back. i broke this repo whoops diff --git a/README.org b/README.org new file mode 100644 index 0000000..94baa7d --- /dev/null +++ b/README.org @@ -0,0 +1,48 @@ +* Pitch: +In essence, this Emacs mode simply loads the data from dconf into ini files, +then applies them after each write to disk. It further provides the variable +=dconf--default-path= to allow more general or specific configuration, as +needed. + +The main benefit of using something like this is that your GNOME (or whatever +else) settings are no longer a nebulous binary hive; they are declarative +human-readable text files. They can be version-controlled and distributed +alongside your other dotfiles. They can be viewed in other editors and +environments. They can be =grep='d through. + +* Installlation: +With straight.el and use-package: +#+begin_src elisp +(use-package dconf-mode + :straight + (:type git + :repo "https://git.mitchmarq42.xyz/mitch/dconf-mode.el")) +#+end_src + +* Usage: +I personally use this to manage my GNOME configuration like so: + +#+begin_example +~/.config/gnome-custom-configs +├── desktop.gsets +├── settings-daemon.gsets +├── shell.gsets +└── terminal.gsets +#+end_example + +Thus, editing `desktop.gsets' modifies the hive =/org/gnome/desktop/=. + +* TODO +** have an option to use a temp buffer +** test +- working with nonexistent files +- older/newer emacs versions + - lexical binding? + +* In other editors +To achieve something similar in vim/nvim: +#+begin_src vimscript +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/ +#+end_src diff --git a/dconf-mode.el b/dconf-mode.el new file mode 100644 index 0000000..28a9157 --- /dev/null +++ b/dconf-mode.el @@ -0,0 +1,72 @@ +;;; dconf-mode.el --- Edit dconf settings in an emacs buffer + +;; Author: Mitchell Marquez +;; URL: https://git.mitchmarq42.xyz/mitch/dconf-mode.el +;; Version: 0.1 +;; Keywords: convenience + +;;; Copyright © 2022 Mitchell Marquez +;;; +;;; +;;; This file is NOT part of GNU Emacs. +;;; +;;; This program is free software: you can redistribute it and/or modify +;;; it under the terms of the GNU General Public License as published by +;;; the Free Software Foundation, either version 3 of the License, or +;;; (at your option) any later version. +;;; +;;; This program is distributed in the hope that it will be useful, +;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with this program. If not, see . + +;;; Commentary: + +;; dconf-mode is a lightweight major mode for editing dconf databases such as +;; the settings of the GNOME desktop environment from the comfort of Emacs, and +;; saving its configuration in simple text files. + + +;;; Code: + +(defcustom dconf--default-path "/org/gnome/" + "The default path for dconf-mode to read and write from." + :group 'dconf-mode + :type 'string) + +(defun dconf-load-current-file () + "Load the current file into dconf's live registry." + (interactive) + (shell-command + (concat "cat " buffer-file-name + " | dconf load " dconf--default-path (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 " dconf--default-path (file-name-base buffer-file-name) "/") + (current-buffer))) + +(defun dconf-edit (path) + "Open a dconf buffer to edit PATH." + (interactive "M") + (pop-to-buffer (get-buffer-create (format "*dconf %s*" path))) + (setq-local dconf-current-path path) + (dconf-mode)) + +;;;###autoload +(define-derived-mode dconf-mode conf-mode "Dconf" + "Major mode for interacting with the dconf database." + :group 'dconf-mode + ;; :after-hook (dconf-dump-current-file) + (add-hook 'after-save-hook 'dconf-load-current-file 0 t)) + +;;;###autoload +(add-to-list 'auto-mode-alist '("\\.gsets" . dconf-mode)) + +(provide 'dconf-mode) +;;; dconf-mode.el ends here