Emacs, 시작시 여러 창 열기 상단 창에서 emacs

이맥스를 시작할 때 4 개의 창을 표시하고 각 창 안에는 .emacs 파일에 버퍼를 지정하고 싶습니다. 아마 왼쪽 상단 창에서 emacs 웹 브라우저 w3m이 나타나고, 오른쪽 상단 창에 파이썬 인터프리터가 나타나고, 왼쪽 아래 창, 마지막으로 사용한 창이 나타납니다. 그리고 오른쪽 아래 창에는 빈 버퍼가 나타납니다.

  1. 어떻게하면 .emacs 파일에 대해 elisp에이 기능을 쓸 수 있습니까?
  2. 이 질문에 답하기 위해이 정보를 어디에서 찾았습니까? 이맥스 도움말 페이지를 사용 했습니까?

모든 도움을 주시면 대단히 감사하겠습니다!



답변

여러분이 요구하는 기능은 Emacs 사용자들 사이에 공통된 요구입니다. 좋은 소식은 원하는대로 할 수있는 기존 패키지가 많이 있다는 것입니다. 내가 가장 좋아하는 것은 workgroups.el이다. 그것은 놀랍도록 강력합니다. ELPA로 설치할 수 있습니다. 여기에 훌륭한 readme와 함께 GitHub 저장소가 있습니다. 전체 패키지는 비정상적으로 잘 문서화되어 있습니다.

https://github.com/tlh/workgroups.el

비록 당신이 윈도우와 버퍼 조작을 코딩하는 법을 배우고 싶다고하더라도, 기존 패키지를 연구함으로써 더 빠르고 더 나은 스타일을 배우게 될 것이라고 생각합니다.


답변

감사의 말

나는 다음 페이지에서 발견 한 것들로부터 해결책을 모았다.

노트

  • 사용중인 운영 체제를 지정하지 않았습니다. 나는 그것이 * nix의 맛이라고 생각할 것이다. 틀 렸으면 말해줘. Windows를 사용하는 경우에도 .emacs 비틀기 나는 제안하고 있지만 해결 방법을 사용할 수 없습니다 (아래 참조).

  • 내 솔루션로드 emacs 4 개의 열린 창문, w3m 왼쪽 상단에 Google, 오른쪽 상단에 파이썬 셸, 왼쪽 하단에 마지막으로 열린 파일 및 비어있는 파일 표시 scratch 오른쪽 하단에 버퍼. 시작하면 제대로 작동합니다. emacs 명령 줄에서 직접 파일을 열면 인수가 없지만 레이아웃이 깨집니다.

    emacs foo.txt
    
  • 따라서 파일 이름을 지정하지 않은 경우에만 레이아웃을로드하는 해결 방법을 제안합니다. 항상 4 윈도우 레이아웃을로드하고 싶다면 아래의 lisp 라인을 직접 추가하면된다. ~/.emacs 새 파일을 만드는 대신 .

  • 직접 선을 추가하기로 결정한 경우 ~/.emacs 파일을 만들 때는 다음 명령을주의하십시오.

    ;; Set the max number of recent files kept
    (custom-set-variables
     '(recentf-max-saved-items 10)
    '(inhibit-startup-screen t))
    

    하나만있을 수 있습니다. custom-set-variables 섹션 .emacs 파일을 추가하여 파일에 추가하는 대신 기존 custom-set-variables 변수를 추가하기 만하면됩니다.

    '(recentf-max-saved-items 10)
    

대답

다음 위치에 파일을 만듭니다. $HOME 전화 한 .my_emacs_layout 이 줄이 포함되어 있거나 (또는 ~/.emacs 파일, 위의 노트 참조) :

;; Activate recentf mode to get the list of
;; recent files
(recentf-mode 1)

;; Load the w3m browser, change this to the location of your `w3m` install.
;; You should be able to copy the relevant lines from your `~/.emacs`.
(add-to-list 'load-path "~/.emacs-lisp/emacs-w3m")
(require 'w3m-load)

;; Set the max number of recent files kept
(custom-set-variables
 '(recentf-max-saved-items 10)
'(inhibit-startup-screen t))
;; Set up initial window layout.
(split-window-horizontally)
;; Open w3m in the main window, this
;; will be the top left
(w3m-goto-url "www.superuser.com")

;; Split the left window vertically
(split-window-vertically)

;; switch to the bottom left window
(other-window 1)
;; and load the most recent file
(recentf-open-most-recent-file 1)

;; I am sure there is a better way of doing this
;; but for some reason opening the python shell screws
;; around with the window focus and this ugly hack is
;; the best I could come up with.
(other-window 1)
(split-window-vertically)
(other-window 1)
(other-window 1)
(other-window 1)
;; open the python shell in what will be
;; the top right window
(py-shell)

그게 전부입니다. 이제 새로운 emacs 런칭으로 레이아웃

emacs -l ~/.my_emacs_layout

해결 방법

정상을로드하려면 emacs 명시 적으로 파일을 열고 단순히 실행하는 경우 4 창 레이아웃을로드 할 때 세션 emacs,이 라인을 쉘의 설정 파일에 추가하십시오 ( ~/.bashrc bash를 사용하는 경우) :

function emacs(){
 if [ $# -eq 0 ]
 then
     /usr/bin/emacs -l ~/.my_emacs_layout
  else
     /usr/bin/emacs "$@"
 fi
}