2014-12-13 1 views
1

Emacs newbie here. 메이크 파일을 열 때 분할 창에서 eshell을 시작하고 싶습니다.Emacs가 예기치 않게 버퍼를 스크래치 버퍼로 바꾼다.

(add-hook 
    'makefile-mode-hook 
    (lambda() 
    (progn 
     (split-window-right 110) 
     (other-window 1) 
     (eshell) 
     (other-window 1)))) 

나는 계획, 그러나 이유 스크래치 버퍼에 메이크에서 내 원래 버퍼 스위치, 알 수없는로 eshell을 얻을 : 그래서 내 .emacs에 다음을 추가했다. 왜 이런거야? 또한

, 나는 eshell 호출하고 마지막으로 "다른 창"을 떠나면, 난 여전히 스크래치 버퍼를 얻을.

답변

0

내가 방금 요리 한이 코드를보십시오 :

(add-hook 'window-configuration-change-hook 
      'makefile-open-eshell) 

(defvar makefile-eshell-in-progress nil) 

(defun makefile-open-eshell() 
    (interactive) 
    (unless makefile-eshell-in-progress 
    (when (memq major-mode 
       '(makefile-mode makefile-gmake-mode)) 
     (let ((dir (file-name-directory (buffer-file-name))) 
      (window (cl-find-if 
        (lambda (window) 
         (with-current-buffer (window-buffer window) 
         (eq major-mode 'eshell-mode))) 
        (window-list)))) 
     (if window 
      (with-current-buffer (window-buffer window) 
       (unless (file-equal-p dir (eshell/pwd)) 
       (eshell/cd dir) 
       (eshell-send-input))) 
      (let ((makefile-eshell-in-progress t)) 
      ;; (delete-other-windows) 
      (split-window-right) 
      (other-window 1) 
      (eshell) 
      (eshell/cd dir) 
      (eshell-send-input) 
      (other-window -1))))))) 

당신이 메이크로 전환 할 때 항상 적절한 eshell을 열어야합니다.

사용이 광기 정지 : 이것은 시작에 작동

(remove-hook 'window-configuration-change-hook 
      'makefile-open-eshell) 
+0

을하지만, eshell에서 때이 종료 eshell 창을 분할 또는 버퍼 (바람직하지 않은 행동을) 죽이려하고, 더 중요한 것은 내가 아직 왜 이것이 작동하는지 또는 왜 내 오리지널 버전이 그런지 알지 못합니다. –

+0

이 코드의 Makefile 전에 eshell을 죽이지 않아도됩니다. 어쨌든 질문에 대한 답은'(other-window -1)'입니다. –

+0

'other-window -1'이 도움이되지 않습니다. 사물을 명확히하기 위해 파일을 열어 분할 창에 셸을 넣을 수 있기를 바랄뿐입니다. 그보다 더 기발한 것도 필요하지 않습니다. –

관련 문제