今日やったこと
Emacs
org-modeにledgerを導入した。ledgerはテキストベースで複式帳簿を扱えるCLIツール。
Emacsでの連携方法は2種類ある。
1つめは普通にledgerファイルを読み書きする方法。
公式からledger-modeというプラグインが提供されているのでそれを使う。
2つめはorg-modeを使う方法。
org-modeは標準でledgerをサポートしているのでこんな感じで書けばorg-babelで実行できる。
gptelにコンテキストを加える関数が良い感じになった。
llm.txtとかはmarkitdownにかける必要がないからmarkitdownにかける関数とかけない関数に分離した。
(defun markitdown (html)
(let ((proc (make-process
:name "markitdown"
:buffer (get-buffer-create "*markitdown*")
:command '("markitdown")
:connection-type 'pipe)))
;; Erase buffer contents
(with-current-buffer (get-buffer "*markitdown*")
(erase-buffer))
(process-send-string proc html)
(process-send-eof proc)))
(defun gptel-add-website (url)
(interactive "s" "website? > ")
(require 'request)
(request url
:success (cl-function
(lambda (&key data &allow-other-keys)
;; Convert HTML to markdown
(markitdown data)
;; Append to context for gptel
(with-current-buffer (get-buffer "*markitdown*")
(gptel-context--add-region (get-buffer "*markitdown*")
(point-max)
(point-min)))))))
(defun gptel-add-url (url)
(interactive "s" "url? > ")
(require 'request)
(request url
:parser 'buffer-string
:success (cl-function
(lambda (&key data &allow-other-keys)
(when data
(with-current-buffer (get-buffer-create "*request*")
(insert data)
(gptel-context--add-region (get-buffer "*request*")
(point-min)
(point-max))))))))
明日以降やりたいこと
Emacsのスニペットまわりが気になるので手を加えていきたい。