【问题标题】:How to move to end of temporary buffer in emacs inside function如何在emacs内部函数中移动到临时缓冲区的末尾
【发布时间】:2014-06-12 15:58:43
【问题描述】:

我正在尝试编写一个 emacs 函数,它将在当前目录中运行 make,切换到另一个目录并运行 make link,同时将文本输出到名为 ma​​ke-output的新缓冲区>(原创,嗯?)。完成后,我想移动到 ma​​ke-output 缓冲区的 end,以便查看编译是否成功。这是我目前所拥有的:

(defun remake-libefp-interface()
  "Will run make in the current directory, change to the NWChem src directory and relink the binary."
  (interactive)
  (defvar T_pwd (getenv "PWD"))
  (defvar T_top (concat (getenv "NWCHEM_TOP") "/src"))
  (defvar cmd (concat "make; cd " T_top "; make link;cd " T_pwd))
  (with-output-to-temp-buffer "*make-output*"
    (shell-command cmd "*make-output*")
    (pop-to-buffer "*make-output*")
    (end-of-buffer)))

这可以正确重新编译,但在 ma​​ke-outputbeginninng 处转储我。我也试过用(goto-char (point-max))替换(end-of-buffer),但这也让我一开始就离开了。

【问题讨论】:

  • (compile (concat "make; cd " T_top "; make link;cd " T_pwd)) 会做你想做的事吗?
  • 是的。这与(setq compliation-scroll-output t) 结合使用可以更好地完成我想要完成的工作,因为它是彩色编码的。谢谢你的提示。我将 Drew 的回复标记为答案,因为它在技术上回答了我提出的问题,但您的回复更有助于实现我想要的。
  • 在程序中,不要使用命令(缓冲区结束),这可能会减慢它的速度。使用 (goto-char (point-max))

标签: emacs elisp buffer


【解决方案1】:

pop-to-buffer(goto-char (point-max)) 移到with-output-to-temp-buffer 之外。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-01-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多