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

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

bug#49980: 28.0.50; [PATCH] Should we have project-save-buffers?


From: Arthur Miller
Subject: bug#49980: 28.0.50; [PATCH] Should we have project-save-buffers?
Date: Sun, 15 Aug 2021 12:44:57 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Juri Linkov <juri@linkov.net> writes:

>> (save-some-buffers t 'save-some-buffers-root)
>>
>> So how does it work? save-some-buffers-root auto detects a git repo
>> root via project-find-functions in project.el or something there? I
>> havent followed entire call chain. I ask, because I guess this is going
>> to be part of Emacs 28 but wonder if you have any plans to port it
>> into older versions?
>
> You can make it backward-compatible with older versions by copying
> the contents of the function save-some-buffers-root literally
> to your code.  This call should work in older versions:
Ah, that was was the magic. I was looking into those functions, but
wasn't really sure what I should snitch :). 

> to your code.  This call should work in older versions:
>
> #+begin_src emacs-lisp
>   (save-some-buffers
>    t
>    (let ((root (or (and (project-current) (project-root (project-current)))
>                    default-directory)))
>      (lambda () (file-in-directory-p default-directory root))))
> #+end_src

Thank you!

>> Could you guys care to take a look at my little branch switcher? If you
>> have time. I could use some review and advice. It is ~200 sloc and most
>> of it is helm boiler code, I am really interesting about opinion on
>> stash/unstash strategy. I stash everything include untracked
>> files. However I am thinking of implementing other strategy, via commit
>> and undo commit.
>
> Thanks, this is a useful package.  It uses the right strategy
> to stash and unstash changes.  This is much better than committing
> and undoing commits like we recently discussed in
> https://lists.gnu.org/archive/html/emacs-devel/2021-08/msg00346.html

I have to admit, I haven't followed so much the discussion, this was
just sommething I wished to had for longer time, but never come about to
implement.

I am not sure if my approach is correct. I think it can mess up things
when multiple branches get changed. If there are only two branches
invloved, a->b, b->c, there are no problems (I think). Also with
multiple branches without changes there should be no problems.

But in case of a->b, b->c, ... , c->n, I am not sure, but I believe they
would have to be checked out in correct reversed order. Otherwise I
think there is possiblity that applied stashes tramp over each others
and cause conflicts. I don't know, I haven't had time to test it that
far. I had this for a couple of weeks, and works fine for my modest
need, but I would appreciate some more input on the code.

I have attached it the source in this mail, if anyone is interested to
look at it, but there is also a github project with some more info in a
readme file at:

https://github.com/amno1/helm-git-branch

I am thankful for all input, and thanks for all your help Juri!

Attachment: helm-git-branch.el
Description: Text document


reply via email to

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