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

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

Re: List of buffers under version control?


From: Rolf Ade
Subject: Re: List of buffers under version control?
Date: Thu, 28 Jul 2016 23:01:19 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

John Mastro <john.b.mastro@gmail.com> writes:

> Rolf Ade <rolf@pointsman.de> wrote:
>> Since emacs show me in the mode line of that buffers, that the file is
>> under version control, there must be a way with elisp to determine, if
>> the file shown in a buffer is under version control. How could that be
>> done?
>
> You could use `vc-backend', e.g. (vc-backend (buffer-file-name)).

Thank you. That was the missing bit.

Something like this is it:

(loop for buffer in (buffer-list)
      until (if (vc-backend (buffer-file-name buffer))
                (buffer-modified-p buffer))
      finally return (if (and (buffer-modified-p buffer)
                              (vc-backend (buffer-file-name buffer)))
                         1
                       0))

> `save-some-buffers' accepts an argument PRED; you could also use
> `vc-backend' there:

Yes. This doesn't apply in my case, because I'm 'quering' emacs from
within a script with the help of emacsclient -e and want just a yes / no
answer (hence the 'un-lispish' return values). I just want to know, if
this is the case (and ask for confirmation, to give me a chance to look
at the thing, instead of just saving).


reply via email to

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