如何为Windows和Linux计算机设置常见的emacs环境?

时间:2021-05-18 23:22:21

I use emacs for text editing and script development. I use both windows and ubuntu emacs 23.1 distribution.

我使用emacs进行文本编辑和脚本开发。我使用windows和ubuntu emacs 23.1分发。

Now I want both my linux and windows environment to replicate the same environment.

现在我希望我的linux和windows环境都能复制相同的环境。

  1. I will save my emacs environment here https://bitbucket.org/krish/emacs/, so file synchronisation will not be problem.

    我将保存我的emacs环境https://bitbucket.org/krish/emacs/,因此文件同步不会有问题。

  2. I don't have any different resolution settings for both the envionment

    我对这两种环境没有任何不同的分辨率设置

  3. I use aspell which need specific path and different installer in windows and linux

    我在Windows和Linux中使用aspell需要特定的路径和不同的安装程序

  4. I use perl, python, ruby mode along with other html, css, js-2 and nxml

    我使用perl,python,ruby模式以及其他html,css,js-2和nxml

Are there any specific way/advise to manage the common emacs environment between windows and linux? especially how to manage the program path?

是否有任何特定的方式/建议来管理Windows和Linux之间的常见emacs环境?特别是如何管理程序路径?

3 个解决方案

#1


7  

There's no real straightforward way. You'd have to isolate most (if not all) your platform specific routines into different files and load them up after checking for platform.

没有真正直截了当的方式。您必须将大多数(如果不是全部)平台特定的例程隔离到不同的文件中,并在检查平台后加载它们。

Steve Yegge has some information on how he manages his .emacs file along with the actual code itself over here. One of his points is how he keeps is cross platform hackable. It's worth a read.

Steve Yegge提供了一些关于他如何管理他的.emacs文件以及实际代码本身的信息。他的一个观点是他如何保持跨平台的可攻击性。值得一读。

#2


3  

I have a very similar setup to yours (Emacs 22.1, 22.2, 23.1 on various Linux versions with and without X and Windows with and without Cygwin). My setup includes ELPA, auctex, emacsw32, CEDET, JDEE, nxml and various other elisp packages. I do not use whatever comes with the system but keep copies of those packages in subversion.

我有一个非常类似的设置(Emacs 22.1,22.2,23.1在各种Linux版本上有和没有X和Windows有和没有Cygwin)。我的设置包括ELPA,auctex,emacsw32,CEDET,JDEE,nxml和各种其他elisp软件包。我不使用系统附带的任何东西,但保留这些包的副本在subversion中。

Majority of setup just works in all environments. Regarding paths, I think that majority of stuff one wants to call, such as aspell, can be called outside Emacs from command line too, so it`s worth putting them in $PATH thus avoiding having to specify full paths in Emacs.

大多数设置只适用于所有环境。关于路径,我认为大多数想要调用的东西,比如aspell,也可以从命令行在Emacs之外调用,所以值得将它们放在$ PATH中,从而避免在Emacs中指定完整路径。

For other things, I do In .emacs:

对于其他事情,我做.emacs:

; Load system-specific library and setup system-specific things that 
; must be setup before main setup 
(cond ((eq system-type 'windows-nt) (load-library "ntemacs-cygwin"))
      ((eq system-type 'gnu/linux) (load-library "linux"))
      (t (load-library "default")))

(system-specific-setup)

; Set up things as usually, no more system-type queries.

Where in linux.el:

linux.el中的位置:

(defun system-specific-setup()

  ; Default font
  (add-to-list
   'default-frame-alist
   '(font . "-Misc-Fixed-Medium-R-Normal--14-130-75-75-C-70-ISO8859-1"))
  (setq my-frame-width 95)
  (setq my-frame-height 56)
  ; Not much else
)

And in ntemacs-cygwin.el:

在ntemacs-cygwin.el中:

(defun system-specific-setup()
  ;; EmacsW32
  (setq emacsw32-root (concat private-elisp-lib "EmacsW32"))
  (add-to-load-path emacsw32-root)

  ;; Work around XSymbol initialization bug
  ;; ("C:\\ImageMagick\\convert" instead of system $PATH? Seriously?)
  (setq x-symbol-image-convert-program "convert")

  ;; etcetera...

)

Basically it is a matter of setting things up on one system, trying them on another and factoring out whatever needs to be different to the system-specific-setup.

基本上,这是在一个系统上进行设置,在另一个系统上尝试它们并将任何需要与系统特定设置不同的因素分解出来的问题。

And the Steve Yegge´s article in Noufal´s answer is a very good one.

Steve Yegge在Noufal答案中的文章非常好。

#3


0  

You can look to my emacs configs, where operations for differnet machines are splitted into separate files

您可以查看我的emacs配置,其中不同机器的操作被拆分为单独的文件

#1


7  

There's no real straightforward way. You'd have to isolate most (if not all) your platform specific routines into different files and load them up after checking for platform.

没有真正直截了当的方式。您必须将大多数(如果不是全部)平台特定的例程隔离到不同的文件中,并在检查平台后加载它们。

Steve Yegge has some information on how he manages his .emacs file along with the actual code itself over here. One of his points is how he keeps is cross platform hackable. It's worth a read.

Steve Yegge提供了一些关于他如何管理他的.emacs文件以及实际代码本身的信息。他的一个观点是他如何保持跨平台的可攻击性。值得一读。

#2


3  

I have a very similar setup to yours (Emacs 22.1, 22.2, 23.1 on various Linux versions with and without X and Windows with and without Cygwin). My setup includes ELPA, auctex, emacsw32, CEDET, JDEE, nxml and various other elisp packages. I do not use whatever comes with the system but keep copies of those packages in subversion.

我有一个非常类似的设置(Emacs 22.1,22.2,23.1在各种Linux版本上有和没有X和Windows有和没有Cygwin)。我的设置包括ELPA,auctex,emacsw32,CEDET,JDEE,nxml和各种其他elisp软件包。我不使用系统附带的任何东西,但保留这些包的副本在subversion中。

Majority of setup just works in all environments. Regarding paths, I think that majority of stuff one wants to call, such as aspell, can be called outside Emacs from command line too, so it`s worth putting them in $PATH thus avoiding having to specify full paths in Emacs.

大多数设置只适用于所有环境。关于路径,我认为大多数想要调用的东西,比如aspell,也可以从命令行在Emacs之外调用,所以值得将它们放在$ PATH中,从而避免在Emacs中指定完整路径。

For other things, I do In .emacs:

对于其他事情,我做.emacs:

; Load system-specific library and setup system-specific things that 
; must be setup before main setup 
(cond ((eq system-type 'windows-nt) (load-library "ntemacs-cygwin"))
      ((eq system-type 'gnu/linux) (load-library "linux"))
      (t (load-library "default")))

(system-specific-setup)

; Set up things as usually, no more system-type queries.

Where in linux.el:

linux.el中的位置:

(defun system-specific-setup()

  ; Default font
  (add-to-list
   'default-frame-alist
   '(font . "-Misc-Fixed-Medium-R-Normal--14-130-75-75-C-70-ISO8859-1"))
  (setq my-frame-width 95)
  (setq my-frame-height 56)
  ; Not much else
)

And in ntemacs-cygwin.el:

在ntemacs-cygwin.el中:

(defun system-specific-setup()
  ;; EmacsW32
  (setq emacsw32-root (concat private-elisp-lib "EmacsW32"))
  (add-to-load-path emacsw32-root)

  ;; Work around XSymbol initialization bug
  ;; ("C:\\ImageMagick\\convert" instead of system $PATH? Seriously?)
  (setq x-symbol-image-convert-program "convert")

  ;; etcetera...

)

Basically it is a matter of setting things up on one system, trying them on another and factoring out whatever needs to be different to the system-specific-setup.

基本上,这是在一个系统上进行设置,在另一个系统上尝试它们并将任何需要与系统特定设置不同的因素分解出来的问题。

And the Steve Yegge´s article in Noufal´s answer is a very good one.

Steve Yegge在Noufal答案中的文章非常好。

#3


0  

You can look to my emacs configs, where operations for differnet machines are splitted into separate files

您可以查看我的emacs配置,其中不同机器的操作被拆分为单独的文件