richardwesthaver / org-notion

Notion.so integration with Emacs Org-mode using the official API
76 stars 4 forks source link

+TITLE: org-notion

+DATE: 2023-07-12

+DESCRIPTION: Notion.so Org-mode Extension

+AUTHOR: ellis

+EMAIL: ellis@rwest.io

[[https://www.notion.so][Notion]] is a web-based application with a similar purpose. It works well on all platforms and has some cool features including databases, realtime collaboration, and as of 2021 an [[https://developers.notion.com/][official API]].

=org-notion= is an Emacs package that uses this API to integrate the beauty of Notion with your Org-mode workflow.

** Status

All classes are shown below. There's an abstract =org-notion-class= which all classes inherit as well as a special =org-notion-cache= class which stores a cache of =org-notion-object= instances.

+begin_example

org-notion-class
+--org-notion-request
+--org-notion-cache
+--org-notion-object
| +--org-notion-block
| +--org-notion-page
| +--org-notion-database
| +--org-notion-user
+--org-notion-rich-text
| +--org-notion-inline-equation
| +--org-notion-inline-mention
| +--org-notion-inline-text

+end_example

The parsing is achieved with the help of [[https://orgmode.org/worg/dev/org-element-api.html][org-element]] and [[https://github.com/emacs-mirror/emacs/blob/master/lisp/json.el][json.el]]. An =org-notion-mode= minor-mode is provided for interacting with the API from an Org buffer and custom properties are used to keep headlines/files in sync with their Notion counterparts.

and make sure your =load-path= is setup correctly in your config:

+begin_src emacs-lisp

(add-to-list 'load-path "/path/to/org-notion")

+end_src

Now you can load the package with:

+begin_src emacs-lisp

(require 'org-notion)

+end_src

This package will be uploaded to MELPA upon reaching v1.0.0.

When running a command for the first time such as =org-notion-get-users= you will be prompted for your token. This is cached internally for future calls but will not persist across sessions (after restarting the emacs daemon).

The default behavior is to first check with [[https://www.gnu.org/software/emacs/manual/html_mono/auth/index.html][auth-sources]] before sending requests (=~/.authinfo= or =~/.authinfo.gpg=). This is highly recommended as it avoids the prompt and is more secure. You can disable the check if you wish to temporarily use a different token with =(setq org-notion-check-auth-source nil)=.

+begin_src emacs-lisp

(add-hook 'org-mode-hook #'org-notion-mode)

+end_src

You can customize the keymap =org-notion-mode-map= to your liking. The defauls are show below.

+tblname: org-notion-mode-map

| key | function | description | |-----------+---------------------+---------------------------------| | C-c n p | org-notion-push | Push local changes to Notion | | C-c n f | org-notion-pull | Pull remote changes from Notion | | C-c n o | org-notion-browse | Open Notion page in browser | | C-c n r s | org-notion-search | Search Notion | | C-c n r u | org-notion-get-user | Get Notion Users |