All Projects → snosov1 → Toc Org

snosov1 / Toc Org

toc-org is an Emacs utility to have an up-to-date table of contents in the org files without exporting (useful primarily for readme files on GitHub)

Projects that are alternatives of or similar to Toc Org

Cheatsheet
Pretty cheat sheets, or ``reference cards'', obtainable from Org files.
Stars: ✭ 116 (-42.57%)
Mutual labels:  emacs, org-mode
Org Fragtog
Automatically toggle Org mode LaTeX fragment previews as the cursor enters and exits them
Stars: ✭ 149 (-26.24%)
Mutual labels:  emacs, org-mode
Walkman
Write HTTP requests in Org mode and replay them at will using cURL
Stars: ✭ 120 (-40.59%)
Mutual labels:  emacs, org-mode
Weblorg
Static Site Generator for Emacs
Stars: ✭ 103 (-49.01%)
Mutual labels:  emacs, org-mode
Org Pdftools
A custom org link type for pdf-tools
Stars: ✭ 165 (-18.32%)
Mutual labels:  emacs, org-mode
Org Brain
Org-mode wiki + concept-mapping
Stars: ✭ 1,512 (+648.51%)
Mutual labels:  emacs, org-mode
Org Graph View
View Org buffers as a clickable, graphical mind-map
Stars: ✭ 141 (-30.2%)
Mutual labels:  emacs, org-mode
Ox Jira.el
Org-mode export backend for JIRA markup
Stars: ✭ 88 (-56.44%)
Mutual labels:  emacs, org-mode
Hexo Renderer Org
Hexo renderer plugin for emacs org-mode
Stars: ✭ 157 (-22.28%)
Mutual labels:  emacs, org-mode
Org Msg
OrgMsg is a GNU/Emacs global minor mode mixing up Org mode and Message mode to compose and reply to emails in a Outlook HTML friendly style.
Stars: ✭ 153 (-24.26%)
Mutual labels:  emacs, org-mode
Ox Rst
reStructuredText Back-End for Org-Mode Export Engine
Stars: ✭ 94 (-53.47%)
Mutual labels:  emacs, org-mode
Go Org
Org mode parser with html & pretty printed org rendering. also shitty static site generator.
Stars: ✭ 177 (-12.38%)
Mutual labels:  emacs, org-mode
Organice
An implementation of Org mode without the dependency of Emacs - built for mobile and desktop browsers
Stars: ✭ 1,327 (+556.93%)
Mutual labels:  emacs, org-mode
Emacs Gtd
Get Things Done with Emacs
Stars: ✭ 111 (-45.05%)
Mutual labels:  emacs, org-mode
Eless
A Better 'less' - A bash script that loads emacs with minimal view-mode config - Created with Org mode
Stars: ✭ 94 (-53.47%)
Mutual labels:  emacs, org-mode
Novels.org
Novels.org - Your Novels in Plain Text (Emacs . org-mode)
Stars: ✭ 120 (-40.59%)
Mutual labels:  emacs, org-mode
Emagicians Starter Kit
🐰 My own take on an Emacs Starter Kit, with Secret Alien Org Mode Superpowers. -|-+-|-
Stars: ✭ 85 (-57.92%)
Mutual labels:  emacs, org-mode
Fundamental Haskell
Fundamental Haskell book, to the point terse statements on Haskell, Category theory, and related fields. Encyclopedic pocketbook of meaning. Zen kōan-like meditations of understanding. For quick or memory curve spaced repetition learning.
Stars: ✭ 88 (-56.44%)
Mutual labels:  emacs, org-mode
Writingwithemacs
Tips, Examples, and Resources for Writing with Emacs
Stars: ✭ 150 (-25.74%)
Mutual labels:  emacs, org-mode
Orgro
An org-mode file viewer for iOS and Android
Stars: ✭ 175 (-13.37%)
Mutual labels:  emacs, org-mode

[[https://travis-ci.org/snosov1/toc-org][file:https://api.travis-ci.org/snosov1/toc-org.svg?branch=master]]

  • About

=toc-org= helps you to have an up-to-date table of contents in org files without exporting (useful primarily for readme files on GitHub).

It is similar to the [[https://github.com/ardumont/markdown-toc][markdown-toc]] package, but works for org files. Since recently, =toc-org=, actually, works in [[#markdown-support][markdown]], too!

NOTE: Previous name of the package is =org-toc=. It was changed because of a name conflict with one of the org contrib modules.

  • Table of Contents :TOC:QUOTE: #+BEGIN_QUOTE
  • [[#about][About]]
  • [[#installation][Installation]]
    • [[#via-packageel][via package.el]]
    • [[#manual][Manual]]
  • [[#use][Use]]
    • [[#follow-links][Follow links]]
    • [[#exclude-headings][Exclude headings]]
    • [[#quote-table-of-contents][Quote table of contents]]
    • [[#shortcut-for-toc-tag][Shortcut for TOC tag]]
  • [[#markdown-support][Markdown support]]
  • [[#different-href-styles][Different href styles]]
  • [[#example][Example]] #+END_QUOTE
  • Installation ** via package.el

[[http://melpa.org/#/toc-org][file:http://melpa.org/packages/toc-org-badge.svg]]

This is the simplest method if you have the package.el module (built-in since Emacs 24.1) you can simply use =M-x package-install= after setting up the [[http://melpa.org/#/getting-started][MELPA]] repository and then put the following snippet in your ~/.emacs file

#+BEGIN_SRC elisp (if (require 'toc-org nil t) (add-hook 'org-mode-hook 'toc-org-mode)

  ;; enable in markdown, too
  (add-hook 'markdown-mode-hook 'toc-org-mode)
  (define-key markdown-mode-map (kbd "\C-c\C-o") 'toc-org-markdown-follow-thing-at-point))
(warn "toc-org not found"))

#+END_SRC

** Manual

  • Create folder ~/.emacs.d if you don't have it

  • Go to it and clone toc-org there #+BEGIN_SRC sh git clone https://github.com/snosov1/toc-org.git #+END_SRC

  • Put this in your /.emacs file #+BEGIN_SRC elisp (add-to-list 'load-path "/.emacs.d/toc-org") (if (require 'toc-org nil t) (add-hook 'org-mode-hook 'toc-org-mode)

      ;; enable in markdown, too
      (add-hook 'markdown-mode-hook 'toc-org-mode)
      (define-key markdown-mode-map (kbd "\C-c\C-o") 'toc-org-markdown-follow-thing-at-point))
    (warn "toc-org not found"))
    

    #+END_SRC

  • Use

After the installation, every time you'll be saving an org file, the first headline with a =:TOC:= tag will be updated with the current table of contents.

To add a TOC tag, you can use the command =org-set-tags-command= (=C-c C-q=).

In addition to the simple :TOC: tag, you can also use the following tag formats:

  • :TOC_2: - sets the max depth of the headlines in the table of contents to 2 (the default)

  • :TOC_2_gh: - sets the max depth as in above and also uses the GitHub-style hrefs in the table of contents (this style is default). The other supported href style is 'org', which is the default org style.

You can also use [email protected]= as separator, instead of =_=.

It's possible to set the default values of max depth and hrefify function with =toc-org-max-depth= and =toc-org-hrefify-default= variables. But, note, that if you do this outside of the org file itself, then you can face conflicts if you work on the same file collaboratively with someone else, as your default configs can vary.

** Follow links

If you call =M-x org-open-at-point= (=C-c C-o=) when you're at a TOC entry, the point will jump to the corresponding heading.

Notice, that this functionality exploits the =org-link-translation-function= variable. So, it won't work if you use this variable for other purposes (i.e. it is not nil).

You can manually disable this functionality by setting =toc-org-enable-links-opening= to nil.

** Exclude headings

Headings tagged with =:noexport:= will be excluded from the TOC. If you want to preserve the heading, but strip its children (for changelog entries, for example), you can tag it =:noexport_1:= (by analogy, you can use =:noexport_2:=, =:noexport_3:=, etc. for children of deeper levels). Note, though, =:noexport:= has a similar meaning in =org-mode=, which I hope is a Good Thing (tm). However, =:noexport_1:= and friends won't be recognized by =org-mode= as anything special. Look at =org-export-exclude-tags= variable for more details.

** Quote table of contents

For presentation purposes, you might want to put the table of contents in a quote block (i.e. =#+BEGIN_QUOTE= / =#+END_QUOTE=). In that case, GitHub, for example, will add a vertical line to the left of the TOC that makes it distinct from the main text. To do this, just add a =:QUOTE:= tag to the TOC heading.

** Shortcut for TOC tag

In your emacs' setup, you can bind a tag =:TOC:= to a binding =T=:

#+BEGIN_SRC emacs-lisp (add-to-list 'org-tag-alist '("TOC" . ?T)) #+END_SRC

Now =C-c C-q T RET= and you are done putting the =:TOC:= entry.

  • Markdown support

You can also enable the mode in Markdown files and get pretty much the same functionality. The package will

  1. Look for '#'s instead of '*'s as heading markers.
  2. Expect the =:TOC:= tag to appear as comment, like, =<-- :TOC: -->=
  3. Format the links and the quote block according to Markdown syntax

Example:

#+BEGIN_SRC markdown

About

Table of Contents <-- :TOC: -->

Installation

via package.el

Manual

Use

Example

#+END_SRC

  • Different href styles

Currently, only 2 href styles are supported: =gh= and =org=. You can easily define your own styles. If you use the tag =:TOC_2_STYLE:= (=STYLE= being a style name), then the package will look for a function named =toc-org-hrefify-STYLE=.

It should accept a heading string and a hash table of previously generated hrefs. The table can be used to maintain href uniqueness (see =toc-org-hrefify-gh=, for example). Return value should be a href corresponding to that heading.

E.g. for =org= style it makes links to be the same as their visible text:

#+BEGIN_SRC emacs-lisp (defun toc-org-hrefify-org (str &optional hash) "Given a heading, transform it into a href using the org-mode rules." (toc-org-format-visible-link str)) #+END_SRC

  • Example #+BEGIN_SRC org

    • About
    • Table of Contents :TOC:
    • [[#about][About]]
    • [[#installation][Installation]]
      • [[#via-packageel][via package.el]]
      • [[#manual][Manual]]
    • [[#use][Use]]
    • [[#example][Example]]
    • Installation ** via package.el ** Manual
    • Use
    • Example #+END_SRC
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].