imenu can be used in org-mode to quickly jump to a heading. It first prompts for the 1st level heading, and then asks for the 2nd level heading and so on untill the selected heading has no subheading and we are then taken to that last selected heading.

しかし、私がむしろ好きなのは、すべての見出しのリストを表示し、行きたいものを直接選択できるようにする imenu です

  • より速くなる
  • 小見出しの見出しにジャンプすることができます。




ビュー: 6
本当にあなたの質問に答えるのではなく、簡単なナビゲーションオプションの提案です。 helm パッケージの helm-org-in-buffer-headings を使用してください。これにより、目的の見出しにインタラクティブに絞り込むことができ、見出しの階層パス全体が使用されます(レベルの数を設定できます)。これは私にとっては、見出しにジャンプする最も効率的な方法です。また、見出しにジャンプするだけでなく他のアクションを簡単に設定することもできます(クロッキング、再読み込みなど)
追加された 著者 Ross,

2 答え

imenu を使用する代わりに、 org-goto を次の 設定:

(setq org-goto-interface 'outline-path-completionp)
(setq org-outline-path-complete-in-steps nil)

,----[ C-h v org-goto-interface RET ]
| org-goto-interface is a variable defined in ‘org.el’.
| Its value is ‘outline-path-completionp’
| Original value was outline
| Documentation:
| The default interface to be used for ‘org-goto’.
| Allowed values are:
| outline                  The interface shows an outline of the relevant file
|                          and the correct heading is found by moving through
|                          the outline or by searching with incremental search.
| outline-path-completion  Headlines in the current buffer are offered via
|                          completion.  This is the interface also used by
|                          the refile command.
| You can customize this variable.
| [back]

,----[ C-h v org-outline-path-complete-in-steps RET ]
| org-outline-path-complete-in-steps is a variable defined in ‘org.el’.
| Its value is nil
| Original value was t
| Documentation:
| Non-nil means complete the outline path in hierarchical steps.
| When Org-mode uses the refile interface to select an outline path
| (see variable ‘org-refile-use-outline-path’), the completion of
| the path can be done in a single go, or it can be done in steps down
| the headline hierarchy.  Going in steps is probably the best if you
| do not use a special completion package like ‘ido’ or ‘icicles’.
| However, when using these packages, going in one step can be very
| fast, while still showing the whole path to the entry.
| You can customize this variable.
| [back]


;;; add func to perform imenu for all headings at one level
(defun org-imenu-get-heading ()
  "Produce the index for Imenu."
  (mapc (lambda (x) (move-marker x nil)) org-imenu-markers)
  (setq org-imenu-markers nil)
  (let* ((n org-imenu-depth)
         (re (concat "^" (org-get-limited-outline-regexp)))
         (subs (make-vector (1+ n) nil))
         m level head0 head)
        (goto-char (point-max))
        (while (re-search-backward re nil t)
          (setq level (org-reduced-level (funcall outline-level)))
          (when (and (<= level n)
                     (looking-at org-complex-heading-regexp)
                     (setq head0 (org-match-string-no-properties 4)))
            (setq head (org-link-display-format head0)
                  m (org-imenu-new-marker))
            (org-add-props head nil 'org-imenu-marker m 'org-imenu t)
            (push (cons head m) (aref subs 1))))))
    (aref subs 1)))

(advice-add #'org-imenu-get-tree :override #'org-imenu-get-heading)