2013-01-13 6 views
1

my .emacs 파일에 다음을 넣으려고했습니다.R 콘솔의 Control + L과 마찬가지로 ESS의 버퍼 맨 위에서 R의 현재 프롬프트를 만드는 방법

(defun clear-shell() 
    (interactive) 
    (let ((old-max comint-buffer-maximum-size)) 
    (setq comint-buffer-maximum-size 0) 
    (comint-truncate-buffer) 
    (setq comint-buffer-maximum-size old-max))) 
(global-set-key (kbd "\C-x c") 'clear-shell) 

효과가 있지만 이전에 입력 한 명령도 모두 제거됩니다. 그래서 내가 원하는 것이 아닙니다. 나는 단지 현재 프롬프트를 버퍼의 맨 위에두고 전에 입력 한 명령을 삭제하지 않기를 원합니다.

아는 사람 있습니까?

+0

코드의'let' 부분은'(let ((comint-buffer-maximum-size 0)) (comint-truncate-buffer))'로 다시 쓸 수 있습니다. – Stefan

답변

2

나를 위해 Esc-0 Ctr-l가 작동하는 것처럼 보입니다.

`Ctrl 키-H K '출력은 다음과 같습니다

는 이맥스 설명서에서 this page에 따르면
C-l runs the command recenter-top-bottom, 
which is an interactive compiled Lisp function in window.el'. 

이 보인다

Scroll the selected window so the current line is the 
center-most text line; on subsequent consecutive invocations, 
make the current line the top line, the bottom line, and so on in 
cyclic order. Possibly redisplay the screen too (recenter-top-bottom). 
+1

Meta-0 Ctrl-l입니까? – PascalVKooten

+0

아니, 제 경우에는 말 그대로'Esc'입니다. [편집]하지만 네,'M-0 Ctrl-l'도 작동합니다. – SlowLearner

+0

나를 위해 작동하지 않습니다 ...하지만 어쩌면 OP. 해당 명령에 바인딩 된 것은 무엇입니까? – PascalVKooten

0

는이 작업 수행에 (실제로 정말 확실하지 않다하지만 이것이 당신이 무엇인지 알고 있다면) :

(defun clean-shell() 
(interactive) 

; if you call this from your .r script, it will switch to the next window 
(when (eq major-mode 'ess-mode) (other-window 1)) 

(mark-whole-buffer) 
(exchange-point-and-mark) 
(move-beginning-of-line 1) 
(delete-region (region-beginning) (region-end)) 
(end-of-line) 
) 

EDIT : 아니면 이거?

(defun clean-shell() 
(interactive) 
(when (eq major-mode 'ess-mode) (other-window 1)) 
(mark-whole-buffer) 
(exchange-point-and-mark) 
(move-beginning-of-line 0) 
(delete-region (region-beginning) (region-end)) 
(end-of-line) 
) 
+0

답변 해 주셔서 감사합니다. 그러나 그것은 내가 겪은 것이 아닙니다. 어쩌면 나는 분명히 밝히지 않았을 것입니다. 제공 한 명령을 실행할 때 프롬프트가 버퍼의 맨 위로 돌아 왔지만 명령을 실행하기 전에 입력 한 명령을 볼 수 없습니다. 다른 말로. clean-shell을 실행 한 후 프롬프트의 행 번호는 1입니다. 그러나 나는 깨끗한 껍데기를 달기 전에 그것을 똑같이 바라고 있습니다. 감사. – Negelis

+0

그럼 정확히 정리해야 할 것은 무엇입니까? – PascalVKooten

+0

이것을 실행하고 마지막 행에 무언가를 입력했으면이 정리 후에도 계속있을 것입니다. 아니면 그 일이 그곳에 있기를 원했습니까? 그래서, 마지막 것이 있어야할까요? – PascalVKooten

0

C-1의 C-1 어떤 문제가 있습니까? 모든 버퍼에서 작동합니다.

+0

"recenter-positions"을 바꾸면 그렇지 않습니다. 그리고 실제로 아무것도 삭제하지 않는다는 사실을 말하는 것이 아닙니다. – desudesudesu