繁体   English   中英

在emacs 23和emacs 24之间共享emacs配置

[英]share emacs configuration between emacs 23 and emacs 24

我试图将所有emacs配置置于版本控制下,以便在不同的计算机之间轻松切换。 实际上,我首选的系统是来自http://emacsformacosx.com/的 OSX(10.8.3)和emacs 24.3。 但是我也可以在通常配备emacs 23.4的其他系统(更可能是基于linux的系统,尽管使用不同的ubuntu / scientific-linux)中工作。 我想要的是一个初始化文件,该文件检查emacs的版本和操作系统,并从emacs软件包管理器中加载所需的软件包。 到目前为止,我在OSX上的emacs 24.3的.emacs初始化文件如下

(require 'package)
(setq package-archives '(
    ("marmalade" . "http://marmalade-repo.org/packages/")
    ("org" . "http://orgmode.org/elpa/")
    ("melpa" . "http://melpa.milkbox.net/packages/")))
(package-initialize)

之后,有配置(例如,单独加载

(load "python-sy")

使用某些未默认安装的软件包:特别是

color-theme
org-mode
theme-changer
ess-site
magit
auctex
python.el (fgallina implementation)

加上依赖于内置软件包的其他一些东西,我承认我不知道如何开始拥有一个.emacs初始化文件,该文件可以在所有设备中使用。 此外,我还希望有一种基于系统配置来加载url-proxy-services的方法

(setq url-proxy-services '(("http" . "proxy.server.com:8080")))

感谢您的任何帮助

相关变量是system-typeemacs-major-version 您可以使用以下内容

(if (>= emacs-major-version 24)
    (progn
      ;; Do something for Emacs 24 or later
      )
  ;; Do something else for Emacs 23 or less
  )

(cond
 ((eq system-type 'windows-nt)
  ;; Do something on Windows NT
  )
 ((eq system-type 'darwind)
  ;; Do something on MAC OS
  )
 ((eq system-type 'gnu/linux)
  ;; Do something on GNU/Linux
  )
 ;; ...
 (t
  ;; Do something in any other case
  ))

除了giornado答案外,您还可以通过特定的方式设置特定于软件包的设置,以便仅通过测试(require)结果对存在的软件包进行评估。 bbdb软件包的示例:

(when (require 'bbdb nil t)
    (progn ...put your (setq) and other stuff here... ))

对于这种情况,我在.emacs的顶部定义了几个常量:

(defconst --xemacsp (featurep 'xemacs) "Is this XEmacs?")
(defconst --emacs24p (and (not --xemacsp) (>= emacs-major-version 24)))
(defconst --emacs23p (and (not --xemacsp) (>= emacs-major-version 23)))
(defconst --emacs22p (and (not --xemacsp) (>= emacs-major-version 22)))
(defconst --emacs21p (and (not --xemacsp) (>= emacs-major-version 21)))

用法示例:

(when --emacs24p
    (require 'epa-file)
    (epa-file-enable)
    (setq epa-file-cache-passphrase-for-symmetric-encryption t) ; default is nil
    )

要么:

  (if --emacs22p
      (c-toggle-auto-newline 1)
    (c-toggle-auto-state 1))

等等

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM