0

I have some settings for my emacs.

Let's say this settings can be separated to "B(both)+P(personal_computers)+R(remote_computers)"

I want in my personal computers, I can git pull/push "B+P" while in remote_computers, I can git pull/push "B+R".

The most important is that the repository includes all of the things "B+P+R".

Thank you very much.

yuxuan
  • 417
  • 5
  • 16

2 Answers2

2

Emacs is less an editor and more an ELisp environment with an editor. Your settings are written in ELisp (Emacs Lisp). ELisp is extremely powerful. One option is to maintain one set of settings and use ELisp to differentiate between "remote" and "personal" features. Use an environment variable or a dot file or whatever you like to indicate "remote" vs "personal". This is probably the least hassle.

Here's an example from my .emacs. Aquamacs defaults alt-w to kill the current frame. This rebinds it to kill the current buffer. Aquamacs uses osx-key-mode-map for key binding, so it first checks for that so the config continues to work with other Emacs implementations.

(defun kill-current-buffer ()
  (interactive)
  (kill-buffer (current-buffer)))
(when (boundp 'osx-key-mode-map)
    (define-key osx-key-mode-map '[(alt w)] 'kill-current-buffer))

The alternative is to maintain three branches. Start with universal and then branch personal and remote from it. When you want to add something, the procedure to would go something like this...

When you add a feature specific to personal or remote, add it to the appropriate branch. If you decide a feature is actually universal, you can use git-cherry-pick to add it to universal.

When you add a universal feature, commit it to the universal branch and then git checkout remote; git merge universal; git checkout personal; git merge universal.

Then clone the repository and checkout the appropriate branch.

Schwern
  • 153,029
  • 25
  • 195
  • 336
  • Your fist option is solid. However, I have to completely disagree with your second approach. Maintaining essentially three dev branches + a master is bad form. I have posted about this before and attached is a GREAT (not mine but the original) article written about a simple yet effective branching setup for GIT. http://stackoverflow.com/questions/32639964/what-is-the-workflow-for-maintaining-a-forked-git-repository/32640038#32640038 – ductiletoaster Sep 22 '15 at 02:35
  • @ductiletoaster Who said anything about having a `master`? Looking at it another way, `universal` is `master`. – Schwern Sep 22 '15 at 02:35
  • Haha ok then it is even worse. Three master branches is a terrible idea. The chances that someone will properly maintain all three "master" branches in unlikely. Each will contain different merge points and syncing them will be a hassle. Even a basic dev cycle should have at most one master branch and many SHORT lived feature branches – ductiletoaster Sep 22 '15 at 02:36
  • 1
    @ductiletoaster This isn't a project workflow; the whole point is to maintain two different "releases" of the software. And `master` is just a name. In this setup, `universal` is what would traditionally be `master`, just with a more descriptive name because this isn't a generic development project. `personal` and `remote` are not feature branches, they're long lived and will not be merged into `universal`. They're more like release branches. Feature branches should still be used for developing features. – Schwern Sep 22 '15 at 02:39
  • If this is truly ONLY for saving emacs settings and not a project workflow (which the OP did not specify) then your suggestion is fine. With that said I still think your first recommendation is solid and as such I am going to upvote! – ductiletoaster Sep 22 '15 at 02:42
  • @ductiletoaster Yes, this will work for storing emacs configs; I'm not going to add requirements to the OP's question. This question is basically "how do I maintain Windows, Mac and Linux releases of my software" on a small scale. Personally using branches for something this small is overcomplicated and I'd go with the ELisp approach. – Schwern Sep 22 '15 at 02:44
  • Awesome. I upvoted your answer simply because of the Elisp approach a little bit of a learning curve but a great solution nonetheless. – ductiletoaster Sep 22 '15 at 02:46
  • I had a lot of code in the settings. Do I need to rewrite it if I choose the first option? Or just put all the codes in a simple condition? – yuxuan Sep 23 '15 at 02:34
  • @yuxuan I'm no ELisp expert. I'd recommend you ask that as another question. – Schwern Sep 23 '15 at 02:35
0

It sounds like what you want is the ability to conditional load files based on your pull location. Though this isn't directly supported there are ways to do it by setting up some simple setting on each machine.

I would check the following post as it appears to be very similar to your question. However, If you have any specific questions about git I can answer them for you here. How to ignore files only locally in git?

Community
  • 1
  • 1
ductiletoaster
  • 483
  • 2
  • 9