1

我试图将以下内容放入my .emacs文件中。

(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)

它有效,但它也删除了我之前输入的所有命令。所以这不是我想要的。我只希望当前提示 > 在缓冲区的顶部,而不是删除我之前输入的任何命令。

有人知道吗?

4

3 回答 3

2

对我来说Esc-0 Ctr-l似乎工作。

`Ctrl-h k' 输出为:

C-l runs the command recenter-top-bottom,
which is an interactive compiled Lisp function in window.el'.

根据Emacs 手册中的这个页面

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). 
于 2013-01-13T08:45:58.957 回答
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)
)

编辑:或者也许这个?

(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)
)
于 2013-01-13T10:43:05.990 回答
0

有什么问题C-l C-l?它适用于任何缓冲区。

于 2013-01-14T10:53:10.593 回答