From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: [patch] get modification-time from vc Date: Sat, 30 Apr 2016 23:43:38 +0200 Message-ID: <87shy2ydpx.fsf@saiph.selenimh> References: <877ffhn3gz.fsf@gmx.us> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:55656) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1awcgJ-0001mU-SY for emacs-orgmode@gnu.org; Sat, 30 Apr 2016 17:44:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1awcg7-0007Qc-VZ for emacs-orgmode@gnu.org; Sat, 30 Apr 2016 17:44:02 -0400 Received: from relay3-d.mail.gandi.net ([217.70.183.195]:51192) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1awcg7-0007LP-PW for emacs-orgmode@gnu.org; Sat, 30 Apr 2016 17:43:55 -0400 In-Reply-To: <877ffhn3gz.fsf@gmx.us> (rasmus@gmx.us's message of "Thu, 28 Apr 2016 17:43:40 +0200") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Rasmus Cc: emacs-orgmode@gnu.org Hello, Rasmus 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