2013-03-11 3 views
13

저는 MELPA와 Marmalade를 통해 가능한 한 많이 설치하고 있습니다. ~/.emacs.d는 git을 사용하여 관리합니다. 그러나, 나는 * .elc 파일을 무시한다.ELPA 패키지를 어떻게 자동으로 (다시) 컴파일합니까?

즉, 하나의 시스템에 패키지를 설치 한 다음 다른 시스템을 사용하기 시작하면 git pull은 * .el 파일 만 제공합니다. 이러한 파일을 사용하는 것은 종종 * .elc를 사용하는 것보다 느립니다.

은 내가 ~/.emacs.d/init.el에 다음을 추가하는 시도 :

;; load the packages we've installed. Note that package-install 
;; byte-compiles the packages, but .elc is ignored by git so we force recompilation here 
(byte-recompile-directory (expand-file-name "~/.emacs.d/elpa") 0) 
(package-initialize) 

불행하게도,이 package.el에 의해 수행 컴파일에 해당하지 않습니다. 내가 이맥스 - eclim을 설치하는 경우 예를 들어, package.el는 이맥스 - eclim/회사 이맥스 - eclim.el를 컴파일되지 않습니다, 나는 다음과 같은 오류 얻을 : 나는 이맥스 바이트 - 어떻게해야합니까

Leaving directory `/home/wilfred/.emacs.d/elpa' 

Compiling file /home/wilfred/.emacs.d/elpa/emacs-eclim-20130310.1237/company-emacs-eclim.el at Mon Mar 11 15:40:01 2013 
Entering directory `/home/wilfred/.emacs.d/elpa/emacs-eclim-20130310.1237/' 
company-emacs-eclim.el:35:1:Error: Cannot open load file: eclim 
Warning: reference to free variable `multiple-cursors-mode' 
Warning: reference to free variable `mc--read-char' 
Warning: assignment to free variable `mc--read-char' 
Warning: reference to free variable `multiple-cursors-mode' 
Warning: reference to free variable `mc--read-quoted-char' 
Warning: assignment to free variable `mc--read-quoted-char' 
Warning: reference to free variable `rectangular-region-mode' 
Warning: reference to free variable `rectangular-region-mode' 

을 package.el과 동일한 파일 만 컴파일 하시겠습니까?

답변

6

package.el 실제로 실제로 똑같은 방법을 사용합니다. 시작시 다시 컴파일하면 오류가 더 눈에 띄게됩니다.

(byte-recompile-directory pkg-dir 0 t) 

가 그래서 문제의 원본 코드가 정확한지 :

사용되는 함수를 호출하는 package--make-autoloads-and-compile이다. 그러나 다음 작업을 수행 할 수 있습니다, 아직 컴파일되지 않은 디렉토리를 다시 컴파일합니다 :

(require 'dash) 
(require 'f) 

(defun was-compiled-p (path) 
    "Does the directory at PATH contain any .elc files?" 
    (--any-p (f-ext? it "elc") (f-files path))) 

(defun ensure-packages-compiled() 
    "If any packages installed with package.el aren't compiled yet, compile them." 
    (--each (f-directories package-user-dir) 
    (unless (was-compiled-p it) 
     (byte-recompile-directory it 0)))) 

(ensure-packages-compiled) 
2

정확히 같은 방법으로 바이트 컴파일 패키지에 대한 특정 문제에 대한 답을 모른다. package.el.

그러나 Melpa 또는 marmalade를 통해 확장 프로그램을 설치하는 동안 emacs 구성 디렉토리를 유지 관리하는 일반적인 문제에 대해서는이 문제를 해결하기 위해 설계된 pallet을 살펴 보시기 바랍니다.

+1

감사합니다. 팔레트에 대해 알지 못했습니다. 그러나, 필자는 .emacs.d를 자체적으로 포함하고 싶습니다. 이전에 거의 다운로드하지 않은 elisp 파일을 더 이상 사용할 수 없어서 슬픔을 겪었습니다. –

8

버전 관리에 패키지를 보관하지 않는 것이 좋습니다 (개정 관리하에 .o 파일을 두지 않습니까?). 여기에 내가 동기화 내 패키지를 유지하기 위해 사용하는 코드입니다 : 내가 (물론 버전 제어에서) init.el에 위를 넣어

(setq jpk-packages 
     '(
     ac-dabbrev 
     ... 
     yasnippet 
     )) 

(package-initialize) 
(add-to-list 'package-archives 
      '("melpa" . "http://melpa.milkbox.net/packages/")) 
(add-to-list 'package-archives 
      '("org" . "http://orgmode.org/elpa/")) 

(when (not package-archive-contents) 
    (package-refresh-contents)) 

(dolist (pkg jpk-packages) 
    (when (and (not (package-installed-p pkg)) 
      (assoc pkg package-archive-contents)) 
    (package-install pkg))) 

(defun package-list-unaccounted-packages() 
    "Like `package-list-packages', but shows only the packages that 
    are installed and are not in `jpk-packages'. Useful for 
    cleaning out unwanted packages." 
    (interactive) 
    (package-show-package-list 
    (remove-if-not (lambda (x) (and (not (memq x jpk-packages)) 
          (not (package-built-in-p x)) 
          (package-installed-p x))) 
        (mapcar 'car package-archive-contents)))) 

, 그리고 아직 때 존재하지 않는 패키지를 설치 emacs가 시작됩니다. 업데이트는 package-list-packages 버퍼에서 수행됩니다. package-list-unaccounted-packages은 설치되어 있지만 내 jpk-packages 목록에없는 모든 패키지를 표시하며 목록에서 제거한 패키지를 쉽게 제거 할 수 있습니다.

특정 질문에 대한 답변을 보려면 위의 코드를 사용하여 elpa 디렉토리를 삭제하고 모든 것을 다시 설치하십시오.

+0

jpk-packages는 Carton 매니페스트와 같습니다 (@francesco는 위의 Pallet에서 설명했듯이). 그러나 정확한 패키지 버전을 지정하는 기능은 상실됩니다. –

+0

나는 Carton이나 Pallet을 사용하지 않지만, 내가 이해하는 바에 따르면, 내가 사용하는 것은 그것들의 아주 간단한 버전이다. 나는 카톤/팔레트를 부트 스트랩하기 위해 거의 모든 코드를 필요로하기 때문에 내 방식이 마음에 들었고, 지금까지는 패키지 버전을 지정하지 않는 데 문제가 없었다. – jpkotta

+2

".o 파일을 개정 관리하에 두지 않습니까?" 나는 공정한 비교라고 생각하지 않는다. 빌드 .o 파일은 항상 재현 가능해야합니다. 그러나 특정 버전의 패키지를 지정하는 방법은없는 것 같습니다. 내가 함께 작동하도록 알고있는 이맥스 설정의 일관된 스냅 샷을 배포 할 수 있도록 패키지 파일을 체크인합니다. –

1

당신이 가진 문제는 당신이 바이트 컴파일 패키지를 초기화하기 전에 파일을 간단하게한다는 것입니다. 두 줄을 전환하면 문제가 사라집니다. 오류 (Cannot open load file: eclim)는 ~/.emacs.d/elpa/emacs-eclim-20130310.1237/이 아직 사용자의 load-path에 없기 때문에 package-initialize은 (다른 몇 가지와 함께) load-path에 추가합니다.

6

더 일반적인 질문에 대한 답변은 "은 (는)을 자동으로 다시 컴파일하는 방법을 좋아합니다.elc 파일 "이 사용됩니다 https://github.com/tarsius/auto-compile

나는 대부분의 상황을 다루는 맞춤 솔루션을 가지고 있었지만이 라이브러리는 내가하고있는 모든 것을 다루고 있으며 그 외에는 아무것도로드하지 않은 채로 초기화합니다.

원래 컴파일되지 않은 파일을 컴파일하지 않는 원래의 질문에 대해서는 0의 인수가 byte-recompile-directory인데, 명시 적으로 해당 동작을 요구하고 있습니다. 기본 동작은 기존 파일을 다시 컴파일하는 것입니다. 구식 .elc 파일이므로, 단지 0을 제거하면됩니다.

1

(byte-compile-file)은 이전에 elpa를 사용하여 설치 한 패키지를 수동으로 재 컴파일해야 할 때 저에게 도움이되었습니다.

특히이 상황의 경우 : https://github.com/yjwen/org-reveal/issues/76t

관련 문제