[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Comparing last modification time without dired?
From: |
Michael Albinus |
Subject: |
Re: Comparing last modification time without dired? |
Date: |
Fri, 07 Nov 2014 10:05:44 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) |
"Loris Bennett" <loris.bennett@fu-berlin.de> writes:
> Hi Michael,
Hi Loris,
>>> If I have two buffers and want to see which of the corresponding files
>>> is the more recent, is there a faster way of doing it than running dired
>>> for each of the corresponding directories?
>>
>> (file-newer-than-file-p (buffer-file-name buf1) (buffer-file-name buf2))
>
> Thanks for this. If I want to do this as part of an interactive
> function, how would I invoke the choice of buffers like ediff-buffers
> does?
Steal the code from ediff-buffers. Untested:
(defun my-buffer-file-newer-than-file-p (buffer-A buffer-B)
(interactive
(list (read-buffer "Buffer A to compare: " (cons (current-buffer) nil))
(read-buffer "Buffer B to compare: ")))
(message
(if (file-newer-than-file-p (buffer-file-name (get-buffer buffer-A))
(buffer-file-name (get-buffer buffer-B)))
"Yes" "No")))
> Cheers,
>
> Loris
Best regards, Michael.
RE: Comparing last modification time without dired?, Drew Adams, 2014/11/07