-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathmajutsu-config.el
More file actions
56 lines (45 loc) · 1.76 KB
/
majutsu-config.el
File metadata and controls
56 lines (45 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
;;; majutsu-config.el --- Config management for Majutsu -*- lexical-binding: t; -*-
;; Copyright (C) 2025-2026 0WD0
;; Author: 0WD0 <wd.1105848296@gmail.com>
;; Maintainer: 0WD0 <wd.1105848296@gmail.com>
;; Keywords: tools, vc
;; URL: https://github.com/0WD0/majutsu
;; SPDX-License-Identifier: GPL-3.0-or-later
;;; Commentary:
;; Functions for reading and writing jj configuration values.
;;; Code:
(require 'majutsu-process)
(defun majutsu-get (key)
"Get config value for KEY from jj."
(let ((lines (majutsu-jj-lines "config" "get" key)))
(when lines
(string-trim (car lines)))))
(defun majutsu-set (key value &optional scope)
"Set config KEY to VALUE in SCOPE (user/repo/workspace).
SCOPE defaults to user."
(let ((args (list "config" "set"
(pcase scope
('repo "--repo")
('workspace "--workspace")
(_ "--user"))
key value)))
(majutsu-run-jj args)))
(defun majutsu-list (&optional prefix scope)
"List config variables matching PREFIX in SCOPE.
Returns alist of (name . value) pairs."
(let* ((args (append '("config" "list")
(when scope
(list (pcase scope
('repo "--repo")
('workspace "--workspace")
('user "--user"))))
(when prefix (list prefix))))
(lines (majutsu-jj-lines args)))
(when lines
(mapcar (lambda (line)
(when (string-match "^\\([^=]+\\)=\"?\\(.*?\\)\"?$" line)
(cons (match-string 1 line)
(match-string 2 line))))
lines))))
(provide 'majutsu-config)
;;; majutsu-config.el ends here