emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nicolas Goaziou <n.goaziou@gmail.com>
To: Alan Schmitt <alan.schmitt@polytechnique.org>
Cc: Bastien <bzg@gnu.org>, emacs-orgmode <emacs-orgmode@gnu.org>
Subject: Re: org-review-schedule
Date: Fri, 25 Apr 2014 08:51:39 +0200	[thread overview]
Message-ID: <87fvl1lx50.fsf@gmail.com> (raw)
In-Reply-To: <m2iopzdjyx.fsf@polytechnique.org> (Alan Schmitt's message of "Thu, 24 Apr 2014 13:51:02 +0200")


Alan Schmitt <alan.schmitt@polytechnique.org> writes:

> I changed the date. As I signed the FSF paper, do I need to change the
> name as well and put mine?

For contrib/ directory, you can assign copyright to your name.

> I attach the new version.

Thanks. A few minor comments follow.

> I would like to propose to add this to the contrib directory, but
> I don't know the procedure to submit this code.

You simply copy the file in the contrib/lisp/ directory, edit
contrib/README and edit `org-modules' defcustom in "org.el".

> ;; Example use.
> ;; 

Trailing whitespace.

> ;; 1 - To display the things to review in the agenda.
> ;; 


> (defun org-review-last-planned (last delay)
>   "Computes the next planned review, given the LAST review
>   date (in string format) and the review DELAY (in string
>   format)."
>   (let* ((lt (org-read-date nil t last))
>          (ct (current-time)))

Plain `let' is sufficient here.

>     (time-add lt (time-subtract (org-read-date nil t delay) ct))))
> (defun org-review-last-review-prop ()
>   "Return the value of the last review property of the current
> headline."
>   (let ((lr-prop org-review-last-property-name))
>     (org-entry-get (point) lr-prop)))

The `let' seems useless. I think

  (org-entry-get (point) org-review-last-property-name)

is simple enough.

> (defun org-review-toreview-p ()
>   "Check if the entry at point should be marked for review.
> Return nil if the entry does not need to be reviewed. Otherwise return
> the number of days between the past planned review date and today.
> If there is no last review date, return nil.
> If there is no review delay period, use `org-review-delay'."
>   (let* ((lr-prop org-review-last-property-name)
>          (lp (org-entry-get (point) lr-prop)))

I suggest to use your own function:

 (let ((lp (org-review-last-review-prop)))

>     (when lp 

Trailing whitespace.

>       (let* ((dr-prop org-review-delay-property-name)
>              (dr (or (org-entry-get (point) dr-prop t) 
>                      org-review-delay))

Trailing whitespace.  Also I suggest to merge DR and DR-PROP:

  (let* ((dr (or (org-entry-GET (point) org-review-delay-property-name t)

>              (nt (org-review-last-planned lp dr))
>              )

Dangling parenthesis.

>         (if (time-less-p nt (current-time)) nt)))))

This is a matter of taste, but I find one-armed `if' a bit confusing.
Since return value matters, I suggest to use

  (and (time-less-p nt (current-time)) nt)

> (defun org-review-insert-last-review (&optional prompt)
>   "Insert the current date as last review. If prefix argument:
> prompt the user for the date."
>   (interactive "P")
>   (let* ((ts (if prompt
>                 (concat "<" (org-read-date) ">")
>               (format-time-string (car org-time-stamp-formats)))))
>     (save-excursion

I don't think this `save-excursion' is needed.

>       (org-entry-put
>        (if (equal (buffer-name) org-agenda-buffer-name)
>            (or (org-get-at-bol 'org-marker)
>                (org-agenda-error))
>          (point))
>        org-review-last-property-name
>        (cond 

Trailing whitespace.

>         ((equal org-review-timestamp-format 'inactive)

`eq' should be used when comparing symbols.

>          (concat "[" (substring ts 1 -1) "]"))
>         ((equal org-review-timestamp-format 'active)


>          ts)
>         (t (substring ts 1 -1)))))))
> (defun org-review-skip ()
>   "Skip entries that are not scheduled to be reviewed."
>   (save-restriction
>     (widen)
>     (let ((next-headline (save-excursion (or (outline-next-heading)
>                                              (point-max)))))
>       (cond
>        ((org-review-toreview-p) nil)
>        (t next-headline)))))

This function doesn't move point (so it skips nothing), is it expected?

Also, I think `save-restriction' + `widen' is only useful for
`outline-next-heading'. And `save-restriction' + `save-excursion' +
`widen' = `org-with-wide-buffer'. You may want to rewrite it to
something like:

  (defun org-review-skip ()
    "Skip entries that are not scheduled to be reviewed."
    (and (not (org-review-toreview-p))
         (org-with-wide-buffer (or (outline-next-heading) (point)))))


Nicolas Goaziou

  reply	other threads:[~2014-04-25  6:51 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-18 20:27 org-review-schedule Alan Schmitt
2014-04-19  8:14 ` org-review-schedule Bastien
2014-04-19 11:16   ` org-review-schedule Alan Schmitt
2014-04-19 11:51     ` org-review-schedule Bastien
2014-04-24 11:51   ` org-review-schedule Alan Schmitt
2014-04-25  6:51     ` Nicolas Goaziou [this message]
2014-04-25  7:43       ` org-review-schedule Alan Schmitt
2014-04-25  8:02         ` org-review-schedule Nicolas Goaziou
2014-04-27  8:09           ` org-review-schedule Alan Schmitt
2014-04-28  7:20             ` org-review-schedule AW
2014-04-28 11:29               ` org-review-schedule Alan Schmitt
2014-05-06  9:27             ` org-review-schedule Bastien
2014-05-15 10:07             ` org-review-schedule Bastien
2014-05-20 12:48               ` org-review-schedule Alan Schmitt
2014-05-21 12:08                 ` org-review-schedule Bastien
2014-05-21 12:58                   ` org-review-schedule Alan Schmitt
2014-04-26  8:57       ` org-review-schedule Alan Schmitt
2014-04-26 10:38         ` org-review-schedule Thorsten Jolitz
2014-04-26 12:25           ` org-review-schedule Nicolas Goaziou
2014-04-27  8:08             ` org-review-schedule Alan Schmitt

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:

  List information: https://www.orgmode.org/

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

  git send-email \
    --in-reply-to=87fvl1lx50.fsf@gmail.com \
    --to=n.goaziou@gmail.com \
    --cc=alan.schmitt@polytechnique.org \
    --cc=bzg@gnu.org \
    --cc=emacs-orgmode@gnu.org \


* 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.
Code repositories for project(s) associated with this public inbox


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).