emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nicolas Goaziou <mail@nicolasgoaziou.fr>
To: Rasmus <rasmus@gmx.us>
Cc: emacs-orgmode@gnu.org
Subject: Re: [patch] get modification-time from vc
Date: Sat, 30 Apr 2016 23:43:38 +0200	[thread overview]
Message-ID: <87shy2ydpx.fsf@saiph.selenimh> (raw)
In-Reply-To: <877ffhn3gz.fsf@gmx.us> (rasmus@gmx.us's message of "Thu, 28 Apr 2016 17:43:40 +0200")

Hello,

Rasmus <rasmus@gmx.us> writes:

> The file system modification time as accessed by {{{modification-time}}}
> is often wrong, e.g. when a project is newly cloned or if the file has
> been copied in a sloppy manner.  At least if modification time suggest the
> time that the file was edited by an author.
>
> Sometimes vc can provide a better answer.  The attached patch tries to get
> a sensible time from vc.

Thank you for the patch.

> WDYT?

Well, if you ask, I do not like much when some software tries to
outsmart me (note that I like it even less when it actually succeeds).
So, I think {{{modification-time}}} should expand to modification time.

If you think that is useful, then I vote for a different macro.

Usual nitpicking follows.

> +					       (when (search-forward-regexp "Date:?[ \t]*" nil t)

Any reason not to use the genuine `re-search-forward'?

Is the search case sensitive? I suggest to bind appropriately
`case-fold-search' in any case.

> +						 (let ((time (parse-time-string
> +							      (buffer-substring
> +							       (point) (point-at-eol)))))

Any reason not to use the genuine `line-end-position'?

> +						   (when (org-some 'identity time)

  (cl-some #'identity time)

> +						     (setq date (apply 'encode-time time))))))))

  (setq date (apply #'encode-time time))

> +					  (let ((proc (get-buffer-process buf)))
> +					    (while (and proc (accept-process-output proc .5 nil t))))
> +					  (kill-buffer " *org-vc*")

  (kill-buffer buf)

However, I suggest to use `unwind-protect' for this and kill-buffer
during as an unwind form.

Also, I suggest to factor this code out of
`org-macro-initialize-templates'.


Regards,

-- 
Nicolas Goaziou

  reply	other threads:[~2016-04-30 21:44 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-28 15:43 [patch] get modification-time from vc Rasmus
2016-04-30 21:43 ` Nicolas Goaziou [this message]
2016-05-18 10:12   ` Rasmus
2016-05-18 16:45     ` Nicolas Goaziou
2016-05-18 19:45       ` Rasmus
2016-05-19  7:47         ` Nicolas Goaziou

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.orgmode.org/

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

  git send-email \
    --in-reply-to=87shy2ydpx.fsf@saiph.selenimh \
    --to=mail@nicolasgoaziou.fr \
    --cc=emacs-orgmode@gnu.org \
    --cc=rasmus@gmx.us \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

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