[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/nix-mode e167b82e64 493/500: nix-flake: Fix inconsistent s
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/nix-mode e167b82e64 493/500: nix-flake: Fix inconsistent state after switching the flake |
Date: |
Sat, 29 Jan 2022 08:27:59 -0500 (EST) |
branch: elpa/nix-mode
commit e167b82e64ce794ff9e08f76625a879164dcf0cd
Author: Akira Komamura <akira.komamura@gmail.com>
Commit: Akira Komamura <akira.komamura@gmail.com>
nix-flake: Fix inconsistent state after switching the flake
The transient and the relevant variables must be updated after
switching the flake.
---
nix-flake.el | 37 ++++++++++++++++++++++++-------------
1 file changed, 24 insertions(+), 13 deletions(-)
diff --git a/nix-flake.el b/nix-flake.el
index fbd99084cb..b759a513c7 100644
--- a/nix-flake.el
+++ b/nix-flake.el
@@ -45,14 +45,12 @@ already registered in either the user or the global
registry."
;;;;; flake-ref
(defclass nix-flake-ref-variable (transient-variable)
- ((variable :initarg :variable)
- (constant-value :initarg :constant-value :initform nil)
+ ((constant-value :initarg :constant-value :initform nil)
+ (on-change :initarg :on-change)
(reader :initarg :reader :initform nil)))
-(cl-defmethod transient-init-value ((obj nix-flake-ref-variable))
- "Set the initial value of the object OBJ."
- (unless (oref obj value)
- (oset obj value (eval (oref obj variable)))))
+(cl-defmethod transient-init-value ((_obj nix-flake-ref-variable))
+ "Set the initial value of the object.")
(cl-defmethod transient-infix-read ((obj nix-flake-ref-variable))
"Determine the new value of the infix object OBJ."
@@ -67,7 +65,8 @@ already registered in either the user or the global registry."
(cl-defmethod transient-infix-set ((obj nix-flake-ref-variable) value)
"Set the value of infix object OBJ to VALUE."
(oset obj value value)
- (set (oref obj variable) value))
+ (when-let (func (oref obj on-change))
+ (funcall func value)))
(cl-defmethod transient-format-value ((_obj nix-flake-ref-variable))
"Format the object's value for display and return the result."
@@ -143,13 +142,19 @@ readers in transient.el."
;;;;; Setting the flake
(transient-define-infix nix-flake:from-registry ()
:class 'nix-flake-ref-variable
- :variable 'nix-flake-ref
+ :on-change
+ (lambda (flake-ref)
+ (nix-flake--set-flake flake-ref :remote t)
+ (transient-update))
:description "Select a flake from the registry")
(transient-define-infix nix-flake:flake-directory ()
:class 'nix-flake-ref-variable
- :variable 'nix-flake-ref
:reader 'nix-flake--read-directory
+ :on-change
+ (lambda (flake-ref)
+ (nix-flake--set-flake flake-ref)
+ (transient-update))
:description "Select a directory")
(defun nix-flake--read-directory (prompt &optional initial-input _history)
@@ -388,13 +393,19 @@ For OPTIONS and FLAKE-REF, see the documentation of
("l" "flake lock" nix-flake-lock)
("u" "flake update" nix-flake-update)]
(interactive (list (convert-standard-filename default-directory)))
+ (nix-flake--set-flake flake-ref :remote remote)
+ (transient-setup 'nix-flake-dispatch))
+
+(cl-defun nix-flake--set-flake (flake-ref &key remote)
+ "Set the flake of the transient interface.
+
+FLAKE-REF and REMOTE should be passed down from `nix-flake-dispatch'."
(setq nix-flake-ref flake-ref)
(setq nix-flake-outputs
(if remote
- (nix--process-json "flake" "show" "--json" nix-flake-ref)
- (let ((default-directory flake-ref))
- (nix--process-json "flake" "show" "--json"))))
- (transient-setup 'nix-flake-dispatch))
+ (nix--process-json "flake" "show" "--json" nix-flake-ref)
+ (let ((default-directory flake-ref))
+ (nix--process-json "flake" "show" "--json")))))
(defun nix-flake--description ()
"Describe the current flake."
- [nongnu] elpa/nix-mode 7e081a560b 427/500: nix-drv-mode.el: make regexp more selective, (continued)
- [nongnu] elpa/nix-mode 7e081a560b 427/500: nix-drv-mode.el: make regexp more selective, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 91e1a05ea6 399/500: Merge pull request #107 from rossabaker/check-for-proc, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode b4b7518231 441/500: Refactor process calling, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 75d2111891 433/500: Merge pull request #129 from nagy/nix-search-separate, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 949cb98ba5 432/500: Set meta.description, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode a8a513770a 436/500: Simplify some functions, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 7f689c4161 450/500: In flake.nix, split name into pname and version, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode b12fa70dd7 446/500: Indicate constants, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 53d1fb9687 469/500: nix-flake: Add nix-flake-init, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 1604a9cec8 484/500: nix-flake: Allow updating the lockfile, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode e167b82e64 493/500: nix-flake: Fix inconsistent state after switching the flake,
ELPA Syncer <=
- [nongnu] elpa/nix-mode 3d04d92d9c 496/500: Merge pull request #144 from akirak/update-cask-on-flake, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode cf957244e7 499/500: Merge pull request #149 from akirak/transient-dep, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 9ee2a867e6 481/500: nix-flake: Follow the terminology and syntax of the guideline, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode b97d0a0aae 488/500: Merge pull request #141 from akirak/dependabot, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 83980ca7e7 498/500: nix-mode: Add missing transient dependency for nix-flake, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode ef2efae30a 482/500: nix-flake: Use flatten-list and bump Emacs to 27.1, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode c4e4f386b7 490/500: chore: Add nix-flake.el to Cask, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 10fc00dba8 015/500: Fix bad setting for indent-tabs-mode., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 630cc427cd 009/500: Update builtins, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 295bcbd919 023/500: Don't indent strings, comments, ELPA Syncer, 2022/01/29