diff options
| -rw-r--r-- | modules/org-babel-config.el | 14 | ||||
| -rw-r--r-- | tests/test-org-babel-config.el | 12 |
2 files changed, 21 insertions, 5 deletions
diff --git a/modules/org-babel-config.el b/modules/org-babel-config.el index bc7ccb80..79661013 100644 --- a/modules/org-babel-config.el +++ b/modules/org-babel-config.el @@ -35,7 +35,7 @@ ;; The block stays a src block (the cj: grep marker is unchanged); org markup ;; is highlighted and editable, though links are followed from the C-c ' buffer. (add-to-list 'org-src-lang-modes '("cj:" . org)) - (setq org-confirm-babel-evaluate t) ;; confirm before running babel; toggle with C-; k + (setq org-confirm-babel-evaluate t) ;; confirm before running babel; toggle with C-; O b (setq org-babel-default-header-args (cons '(:tangle . "yes") (assq-delete-all :tangle org-babel-default-header-args)))) ;; default header args for babel @@ -54,7 +54,17 @@ session when working in trusted files, and back on when done." (message "Babel evaluation confirmation %s" (if org-confirm-babel-evaluate "ON" "OFF"))) -(keymap-global-set "C-; k" #'cj/org-babel-toggle-confirm) +;; Bound on the org menu (C-; O) rather than the global C-; map — the toggle +;; is an org-babel concern. cj/org-map is defined in org-config, which init +;; loads before this module; the after-load guard keeps a standalone load of +;; this module from erroring when org-config is absent. +(defvar cj/org-map) +(with-eval-after-load 'org-config + (keymap-set cj/org-map "b" #'cj/org-babel-toggle-confirm)) + +(with-eval-after-load 'which-key + (which-key-add-key-based-replacements + "C-; O b" "toggle babel confirm")) ;; ---------------------------- Org Babel Languages ---------------------------- diff --git a/tests/test-org-babel-config.el b/tests/test-org-babel-config.el index b62a9422..15eb44c4 100644 --- a/tests/test-org-babel-config.el +++ b/tests/test-org-babel-config.el @@ -3,11 +3,12 @@ ;;; Commentary: ;; Covers cj/org-babel-toggle-confirm, which flips `org-confirm-babel-evaluate' ;; between t (the safe default — confirm before running a block) and nil, and -;; the C-; k binding that invokes it. +;; the C-; O b binding (on `cj/org-map') that invokes it. ;;; Code: (require 'ert) +(require 'org-config) ;; provides cj/org-map, where the toggle is bound (require 'org-babel-config) ;; org defines this as a defcustom, but org is not loaded in batch; declare it @@ -27,9 +28,14 @@ (should (eq t org-confirm-babel-evaluate)))) (ert-deftest test-org-babel-toggle-confirm-bound-to-key () - "Smoke: C-; k invokes the toggle command." - (should (eq (keymap-lookup (current-global-map) "C-; k") + "Smoke: C-; O b (org menu) invokes the toggle command." + (should (eq (keymap-lookup cj/org-map "b") #'cj/org-babel-toggle-confirm))) +(ert-deftest test-org-babel-toggle-confirm-old-binding-freed () + "Boundary: the old C-; k global binding is gone." + (should-not (eq (keymap-lookup (current-global-map) "C-; k") + #'cj/org-babel-toggle-confirm))) + (provide 'test-org-babel-config) ;;; test-org-babel-config.el ends here |
