簡體   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