developer tip

Windows에서 실행되는 Emacs 용 .emacs 파일은 어디에서 찾을 수 있습니까?

optionbox 2020. 8. 11. 08:21
반응형

Windows에서 실행되는 Emacs 용 .emacs 파일은 어디에서 찾을 수 있습니까?


Emacs 용 Windows 설치용 .emacs 파일을 찾으려고했지만 찾을 수 없었습니다. Windows에서 Unix와 동일한 파일 이름을 가지고 있습니까?

직접 만들어야합니까? 그렇다면 어떤 특정 디렉토리로 이동합니까?


Emacs FAQ, http://www.gnu.org/software/emacs/windows/ 에서 복사하여 붙여 넣었습니다 .

초기화 파일을 어디에 두나요?

Windows 에서는 파일 이름이 점으로 시작할 수없는 DOS 및 FAT 파일 시스템과의 하위 호환성을 위해 .emacs파일을 호출 할 수 있습니다 _emacs. 일부 사용자는 파일 시스템과 대부분의 다른 프로그램에서 처리 할 수 ​​있지만 Windows 탐색기가 점으로 시작하는 이름으로 파일을 만들 수 없기 때문에 이러한 이름을 계속 사용하는 것을 선호합니다. Emacs 22 이상에서는 init 파일을 .emacs.d/init.el. Lisp 패키지로 생성 된 다른 많은 파일도 이제 .emacs.d디렉토리에 저장 되므로 모든 Emacs 관련 파일을 한 곳에 보관합니다.

위에서 언급 한 모든 파일은 홈 디렉토리에 있어야합니다. HOME 디렉토리는 다음 단계에 따라 결정됩니다.

  1. 환경 변수 HOME이 설정된 경우 표시되는 디렉토리를 사용하십시오.
  2. 레지스트리 항목 HKCU \ SOFTWARE \ GNU \ Emacs \ HOME이 설정되어 있으면 표시된 디렉터리를 사용합니다.
  3. 레지스트리 항목 HKLM \ SOFTWARE \ GNU \ Emacs \ HOME이 설정되어 있으면 표시된 디렉터리를 사용합니다. 사용자가 동일한 홈 디렉토리를 공유하게되므로 권장되지 않습니다.
  4. C:\.emacs존재하는 경우 C:/. 이전 버전 C:/은 HOME이 설정되지 않은 경우 기본값으로 설정되었으므로 이전 버전과의 호환성을위한 것 입니다.
  5. 사용자의 AppData 디렉터리 (일반적으로 사용자 프로필 디렉터리 아래의 Application Data라는 디렉터리)를 사용합니다.이 디렉터리의 위치는 Windows 버전 및 컴퓨터가 도메인의 일부인지 여부에 따라 다릅니다.

Emacs 내 ~에서 파일 이름의 시작 부분은 HOME 디렉토리로 확장되므로 항상 .emacs 파일을 사용하여 .emacs 파일을 찾을 수 있습니다 C-x C-f ~/.emacs.

MS-Windows의 HOME 및 Startup Directories에 자세한 정보가 있습니다 .


변수 user-init-file에 저장되어야합니다. C-H v user-init-file RET확인하는 데 사용 합니다. 다음을 사용하여 직접 열 수도 있습니다.M-x eval-expression RET (find-file user-init-file) RET


Windows 용 Emacs에서 다음과 같이 파일을 엽니 다.

C-x C-f ~/.emacs

Emacs Wiki의 추가 정보


내 Vista 상자에는 C:\Users\<USER>\AppData\Roaming\


Ctrl-x Ctrl-f ~/.emacs파일을 입력 하고 생성하는 것만으로는 충분하지 않을 수 있습니다 .

Emacs 응용 프로그램이 init 파일을 저장하기 위해 다른 위치를 사용하는 것일 수 있으며, 그렇다면 ~ / .emacs 파일을 생성하면 Emacs 응용 프로그램이 무시 하는 쓸모없는 파일이 생성 됩니다.

또한 .emacs init 파일에 액세스 하는 것 이상을 원할 수 있지만 파일의 위치, 즉 경로 이름을 알고 싶을 수 있습니다.

이를 위해 두 가지 방법이 있습니다.

쉬운 방법 : 유형 Ctrl+ H V사용자 초기화 파일Return

약간 까다로운 방법 : 다음과 같이 시스템이 자체 .emacs 파일을 저장하는 위치를 찾을 수 있습니다.

  1. 옵션을 클릭하고 "기본 글꼴 설정 ..."까지 아래로 스크롤합니다.
  2. 글꼴 설정을 변경하고 확인을 클릭하십시오.
  3. 옵션 메뉴에서 "옵션 저장"으로 이동합니다.
  4. 옵션이 저장되면 시스템은 .emacs 파일을 저장하고 Emacs 화면 하단의 미니 버퍼에서 파일 경로읽을 수 있습니다.

Windows 7에서는 init.el파일을에 습니다 C:\Users\user-name\AppData\Roaming\.emacs.d\. 여기서 user-name 은 사용자 / 로그인 폴더입니다.

당신 때문에주의 init.el파일 이름이되지 않습니다 init.el.txt. 메모장과 같은 편집기로 파일을 만들면 Windows가 수행하는 작업입니다.


Windows 22 이상의 Emacs 버전에서는 다음으로 이동 한 것 같습니다.

~/.emacs.d/init.el

, ~환경 변수 HOME의 값입니다 (제어판 → 시스템고급환경 변수 참조 ).

파일 자체가 존재하지 않을 수 있습니다. 이 경우 그냥 만드십시오.


간자가 대답했듯이이 파일의 경로는 user-init-file변수에 저장됩니다 (또는 초기화 파일이없는 경우 변수에는 파일을 만들 위치에 대한 기본값이 포함됩니다).

따라서 사용할 수있는 init 파일 이름과 파일이있는 디렉토리에 관계없이 다음을 사용하여 init 파일을 방문 할 수 있습니다.

M-: (find-file user-init-file) RET

또는 다음을 사용하여 에코 영역에 전체 경로를 표시합니다.

M-: (expand-file-name user-init-file) RET


Emacs 23 및 Windows 7에서는 다음을 설정 한 경우에만 작동합니다.

HKCU\SOFTWARE\GNU\Emacs\HOME

Emacs 22가 가끔 내 XP 컴퓨터에서 "C : \ Documents and Settings \ username \ Application Data \ .emacs"또는 단지 "C : \ Documents and Settings \ username \ .emacs"를 여는 것을 발견했습니다. 가끔 마음이 바뀌는 이유에 대한 설명을 찾지 못했습니다.

~는 항상 emacs의 현재 인스턴스가 HOME이라고 생각하는 모든 것을 가리킬 것이지만, kanja의 팁 (Ch v user-init-file)은 항상 ~ / .emacs가 실제로 매핑하는 것을 알려줄 것입니다.


Windows XP에서는 다음과 같습니다.

C:\Documents and Settings\yourusernamehere\Application Data\

emacs 초기화 파일을 만들어야합니다. 하나는 자동으로 생성되지 않습니다. 나는 비슷한 문제가 있었고이 대답은 내가 한 일을 추적합니다.

내 문제는 내 ~/.emacs.el파일이로드되지 않는다는 것입니다. 이것이 항상 나를 위해 일했기 때문에 이상합니다.

This question/answer helped me but I had to put my init file in the %USERPROFILE%\AppData\Roaming\.emacs.d\init.el because this is apparently the default behavior on Windows.

To troubleshoot this, I ran the following in the emacs *scratch* buffer.

user-emacs-directory
"~/.emacs.d/"

When I saw user-emacs-directory was ~/.emacs.d, I simply moved my .emacs.el file to %USERPROFILE%\.emacs.d\init.el. But this still didn't work. I continued with expand-file-name as shown below:

(expand-file-name user-emacs-directory)
"c:/Users/pats/AppData/Roaming/.emacs.d/"

Got to love how Windows works. (not) So I moved my emacs.el file to the %USERPROFILE%\AppData\Roaming\.emacs.d\init.el and this worked. The file was now being read. But I got other errors because my initialization file loaded other (personal emacs) files (in ~/myenv/emacs/*.el.

Warning (initialization): An error occurred while loading ‘c:/Users/pats/AppData/Roaming/.emacs.d/init.el’:

Hum... Seems like all my files ~/myenv/emacs/*.el would need to be moved in order for this to work but I didn't want to do that. Then I realized that because the HOME environment variable was not set, emacs was performing its default behavior.

SOLUTION

Once I set my windows HOME environment variable to %USERPROFILE% everything began to work like it has for the past 25 years. :-)

To set the HOME environment variable, I typed WindowsKey+"edit environment variables for your account" to open the Environment Variables dialog box, and entered HOME=%USERPROFILE%.

Now my emacs initialization file .emacs.el is is back to its rightful place $HOME/.emacs.el and not in %USERPROFILE%\AppData\Roaming\.emacs.d\init.el

To be fair, if Windows had just one place to put files for user installed packages the solution of making HOME=%USERPROFILE\AppData\Roaming might be acceptable, but because some applications use %USERPROFILE%, some use %USERPROFILE\AppData\Roaming and others use %USERPROFILE\AppData\Local it just makes it difficult to know where to find your configuration files.

I prefer having everything in my %USERPROFILE% or $HOME directory.

Another similar question was here:


There is a list of directories based on your Windows version and extra information: http://www.gnu.org/software/emacs/manual/html_node/emacs/Windows-HOME.html


On Windows 8.1, if Emacs is started from Windows Explorer, a shortcut or from cmd console it uses C:\Users\<USER>\AppData\Roaming.emacs init file. When I start Emacs from PowerShell, Emacs looks for its init file in C:\Users\<USER> folder. The fix to this issue was to set the HOME user environment variable (Control Panel\System and Security\System->Advanced system settings->Advanced->Environment variables) to C:\Users\<USER>. After this change, no matter how I start Emacs, it uses the same init file (see the accepted answer of this question)

참고URL : https://stackoverflow.com/questions/189490/where-can-i-find-my-emacs-file-for-emacs-running-on-windows

반응형