UP | HOME

emacs-将daily笔记以逆序datetree方式refile到另一个窗口

[2024-04-07 周日 10:12]

将daily笔记以逆序datetree方式refile到另一个窗口

在左右并排的两个window间,会根据本buffer的title,将指定的headline refile到另一个窗口,并按reverse-datetree排列

(use-package org-reverse-datetree)
(setq-default org-reverse-datetree-level-formats
              '("%Y"                    ; year
                "%Y-%m %B"
                "%Y-%m-%d %A"           ; date
                ))
(defun org-get-next-window-file ()
  (if (delq (selected-window) (window-list-1 (next-window nil 'nomini 'visible)))
      (let ((buffer2 (window-buffer (next-window nil 'nomini 'visible))))
        (with-current-buffer buffer2
          (when (eq major-mode 'org-mode)
            (buffer-file-name buffer2))))))
(defun org-get-current-window-title ()
  (with-current-buffer (window-buffer)
        (pcase (org-collect-keywords '("TITLE"))
          (`(("TITLE" . ,val))
           (setq title (car val))))))
(defun org-refile-to-other-window (arg)
  (interactive "P")
  (if (org-get-next-window-file)
      (org-reverse-datetree-refile-to-file (org-get-next-window-file) (date-to-time (org-get-current-window-title)))
        ))

▲ 编辑于 [2024-05-22 周三 21:58] | © Published by Emacs 31.0.50 (Org mode 9.7.16) on [2024-11-21 周四 00:22] | RSS