help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Comparing last modification time without dired?


From: Loris Bennett
Subject: Re: Comparing last modification time without dired?
Date: Fri, 07 Nov 2014 11:24:20 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Hi Michael,

Michael Albinus <michael.albinus@gmx.de> writes:

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

Stealing your code, I get

Wrong type argument: stringp, #<buffer alternative_cluster_software.org>

as soon as I call my-buffer-file-newer-than-file-p

However, if I run it with "emacs -q" it works.  So something in my
.emacs must be screwing things up.  I thought maybe using uniqify was
the problem, but toggling it didn't make any difference.

Any ideas what the problem might be?

Cheers,

Loris

>> Cheers,
>>
>> Loris
>
> Best regards, Michael.
>

-- 
This signature is currently under construction.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]