unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Thien-Thi Nguyen <ttn@surf.glug.org>
Cc: guile-user@gnu.org
Subject: todo
Date: Tue, 09 Sep 2003 16:15:12 +0200	[thread overview]
Message-ID: <E19wjGy-0006yv-00@surf.glug.org> (raw)

nothing a few lines of shell script couldn't replace...  on the other
hand, Some Day we will be able to boot into scheme like the PLT folks...

thi

______________________________________
#!/bin/sh
exec guile -s $0 "$@"
!#
;;; todo --- display TODO files in various ways

;; Copyright (C) 2003 Thien-Thi Nguyen
;; This program is part of ttn-do, released under GNU GPL v2 with ABSOLUTELY
;; NO WARRANTY.  See http://www.gnu.org/copyleft/gpl.txt for details.

;;; Commentary:

;; Usage: todo [OPTIONS] [PROJECT]
;;
;; Summarize PROJECT's todo file using "guile-tools summarize-guile-TODO".
;; PROJECT is a regular expression that may match one or more todo file
;; names registered in the meta data file (see `--meta' below).  If PROJECT
;; is omitted, all projects are selected.
;;
;; OPTIONS are zero or more of:
;;  -L, --list       -- display mtime and name of each todo file regsitered
;;  -M, --meta FILE  -- use FILE for meta data [default: $HOME/.todo.list]
;;
;; These options are also accepted (passed through to summarize-guile-TODO):
;;  -i, --involved USER  -- select USER-involved items
;;  -p, --personal USER  -- select USER-responsible items
;;  -t, --todo           -- select unfinished items (status "-")
;;  -d, --done           -- select finished items (status "+")
;;  -r, --review         -- select review items (marker "R")
;;
;;  -w, --who            -- also show who is associated w/ the item
;;  -n, --no-parent      -- do not show parent chain

;;; Code:

(use-modules (scripts PROGRAM)
             (scripts summarize-guile-TODO)
             (ttn expand-file-name))

(define (display-mtime-and-name name)
  (format #t "~A  ~A\n"
          (let ((full (expand-file-name name)))
            (if (file-exists? full)
                (strftime "%Y-%m-%d  %H:%M:%S"
                          (localtime (stat:mtime (stat full))))
                "  (does not exist)  "))
          name))

(define *summarize-guile-TODO-option-spec*
  '((involved  (single-char #\i)
               (value #t))
    (personal  (single-char #\p)
               (value #t))
    (todo      (single-char #\t))
    (done      (single-char #\d))
    (review    (single-char #\r))
    (who       (single-char #\w))
    (no-parent (single-char #\n))))

(define (make-display-todo-file-proc qop)
  (let* ((options '())
         (chk! (lambda (key)
                 (let ((val (qop key)))
                   (and val (set! options (acons key val options)))))))
    (for-each chk! (map car *summarize-guile-TODO-option-spec*))
    (lambda (name)                      ; rv
      (format #t "todofile: ~A\n" name)
      (summarize-guile-TODO options (expand-file-name name))
      (newline))))

(define (main/qop qop)
  (let ((all (let ((inp (open-input-file
                         (or (qop 'meta)
                             (format #f "~A/.todo.list" (getenv "HOME"))))))
               (let loop ((f (read inp)) (acc '()))
                 (if (eof-object? f)
                     (begin (close-port inp)
                            (reverse acc))
                     (loop (read inp) (cons f acc)))))))
    (cond ((qop 'list)
           (for-each display-mtime-and-name all))
          ((null? (qop '()))
           (for-each (make-display-todo-file-proc qop) all))
          (else
           (let ((rx (make-regexp (car (qop '()))))
                 (spew (make-display-todo-file-proc qop)))
             (for-each (lambda (name)
                         (and (regexp-exec rx name)
                              (spew name)))
                       all)))))
  #t)

(HVQC-MAIN (command-line) main/qop
           '(usage . commentary)
           '(version . "1.0")
           '(package . "ttn-do")
           `(option-spec (meta (single-char #\M)
                               (value #t))
                         (list (single-char #\L))
                         ;; these are passed to `summarize-guile-TODO'
                         ,@*summarize-guile-TODO-option-spec*))

;;; todo ends here


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user


                 reply	other threads:[~2003-09-09 14:15 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E19wjGy-0006yv-00@surf.glug.org \
    --to=ttn@surf.glug.org \
    --cc=guile-user@gnu.org \
    --cc=ttn@glug.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).