;;; -*- lexical-binding: t -*- ;; ;; this file: ;; https://dataswamp.org/~incal/emacs-init/todo-did.el (defun todo-get-buffer () (find-file-noselect "~/TODO" t) ) (defun todo-sort-and-save () (sort-lines nil (point-min) (point-max)) (whitespace-cleanup) (save-buffer) ) (defun todo-insert-entry (entry buffer) (with-current-buffer buffer (goto-char (point-max)) (insert "\n" entry) (todo-sort-and-save) )) (defun todo (what) (interactive "sdo what: ") (todo-insert-entry what (todo-get-buffer)) ) (defun todo-show-file () (interactive) (let ((todo-buffer (todo-get-buffer))) (with-current-buffer todo-buffer (when (buffer-modified-p todo-buffer) (todo-sort-and-save) ) (switch-to-buffer todo-buffer) ))) (provide 'todo-did)