Move that to a separate file

This commit is contained in:
Benson Chu 2025-08-10 13:40:50 -05:00 committed by Benson Chu
parent 0b4cac4c54
commit 676e534596
3 changed files with 54 additions and 14 deletions

View file

@ -0,0 +1,49 @@
;;; my-org-edit-special.el --- -*- lexical-binding: t -*-
;; Copyright (C) 2025 Benson Chu
;; Author: Benson Chu <bensonchu457@gmail.com>
;; Created: [2025-08-10 13:28]
;; This file is not part of GNU Emacs
;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;;; Code:
(defun my/org-edit-src-exit ()
(interactive)
(save-window-excursion
(call-interactively #'org-edit-src-exit)))
(defvar-keymap org-capture-self-chat-keymap
:parent org-src-mode-map
"C-c C-c" #'my/org-edit-src-exit
"C-c C-'" #'my/org-edit-src-exit
"C-c C-k" #'(lambda ()
(interactive)
(call-interactively #'org-edit-src-abort)
(call-interactively #'org-cut-special)
(call-interactively #'delete-window)))
(defun my/org-edit-special ()
(interactive)
(call-interactively #'org-edit-special)
(setq-local minor-mode-overriding-map-alist
`((org-src-mode . ,org-capture-self-chat-keymap))))
(provide 'my-org-edit-special)
;;; my-org-edit-special.el ends here

View file

@ -129,11 +129,6 @@
(setq org-html-table-default-attributes
'(:border "2" :cellspacing "0" :cellpadding "6")))
(when (eq window-system 'x)
(define-key org-mode-map
(kbd "C-S-b")
#'(lambda () (interactive) (org-back-to-heading))))
(define-key org-mode-map (kbd "M-g o") (lambda () (interactive) (org-back-to-heading)))
(define-key org-mode-map (kbd "C-M-a") (lambda () (interactive) (org-back-to-heading)))
@ -258,5 +253,8 @@
(my/org-agenda-save)
(close-tab-switch))
(require 'my-org-edit-special)
(define-key org-mode-map (kbd "C-c \"") #'my/org-edit-special)
(provide 'my-org-misc)
;;; my-org-misc.el ends here

View file

@ -70,20 +70,13 @@
(org-roam-setup)
(setq org-roam-dailies-directory "daily/")
(defvar-keymap org-capture-self-chat-keymap
"C-c C-k" #'(lambda ()
(interactive)
(call-interactively #'org-edit-src-abort)
(call-interactively #'org-cut-special)
(call-interactively #'delete-window)))
(require 'my-org-edit-special)
(defun self-chat-capture-template-display-src ()
(with-current-buffer (org-capture-get :buffer)
(goto-char (org-capture-get :insertion-point))
(let ((src-buffer (save-window-excursion
(org-edit-special)
(setq-local minor-mode-overriding-map-alist
`((org-src-mode . ,org-capture-self-chat-keymap)))
(my/org-edit-special)
(current-buffer)
)))
(org-display-buffer-split src-buffer nil))))