アットウィキロゴ
;; 2021-04-11
(defun k-markdown-copy-to-subtree-wiki ()
  "Narrow buffer to the current subtree."
  (interactive)
  (save-excursion
    (let ((=start)(=end))
      (markdown-outline-previous)
      (beginning-of-line)(setq =start (point))
      (end-of-line)(setq =end (point))
      (setq title (buffer-substring =start =end))
      (progn (markdown-back-to-heading-over-code-block t) (setq =start (point)))
      (message title)
      (progn (markdown-end-of-subtree)
             (if (and (markdown-heading-at-point) (not (eobp)))
                 (backward-char 1))
             (setq =end (point))
             (setq fname (file-name-nondirectory (buffer-file-name)))
             (string-match ".+_\\(.+\\)\\.md" fname)
             (setq fname (match-string 1 fname))
             ;;(copy-region-as-kill =start =end)
             ;; 指定した範囲のリージョンのテキストを変数に代入
             (setq title (replace-regexp-in-string "#" "*" title))
             (setq title (concat fname " #令和3年3月31日付告発状 " title))
             (setq fname (concat "TITLE:" title))
             (setq fname (concat fname "\n#contents\n----\n"))
             (setq text (buffer-substring-no-properties =start =end))
             (setq text (concat fname text))
             (setq text (replace-regexp-in-string "^#### " "**** " text))
             (setq text (replace-regexp-in-string "^### " "*** " text))
             (setq text (replace-regexp-in-string "^## " "** " text))
             (setq text (replace-regexp-in-string "^# " "* " text))
             (message title)
             ;; クリップボードに変数の内容を送る。
             (x-set-selection nil text)
 
最終更新:2021年04月12日 12:58