From 40929155bff9276a8edf3dbe3fd0bb473f7a7b65 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Sun, 3 Mar 2024 02:02:05 +0200 Subject: gnosis-edit-save-exit: Refactor Add function as argument to be used as exit func. This will make it easier to reuse with other funcs --- gnosis.el | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/gnosis.el b/gnosis.el index 6220d10..eecde0a 100644 --- a/gnosis.el +++ b/gnosis.el @@ -1217,15 +1217,16 @@ changes." ":tags" ":extra-notes" ":image" ":second-image" ":ef" ":ff" ":suspend")) -(defun gnosis-edit-save-exit () - "Save edits and exit." +(cl-defun gnosis-edit-save-exit (&optional deck-edit (exit-func 'exit-recursive-edit) &rest args) + "Save edits and exit. + +If not DECK-EDIT and not in a recursive-edit, pop back +gnosis-dashboard." (interactive) - (eval-buffer) - (quit-window t) - ;; exit recursive edit if we are in one - (if (>= (recursion-depth) 1) - (exit-recursive-edit) - (gnosis-dashboard))) + (let ((deck-edit (or deck-edit nil))) + (eval-buffer) + (quit-window t) + (apply exit-func args))) (defvar-keymap gnosis-edit-mode-map :doc "gnosis-edit keymap" -- cgit v1.2.3