本文介绍了在Emacs Lisp功能中拆分窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够在我正在编辑的当前文件上运行一个shell命令,并将输出显示在 Shell命令输出窗口中。我已经能够定义
函数,如下所示。

I'd like to be able to run a shell command on the current file that I'm editing and have the output be shown in the Shell Command Output window. I've been able to define thefunction which is shown below.

(defun cpp-check ()
  "Run cpp-check on current file the buffer is visiting."
  (shell-command
   (concat "/home/sburke/downloads/cppcheck-1.31/cppcheck "
       (buffer-file-name))))

唯一的问题是输出窗口没有带以任何方式到前台。我想要发生的是窗口被拆分,输出窗口显示在那里。此外,我在正确的轨道上定义要放在我的.emacs文件中的功能还是有更好的方法?

The only problem is that the output window isn't brought to the foreground in any way. What I'd like to happen is for the window to be split and the output window shown there. Also, am I on the right track here defining the function to be put in my .emacs file or is there a better way?

任何帮助将不胜感激。谢谢。

Any help would be appreciated. Thanks.

推荐答案

这是我想出来的。感谢您的回应。我定义了一个将继续执行cpp-check的功能。我想要它绑定在c模式的一个键,所以我把它添加为一个钩子。我遇到了正常功能和可以绑定到键盘映射的区别,所以我必须使功能交互。这个有助于解释。所以现在当按下快捷方式时,结果会在另一个窗口中出现,但光标仍保留在原始缓冲区中,这就是我想要的。唯一的问题是输出显示在minibuffer中,这不是我想要的。关于修改这个细节的任何想法?

This is what I came up with. Thanks for the responses. I defined a function that will go ahead and run cpp-check. I wanted it bound to a key in c-mode so I add it as a hook. I ran into the difference between normal functions and ones that can be bound to keymaps so I had to make the function interactive. This article helped explain that. So now when the shortcut is pressed the results come up in another window, but the cursor remains in the original buffer, which is what I want. The only problem is that the output is shown in the minibuffer as well which isn't quite what I want. Any thoughts on fixing that little detail?

(defun cpp-check ()
  (interactive)
  "Run cpp-check on current file the buffer is visiting."
  (shell-command
   (concat "/home/sburke/downloads/cppcheck-1.31/cppcheck "
       (buffer-file-name)))
  (display-buffer "*Shell Command Output*"))

(add-hook 'c-mode-common-hook
           (lambda ()
         (define-key c-mode-base-map
               "\C-x\p" 'cpp-check)))

这篇关于在Emacs Lisp功能中拆分窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 09:26