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 21:31:26 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Yuri Khan <yuri.v.khan@gmail.com> writes:
> On Thu, Jul 28, 2016 at 7:03 AM, Rolf Ade <rolf@pointsman.de> wrote:
>
>> I often edit files in emacs, that are under version control. It should
>> not, but it happens, that I haven#t save-buffer some buffer, while
>> check-in on the cmd line.
>
> Normally, when staging a commit, for each unsaved file, you will see a
> lock (.#<filename>) and possibly a recovery file (#<filename>#) in the
> same directory. This is your signal that not all files are saved. As
> soon as you save the file, its lock and recovery file disappear.

Well, this proposes an enlargement of my work-flow. Do one step more:
run ls and look at the output, before I check-in.

Still, a simple ls would not be sufficent. Often, there are a few
modified files spread over sub-directories. A `find -name '#*'` instead
of a simple ls could help, but has other drawbacks. Most important, this
would only work if I check-in only in the root directory of the version
controled sub tree, which is I step, that is currently not needed. Yes,
a bit shell scripting within the wrapper around the scm command line
tool could find the root of the source tree and do the find there. But
even then other open and modified files out of that sub tree, that are
not under version control (temporary input or output files, for example)
would give false positives.

With emacsclient -e I'm able to ask the running emacs. Something like
this

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

is a skeleton of what I want. The missing piece is that I only want to
look at buffers under version control, not on all buffers, that are
visiting a file, as above.

In other words, I'm searching for a (buffer-is-under-version-control-p
buffer) function. How could that be done?


reply via email to

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