3

我经常在 Emacs 中使用 org-mode 来写长篇文章和论文章节,我一直发现自己很沮丧,因为我在章节大纲和全文之间没有中间视图。有谁知道包含某种可以轻松显示和隐藏的摘要(如点或一段文本)的好方法?

到目前为止,我尝试使用抽屉进行摘要。例如:

#+TITLE: My article
#+DRAWERS: SUMMARY

* Introduction
* Data and hypotheses
* Results
** First attempt
:SUMMARY:
My first attempt didn't work so well.
:END:

The text of the section goes here...
** Second attempt
:SUMMARY:
I still haven't started my second attempt.
:END:

我发现这很有效,因为摘要大部分是隐藏的,我只在需要时才看到它们。问题是我仍然无法通过这种方式获得摘要概述,在那里我可以看到每个部分的摘要并隐藏全文。

也许在 org-mode 中没有明显的解决方案,在这种情况下,我不反对写一个,但肯定其他人也有同样的需求,所以我想我会问其他人是否首先找到了解决方案。

4

2 回答 2

2

在这里,您可以找到问题中 :SUMMARY: 解决方案的快速而肮脏的扩展。

编辑:我添加了更好的帮助和一种包含org-summaryorg-shifttab操作中的方法。但是,您也可以将一些键绑定到org-summary.

(defun org-summary ()
  "Include :SUMMARY: drawer into heading if present.
You can use this drawer to write a summary.
As a pre-requisite you should include :SUMMARY: in `org-drawers':

\'(add-to-list 'org-drawers \"SUMMARY\")

 1. In your org-document put a line only containing :SUMMARY: on the line following the header.
 2. End the summary by a line starting with :END:.
 3. Leading indentation for :SUMMARY: and :END: is fine.
 4. The last line in the summary block must not be a blank line.
 5. The first non-blank character within summary lines must not be a colon `:'.

Example:

* I am the header
  :SUMMARY:
    And I am the summary.

    Spanning several lines including newlines.
    In this chapter the following topics are discussed:
    1. The world turns fast.
    2. We cannot always read everything we have written once.
    3. We need a summary.
  :END: Now, we will explain everything in full..."
  (interactive)
  (show-all)
  (let ((outline-heading-end-regexp "
\\([[:blank:]]*:SUMMARY:\\(
[[:blank:]]*[^:[:blank:]].*\\)*
[[:blank:]]*:END:\\)?"))
    (hide-body)
    ))

(add-to-list 'org-drawers "SUMMARY")

;; You can insert org-summary into org-cycle:
(defadvice org-shifttab (around summary activate)
  (if (and (boundp 'org-summary-cycle)
       (null org-summary-cycle)
       (eq org-cycle-global-status 'all))
      (progn
    (org-summary)
    (setq-local org-summary-cycle t)
    (message "SUMMARY")
    )
    ad-do-it
    (setq-local org-summary-cycle nil)))
于 2013-10-22T21:36:29.227 回答
0

我发现了一个邮件列表帖子,它描述了一个“概要视图”,听起来它会做你想做的事。看起来很简单:只需使用SYNOPSIS抽屉,然后使用此函数显示“概要视图”:

(defun k-synopsis-view ()
  "Show all headings (contents view) and, if any, their synopsis."
  (interactive)
  (save-excursion
    (goto-char (point-min))
    (hide-sublevels 1)
    (while (re-search-forward "\\(^[ \t]*:SYNOPSIS:[. \t]*$\\)" nil t)
      (org-flag-drawer nil)
      (re-search-forward "^[ \t]*:END:[ \t]*" nil t)
      (outline-flag-region (match-beginning 0) (match-end 0) t))
    (org-content)))
于 2015-08-29T18:21:23.963 回答