If you have multiple machines, such as Windows and Linux, you may need to try to synchronize your Emacs configuration file among multiple machines! In this way, the following steps can be used to achieve this goal:
1) try to put things related to the local path into the. emacs file, and put other common contents into other El files.
I use SVN to manage my Emacs configuration files, and I also save the extended El files to SVN. In this way, I only need to check out the configuration file on any machine, you can use it.
Of course, different machines may face issues such as fonts and file paths. In this case, you need to configure them separately based on the actual situation of each machine.
You can use (system-type) to identify the operating system version of the current machine. Similarly, you can determine which parameters should be set in the configuration file based on more attributes, such as the user name.
For multiple machines of the same type, you can determine the path of your Emacs based on the (system-name.
These two methods are similar in nature and can be selected flexibly based on their own attributes.
To identify and configure differentCodeYou can refer to the following example code:
;; For Windows, perform the following settings: ( If (EQ system-type 'windows-NT) ;; Current System is windows, do some specific setting for Windows ;; (Message "current system is Windows ") ;; Use cygwin as Bash ( Let * (Cygwin-Root "D:/cygwin" ) (Cygwin-bin (Concat cygwin-Root "/Bin" ))) ;; Set different paths based on different Windows systems ;; Set the company computer path (If (String-match (system-name) SCUT-9C14ED3B4C" ) (Setenv "Home" (Concat cygwin-Root "/Home/water" ))) ;; Set the home computer path ( If (String-match (system-name) "32283744ff164e6" ) (Setenv "Home" (Concat cygwin-Root "/Home/water" ) (Setenv "Path" (Concat cygwin-bin ";" (Getenv "Path" ) (Setq Exec-path (cons cygwin-bin Exec-path) (setq shell-file-name "Bash" ) (Setq explicit-shell-file-name "Bash" ) ;; Else current system is Linux, do some specific setting for Linux ( If (Or (EQ system-type 'cygwin) (EQ system-type' GNU/Linux) (EQ system-type' Linux) (Message "Current System is Linux, please do some specific setting here" )))
If you want to set the font for a specific type of system, you can refer to the following code to set it:
;;Font set(If(Or (EQ system-type 'cygwin) (EQ system-type' GNU/Linux) (EQ system-type' Linux) (set-default-font"Courier 10 pitch-12") (Set-default-font"Courier New-14"))
If you set a large amount of code, you can divide the code on different platforms into several files and import different files.
2) Select the file to be synchronized
Not all configuration files need to be synchronized, and I do not agree that all files need to be synchronized. Some configuration files can be chosen not to be synchronized based on the platform's needs.
My habit is that. Ido. Last,. recentf,. emacs. Desktop files are not synchronized.
Because the computer at home is basically different from the company's computer, there is no need to stir up a pile of computers, so it is not easy to conflict. Another one, when I go home, I will not do anything about the public!
3) remote file synchronization software or tools
For file synchronization tools, shuimuCommunityRecommended on Emacs, projectlocker and Dropbox are both good. The former is a free SVN server, and the latter is also a free file synchronization tool. Similarly, some other synchronization software can be used for trial.
By carefully setting the preceding three steps, you can synchronize the Emacs working environment, org, Muse, and other files on multiple computers once and for all.
I would like to thank the ahei0802, swdonline, Madsen and other members of the Emacs community for sharing their experiences.