首页 > 解决方案 > 从 lisp 调用 org-content 不起作用

问题描述

当我从活动缓冲区调用 org-content 时,我得到了我想要的大纲。但是,如果我在这样的 lisp 函数中使用它

(split-window-right (truncate (* W 0.75)))
    (if (get-buffer "inbox.org")
        (set-window-buffer nil "inbox.org")
      (progn
        (find-file "~/Documents/GTD/inbox.org")
        (text-scale-set -1)))
    (org-content)

窗口拆分并加载了正确的缓冲区,但 org-content 位似乎没有做任何事情。关于我做错了什么的任何想法?

谢谢,

约克

标签: elisporg-mode

解决方案


这是一个可重现的示例,打开一个名为的新缓冲区test.org并在缓冲区中定义以下函数*scratch*

(defun test ()
  (let ((buffer (get-buffer "test.org")))
    (when buffer
      (set-window-buffer nil buffer)
      (message "%s" (current-buffer)))))

输出的消息是*scratch*:只有与窗口关联的缓冲区被更改,但 Emacs 认为当前缓冲区没有。

如果改为使用switch-to-buffer,如下所示,消息将显示选定的缓冲区:

(defun test ()
  (let ((buffer (get-buffer "test.org")))
    (when buffer
      (switch-to-buffer buffer)
      (message "%s" (current-buffer)))))

将相同的更改应用于您的代码会(org-content)很开心。


推荐阅读