~goofansu/doom-config

5a14c0f7e2896cf86046d37b210ea8fdce25140e — Yejun Su 5 months ago afb2568
update section for nix advice
1 files changed, 26 insertions(+), 27 deletions(-)

M config.org
M config.org => config.org +26 -27
@@ 387,6 387,32 @@ https://gitlab.com/oer/org-re-reveal
  (org-babel-do-load-languages 'org-babel-load-languages org-babel-load-languages))
#+end_src

*** Run Nix org-babel source block in Kitty's nix-repl tab
#+begin_src emacs-lisp
(defun kitty--ensure-nix-repl-tab ()
  (unless (zerop (shell-command "kitty @ ls | grep -q '\"title\": \"nix-repl\"'"))
    (shell-command "kitty @ launch --type tab --tab-title nix-repl nix repl")))

(defun kitty--send-region-to-nix-repl-tab ()
  (shell-command-on-region
   (if (use-region-p) (region-beginning) (point-min))
   (if (use-region-p) (region-end) (point-max))
   "kitty @ send-text --match-tab title:nix-repl --stdin"))

(defun org-babel-src-block-language-p (language)
  (let ((block-info (org-element-at-point)))
    (and (eq (car block-info) 'src-block)
         (string= language (org-element-property :language block-info)))))

(defadvice +eval/send-region-to-repl (around my-send-region-to-repl activate)
  (if (and (eq major-mode 'org-mode)
           (org-babel-src-block-language-p "nix"))
      (progn
        (kitty--ensure-nix-repl-tab)
        (kitty--send-region-to-nix-repl-tab))
    ad-do-it))
#+end_src

** Web
#+begin_src emacs-lisp
(use-package! web-mode


@@ 727,33 753,6 @@ I'm building my own Emacs configuration [[https://github.com/goofansu/.emacs.d][
      :desc "Browse blog" "nA" #'yejun/browse-blog)
#+end_src

* Advices
** Run Nix org-babel source block in Kitty's nix-repl tab
#+begin_src emacs-lisp
(defun kitty--ensure-nix-repl-tab ()
  (unless (zerop (shell-command "kitty @ ls | grep -q '\"title\": \"nix-repl\"'"))
    (shell-command "kitty @ launch --type tab --tab-title nix-repl nix repl")))

(defun kitty--send-region-to-nix-repl-tab ()
  (shell-command-on-region
   (if (use-region-p) (region-beginning) (point-min))
   (if (use-region-p) (region-end) (point-max))
   "kitty @ send-text --match-tab title:nix-repl --stdin"))

(defun org-babel-src-block-language-p (language)
  (let ((block-info (org-element-at-point)))
    (and (eq (car block-info) 'src-block)
         (string= language (org-element-property :language block-info)))))

(defadvice +eval/send-region-to-repl (around my-send-region-to-repl activate)
  (if (and (eq major-mode 'org-mode)
           (org-babel-src-block-language-p "nix"))
      (progn
        (kitty--ensure-nix-repl-tab)
        (kitty--send-region-to-nix-repl-tab))
    ad-do-it))
#+end_src

* Customize
** Use Kagi for +lookup/online
#+begin_src emacs-lisp