[Top][All Lists]

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

todo-did.el complete rewrite

From: Emanuel Berg
Subject: todo-did.el complete rewrite
Date: Mon, 25 Mar 2019 06:12:22 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

Emacs/shell (here, zsh) interface to a TODO
buffer. Very useful and fast. (`todo-show-file'
ought to be bound to a key, e.g. I have it
`C-j t'.)

In the shell it is just

    $ todo sleep more, take less amphetamine

(Note the lack of apostrophes/quotes!) The next
time you do `C-j t' (or whatever you have it)
it'll be there - sorted, and saved.

Same if you do

    M-x todo RET fix all the bugs in todo-did.el RET

Ain't it cool stuff? :) Please comment!
The last couple of days I have posted tons of
code (of various degrees of advancedness, this
is probably the most advanced) - the last
couple of days I have posted tons of code and
not received a single comment :(
Very disappointing is my honest sensation.

PS. Check the date if you use the URL!
Might get a cached version otherwise. DS.


;; This file:
;; Updated: 25-03-2019 05:53
;; 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)) )
    (if todo-file
        (or (get-file-buffer    todo-file)
            (find-file-noselect todo-file) )
      (error "Set the env var %s first" todo-env-var) )))

(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)))
    (set-buffer todo-buffer)

    ;; this if if the file doesn't exist
    ;; but the env is set correctly

    ;; this is if the file
    ;; has changed from the shell
    (revert-buffer t t) ; IGNORE-AUTO NOCONFIRM

    (switch-to-buffer todo-buffer)

underground experts united

reply via email to

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