[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: todo-did.el complete rewrite

From: Emanuel Berg
Subject: Re: todo-did.el complete rewrite
Date: Wed, 27 Mar 2019 01:37:15 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

Stefan Monnier wrote:

>> (defun todo-show-file () [...]
> Have you considered using todo-mode or
> org-mode for the buffer into which you add
> those entries?

No, as wasn't aware of them (or, I was aware of
org-mode in general, but not that it had a todo
list). Anyway that function is no good. I have
made some changes:

;; This file:
;; Updated: 27-03-2019 01:34
;; zsh companion:
;; set the TODO_FILE env in:  ~/.zshenv
;; 'todo' command:
;;   ~/.zsh/todo

(defun todo-get-buffer ()
  (let*((todo-env-var "TODO_FILE")
        (todo-file     (getenv todo-env-var))
        (todo-buffer   (if todo-file (find-file-noselect todo-file t) ; NOWARN
                         (error "Set the env var %s first"
                                todo-env-var) )))
    (with-current-buffer todo-buffer
      (revert-buffer t t)) ; IGNORE-AUTO NOCONFIRM
    todo-buffer) )

(defun todo-sort-and-save ()
  (sort-lines nil ; not REVERSE
              (point-min) (point-max))
  (save-buffer) )

(defun todo (what)
  (interactive "sdo what: ")
  (let ((todo-buffer (todo-get-buffer)))
    (with-current-buffer todo-buffer
      (goto-char (point-max))
      (insert what)

(defun todo-show-file ()
  (let ((todo-buffer (todo-get-buffer)))
    (switch-to-buffer todo-buffer)

underground experts united

reply via email to

[Prev in Thread] Current Thread [Next in Thread]