elisp - 从 Lisp 调用 org-content 不起作用

标签 elisp org-mode

当我从事件缓冲区调用 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)

窗口 split ,右侧缓冲区被加载,但组织内容位似乎没有做任何事情。 对我做错了什么有什么想法吗?

谢谢

乔克

最佳答案

这是一个可重现的示例,打开一个名为 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) 满意。

关于elisp - 从 Lisp 调用 org-content 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58408339/

相关文章:

org-mode - 组织模式 : How to schedule repeating tasks for the first Saturday of every month?

bash - 我如何在 org babel 中加载 bash(而不是 sh)以启用 #+BEGIN_SRC bash?

org-mode - 以 cweb 或 noweb 样式导出代码块名称?

emacs - 如何在 emacs minibuffer 中模拟返回

emacs - 在 Emacs bibtex-mode 中重新定义段落开头和段落分隔

emacs latex Hook 未运行

emacs - 在 org-mode 的代码块中有基本的自动缩进

emacs - 如何摆脱 emacs 错误 "void-variable org-format-latex-options"?

unix - 在emacs中打开时如何自动解压缩自定义压缩文件?

datetime - 如何使用Emacs Lisp在Emacs中添加日期?