library.org

beorg uses the Scheme interpreter BiwaScheme to provide a way to offer advanced customization of the app.

When beorg starts the file library.org, which is bundled with the app, is read. If you have created a file in beorg called init then that will be read immediately afterwards. By reading library.org you can familiarize yourself with the possibilities for customizing beorg.

Here is the contents of library.org (updated 2019-11-14).

* Utility functions
#+begin_src scheme
  ;; Emacs Lisp like defvar
  (define documentation-table (make-hashtable equal-hash equal?))
  (define-macro (defvar name initial-value docstring)
    `(begin (define ,name ,initial-value)
            (hashtable-set! documentation-table ',name ,docstring)))
  ;; Emacs Lisp like defun
  (define interactive-table (make-hashtable equal-hash equal?))
  (define-macro (defun name args docstring interactive body)
    `(begin (define ,name (lambda ,args ,body))
            (hashtable-set! documentation-table ',name ,docstring)
            (hashtable-set! interactive-table ',name ,interactive)))
  (define (documentation name)
    (hashtable-ref documentation-table name "No documentation available."))

  ;; Some other useful Emacs Lisp like functions
  (define (1+ value) (+ 1 value))
  (define (1- value) (- value 1))

  ;; Redefine some functions which don't make sense on iOS
  (define (sleep timeout) "Sleep is not supported in beorg.")
  (define (timer proc sec) "Timers are not supported in beorg.")

  ;; Keyboard shortcuts
  (define key-table (make-hashtable equal-hash equal?))
  (define (define-key scope shortcut command)
    (let ((current-shortcuts (hashtable-ref key-table scope '())))
      (hashtable-set! key-table
                      scope
                      (append (list (list shortcut command)) current-shortcuts))))
  (define (keys-in-scope scope) (hashtable-ref key-table scope '()))
  (define command-title-table (make-hashtable equal-hash equal?))
  (define (define-command-title command title)
    (hashtable-set! command-title-table command title))
  (define (title-for-command command) (hashtable-ref command-title-table command #f))
#+end_src

* Items
An item (task) is represented by an association list. Here are some helper functions to extract values.
#+begin_src scheme
  (define (item-file item)
    (cadr (assoc 'file item)))
  (define (item-headline item)
    (cadr (assoc 'headline item)))
  (define (item-state item)
    (cadr (assoc 'state item)))
  (define (item-priority item)
    (cadr (assoc 'priority item)))
  (define (item-scheduled item)
    (cadr (assoc 'scheduled item)))
  (define (item-deadline item)
    (cadr (assoc 'deadline item)))
  (define (item-active-date item)
    (cadr (assoc 'active-date item)))
  (define (item-overdue item)
    (cadr (assoc 'overdue item)))
  (define (item-tags item)
    (cadr (assoc 'tags item)))
  (define (item-inherited-tags item)
    (cadr (assoc 'inherited-tags item)))
  (define (item-all-tags item)
    (append (item-tags item) (item-inherited-tags item)))
  ;; If an item doesn't have a properties drawer then it will be an empty list
  (define (item-properties item)
    (cadr (assoc 'properties item)))
  ;; Return the value of property from item's property drawer or an empty string is it doesn't exist
  (define (item-property item property)
    (let ((pair (assoc property (cadr (assoc 'properties item)))))
      (if pair (cadr pair) "")))
  ;; If item is a calendar event then item-is-file will return #f
  (define (item-is-file item)
    (not (string=? (item-file item) "")))
  ;; Convenience functions to get effort from an item
  (define (effort->minutes effort)
    (let* ((components (string-split effort ":"))
           (hours (* 60 (string->number (car components))))
           (minutes (string->number (cadr components))))
      (+ hours minutes)))
  (define (item-effort item) (effort->minutes (item-property item "Effort")))
#+end_src

Available priorities as a list. Each list item should be just a single uppercase letter.

#+begin_src scheme
  (defvar org-priorities '("A" "B" "C" "D" "E" "F")
    "A list of priorites from which the user can select. The order here is how they will be displayed, but don't affect the order when creating the agenda.")
#+end_src

#+begin_src scheme
  (defvar org-use-tag-inheritance #t
    "Whether or not tags are inherited for the purposes of search and filter. By default this is true.")
#+end_src

#+begin_src scheme
  (defvar org-log-done 'time
    "What to do when the state of an item is changed to a done state. This can be either 'time (to add a CLOSED line with a timestamp) or #f")

  (defvar org-log-repeat 'time
    "What to do when the state of a repeated item is changed to a done state. This can be either 'time (to log the state change) before going back to a todo state or #f")

  (defvar org-log-into-drawer #f
    "The name of the drawer to log state changes and clock/timer entries to. If set to #f then don't log state changes into a drawer. A sensible name for this is LOGBOOK.")
#+end_src

#+begin_src scheme
  (defvar org-todo-action-keywords '()
    "A list of keywords to use for TODO action states. If empty then the value entered on the Settings tab is used.")
    
  (defvar org-todo-done-keywords '()
    "A list of keywords to use for TODO done states. If empty then the value entered on the Settings tab is used.")
#+end_src

An item template can be applied when quick capture is initiated within beorg itself (i.e. not via the extension).
In the future a user interface will be implemented to allow easier definition of these templates.

#+begin_src scheme
  (defvar item-templates () "List of pairs, first item in pair is template name followed by template definition. Templates can also be defined using a beorg extension.")

  (defvar template-allow-spec-in-url-scheme #f "If #t then the template parameter in the capture URL scheme can specify the template parameters and not just an existing template")

  (define template-text-toolbar-items '(("icon-left" (backward-char))
                                        ("icon-right" (forward-char))
                                        ("icon-change" (show-transform-commands))))

  (define template-date-toolbar-items '(("icon-help" (alert "Help" "In most cases the toolbar buttons will insert what is needed. The minimum required to specify a date is a number of days from today. For example, 0 is today. If you want tomorrow then type 1. Optionally this number can be followed by a unit - h (for hour), d (for day), m (for month), y (for year). If you want a date+time for 1 hour for now then enter 1h.\n\nAfter the relative number of hours/days/etc from now has been entered you can optionally provide a flag to say that the time should be included. For example 1t (or 1dt) means in exactly one day from now, i.e. the time is also included.\n\nFinally you can specify an absolute time. For example, 1t1300 means tomorrow at 1pm."))
                                        ("icon-left" (backward-char))
                                        ("icon-right" (forward-char))
                                        ("Today" (insert "0"))
                                        ("Today+time" (insert "0t"))
                                        ("In 1 hour" (insert "1h"))
                                        ("Tomorrow" (insert "1"))
                                        ("In 1 Week" (insert "1w"))
                                        ("Today at 13:00" (insert "0t1300"))))

  (define template-macro-toolbar-items '(("icon-help" (alert "Help" "There are various macros available (toolbar buttons are defined for each) which are expanded when the template is applied to a new item. For example you might want to insert the name of the current month - in which case the %monthlong% will insert January or February, etc."))
                                         ("icon-left" (backward-char))
                                         ("icon-right" (forward-char))
                                         ("icon-change" (show-transform-commands))
                                         ("Now" (insert "%now%"))
                                         ("Today" (insert "%today%"))
                                         ("Year" (insert "%year%"))
                                         ("Month, e.g. 01" (insert "%month%"))
                                         ("Month, e.g. Jan" (insert "%monthshort%"))
                                         ("Month, e.g. January" (insert "%monthlong%"))
                                         ("Day, e.g. 18" (insert "%day%"))
                                         ("Day, e.g. Mon" (insert "%dayshort%"))
                                         ("Day, e.g. Monday" (insert "%daylong%"))
                                         ("Hour" (insert "%hour%"))
                                         ("Minute" (insert "%minute%"))))
#+end_src
* Agenda
#+begin_src scheme
  (defvar agenda-exclude-files ()
    "List of files, including extension, to exclude from the agenda")

  (defvar date-preset-times '("09:00" "14:00" "17:00" "21:00")
    "A list of pre-defined times which will be shown when you add a time to a date")
#+end_src
* todo
#+begin_src scheme
  (defvar todo-exclude-files ()
    "List of files, including extension, to exclude from the TODO list")
#+end_src

Filtering

#+begin_src scheme
  (define filter-table (make-hashtable equal-hash equal?))
  (define (filter-add name predicate)
    (if (and (string? name) (procedure? predicate))
        (hashtable-set! filter-table name predicate)
        "name expected to be a string and predicate should be a procedure"))
  (define (filter-match name item)
    ((hashtable-ref filter-table name (lambda (item) #f)) item))

  (defvar filter-include-default #t
    "Whether or not the built-in TODO filters should be shown")

  (defvar filter-min-chars 3
    "The minimum number of characters that need to be entered for a search string to be acted upon.")
#+end_src
* Notifications
#+begin_src scheme
  (defvar badge-filter "o k"
    "The search filter string which is used to determine the number to display on the badge. By default this uses the flags 'o' (for overdue tasks only) and 'k' (for incomplete tasks only)")
#+end_src
* Buffer handling
The buffer is equivalent to the text being edited (or for the REPL the entire text shown since it started)
#+begin_src scheme
  ;; The point is equivalent to the cursor and has a minimum value of 1
  (define (point-min) 1)
  ;; The maximum point value is the equivalent to going to the end of the buffer
  (define (point-max)
    (1+ (buffer-size)))
  ;; The region is the selected text. If no text is selected then this will return an empty string
  (define (region)
    (buffer-substring (region-beginning) (region-end)))
#+end_src
* Editor
** Functions
#+begin_src scheme
  ;; Move the point (i.e. the cursor) back one character. If already at the beginning nothing will happen.
  (define (backward-char) (goto-char (1- (point))))
  ;; Move the point forward one character. If already at the end nothing will happen.
  (define (forward-char) (goto-char (1+ (point))))
  ;; Used internally by beorg to execute the code attached to an item on a toolbar.
  (define (toolbar-run toolbar-name item)
    (eval (cadr (assoc item toolbar-name))))
  ;; Hooks so that the editor can respond to particular key presses
  (define (editor-char-event char)
    (if (string=? char "\n") (begin (editor-newline-event) #t) #f))
  (define (editor-newline-event)
    (org-list-continue))
#+end_src
** Defaults
#+begin_src scheme
  (defvar editor-font "Menlo 15"
    "The font to use in the editor. The format is '<FONT NAME> <FONT SIZE>'. For example 'Menlo 15'.")
  (defvar editor-background-color ""
    "The hex color, e.g. 000000, to use for the text editor background. If an empty string then the color defined in the active theme will be used.")
  (defvar editor-text-color-default ""
    "The hex color, e.g. 000000, to use for the text editor background font when no syntax highlighting is applied. If an empty string then the color defined in the active theme will be used.")
  (defvar editor-text-color-level1 ""
    "The hex color, e.g. 000000, to use for the text editor for a first level headline. If an empty string then the color defined in the active theme will be used.")
  (define editor-text-color-level2 "")
  (define editor-text-color-level3 "")
  (define editor-text-color-level4 "")
  (define editor-text-color-level5 "")
  (define editor-text-color-level6 "")

  (defvar editor-toolbar-items '(("icon-left" (backward-char))
                                 ("icon-right" (forward-char))
                                 ("icon-list" (insert "+ "))
                                 ("icon-todolist" (insert "+ [ ] "))
                                 ("icon-change" (show-transform-commands))
                                 ("icon-tools" (show-tools-commands))
                                 ("icon-settings" (insert-code-snippet)))
    "A list of buttons to show above the keyboard when editing notes. The list is a list of lists stating the button text and the code to run. For example '((\"<\" (backward-char)) (\">\" (forward-char))) defines a toolbar with the buttons < and > which respectively execute the functions backward-char and forward-char.")

  (defvar editor-toolbar-show-in-mini #f
    "If #t then the editor toolbar will be shown in the mini editor when editing an item.")

  (define sheet-current '())
  (define (sheet items)
    (set! sheet-current items)
    (sheet-present (map car items)))
  (define (sheet-current-exec item-name)
    (let ((form (cadr (assoc item-name sheet-current))))
      (eval form)))

  (define date-picker-callback #f)
  (define (date-picker date includes-time callback)
    (set! date-picker-callback callback)
    (date-picker-present date includes-time))
  (define (date-picker-callback-exec removed date includes-time)
    (if (procedure? date-picker-callback)
        (date-picker-callback removed date includes-time)))

  (define (region-text-set text)
    (let ((current-start (region-beginning)))
      (insert text)
      (region-set current-start (+ current-start (string-length text)))))

  (define (add-prefix-to-lines prefix text)
    (string-concatenate (map (lambda (line)
                               (string-concatenate (list prefix line "\n")))
                             (string-split text "\n"))))

  (define (show-transform-commands)
    (if (string=? (region) "")
        (alert "" "No text is selected.")
        (sheet '(("Uppercase" (region-text-set (string-upcase (region))))
                 ("Lowercase" (region-text-set (string-downcase (region))))
                 ("To List" (region-text-set (add-prefix-to-lines "+ " (region))))
                 ("To Checklist" (region-text-set (add-prefix-to-lines "+ [ ] " (region))))
                 ("Reset Checklist" (region-text-set (regexp-replace-all "\\+ \\[\\X\\]" (region) "+ [ ]")))))))

  (define (show-tools-commands)
    (sheet '(("Autocorrect On" (autocorrect-set! #t))
             ("Autocorrect Off" (autocorrect-set! #f)))))

  (define (insert-code-snippet)
    (insert "#+BEGIN_SRC scheme\n\n#+END_SRC\n")
    (goto-char (- (point) (string-length "\n#+END_SRC\n"))))

  (define (org-list-continue)
    (let* ((start-of-line
            (string-search-backward "\n"
                                    (buffer-substring (point-min)
                                                      (point))))
           (buffer-line-start (+ 2 (or start-of-line -1)))
           (match (string-re-search-forward "^(\\s*[\\+\\-](?:\\s\\[[\\s\\X\\-]\\])?\\s+)"
                                            (buffer-substring buffer-line-start
                                                              (point)))))
      (if (> (length match) 0)
          (if (> (- (point) (string-length (car match))) buffer-line-start)
              (insert (string-append "\n" (car match)))
              (let ((region-start (- (point) (string-length (car match)))))
                (delete-region region-start (point))
                (goto-char region-start)))
          (insert "\n"))))
#+end_src
* Files
#+BEGIN_SRC scheme
  (defvar file-read-only-list '()
    "A list of files which should be considered read only and not to be updated by beorg - for example '(\"family.org\").")
  (defvar file-disable-delete #f
    "If set to #t then the option to delete files won't be available in beorg.")
#+END_SRC
* Outliner
Fonts and colours

#+BEGIN_SRC scheme
  (defvar outliner-state-todo-font "Menlo-Bold 17"
    "The font to use for TODO state in the outliner")
  (defvar outliner-state-done-font "Menlo 17"
    "The font to use for DONE state in the outliner")
  (defvar outliner-state-todo-color "#628395"
    "The color to use for a TODO state")
  (defvar outliner-state-done-color "#555555"
    "The color to use for a DONE state")
  (defvar outliner-headline-font ".SFUIDisplay-Medium 17"
    "The font to use for the headline")
  (defvar outliner-headline-color ""
    "The color to use for the headline, leave as empty string to use color from theme")
  (defvar outliner-notes-font ".SFUIDisplay 17"
    "The font to use for the notes")
  (defvar outliner-notes-color ""
    "The color to use for the notes, leave as empty string to use color from theme")
#+END_SRC

* Keyboard shortcuts
#+BEGIN_SRC scheme
  ;; Tab bar
  (define-command-title "tabbar.agenda" "Show Agenda")
  (define-command-title "tabbar.todo" "Show TODO")
  (define-command-title "tabbar.files" "Show Files")
  (define-command-title "tabbar.settings" "Show Settings")
  (define-command-title "tabbar.new" "New item")
  (define-command-title "tabbar.show-templates" "Templates")
  (define-command-title "tabbar.repl" "REPL")
  (define-key "tabbar" "s-1" ".agenda")
  (define-key "tabbar" "s-2" ".todo")
  (define-key "tabbar" "s-3" ".files")
  (define-key "tabbar" "s-4" ".settings")
  (define-key "tabbar" "s-n" ".new")
  (define-key "tabbar" "S-s-n" ".show-templates")
  (define-key "tabbar" "S-s-r" ".repl")

  ;; Agenda/TODO
  (define-command-title "agenda.next-item" "Next item")
  (define-command-title "agenda.previous-item" "Previous item")
  (define-command-title "agenda.open-item" "Open item")
  (define-command-title "agenda.toggle-search-focus" "Toggle search focus")
  (define-command-title "agenda.show-saved-searches" "Saved searches")
  (define-command-title "agenda-weekly.today" "Today")
  (define-command-title "agenda-weekly.next-week" "Next week")
  (define-command-title "agenda-weekly.previous-week" "Previous week")
  (define-command-title "agenda-weekly.goto-week" "Goto week")
  (define-key "agenda" "<down>" ".next-item")
  (define-key "agenda" "<up>" ".previous-item")
  (define-key "agenda" "<return>" ".open-item")
  (define-key "agenda" "s-f" ".toggle-search-focus")
  (define-key "agenda" "S-s-f" ".show-saved-searches")
  (define-key "agenda-weekly" "s-t" ".today")
  (define-key "agenda-weekly" "s-<right>" ".next-week")
  (define-key "agenda-weekly" "s-<left>" ".previous-week")
  (define-key "agenda-weekly" "s-g" ".goto-week")

  ;; Saved searches
  (define-command-title "saved-searches.done" "Dismiss")
  (define-command-title "saved-searches.add" "New search")
  (define-command-title "saved-searches.next" "Next search")
  (define-command-title "saved-searches.previous" "Previous search")
  (define-command-title "saved-searches.use" "Use selected search")
  (define-command-title "saved-searches.edit" "Edit selected search")
  (define-command-title "saved-searches.delete" "Delete selected search")
  (define-key "saved-searches" "<escape>" ".done")
  (define-key "saved-searches" "s-n" ".add")
  (define-key "saved-searches" "<down>" ".next")
  (define-key "saved-searches" "<up>" ".previous")
  (define-key "saved-searches" "<return>" ".use")
  (define-key "saved-searches" "s-e" ".edit")
  (define-key "saved-searches" "s-d" ".delete")

  ;; Files
  (define-command-title "files.next-file" "Next file")
  (define-command-title "files.previous-file" "Previous file")
  (define-command-title "files.open-file" "Open file")
  (define-command-title "files.new" "New file")
  (define-command-title "files.delete" "Delete file")
  (define-command-title "files.rename" "Rename file")
  (define-command-title "files.toggle-pin" "Toggle pinned status")
  (define-command-title "files.toggle-search-focus" "Toggle search focus")
  (define-key "files" "<down>" ".next-file")
  (define-key "files" "<up>" ".previous-file")
  (define-key "files" "<return>" ".open-file")
  (define-key "files" "S-s-n" ".new")
  (define-key "files" "s-d" ".delete")
  (define-key "files" "s-r" ".rename")
  (define-key "files" "s-p" ".toggle-pin")
  (define-key "files" "s-f" ".toggle-search-focus")

  ;; Item editor
  (define-command-title "item.save" "Save changes")
  (define-command-title "item.cancel" "Cancel changes")
  (define-command-title "item.headline" "Headline")
  (define-command-title "item.file" "Move file")
  (define-command-title "item.state" "State")
  (define-command-title "item.priority" "Priority")
  (define-command-title "item.tags" "Tags")
  (define-command-title "item.date-scheduled" "Scheduled date")
  (define-command-title "item.date-deadline" "Deadline date")
  (define-command-title "item.date-showon" "Show on date")
  (define-command-title "item.notes" "Notes")
  (define-key "item" "s-s" ".save")
  (define-key "item" "<escape>" ".cancel")
  (define-key "item" "s-e" ".headline")
  (define-key "item" "s-r" ".file")
  (define-key "item" "s-1" ".state")
  (define-key "item" "s-2" ".priority")
  (define-key "item" "s-3" ".tags")
  (define-key "item" "s-4" ".date-scheduled")
  (define-key "item" "s-5" ".date-deadline")
  (define-key "item" "s-6" ".date-showon")
  (define-key "item" "s-t" ".notes")

  ;; Text editor
  (define-command-title "text-editor.save" "Save")
  (define-key "text-editor" "s-s" ".save")

  ;; Text editor toolbar
  (define-command-title "editor-toolbar-items.icon-list" "Start a list")
  (define-command-title "editor-toolbar-items.icon-todolist" "Start a checklist")
  (define-key "editor-toolbar-items" "S-s-l" ".icon-list")
  (define-key "editor-toolbar-items" "S-s-c" ".icon-todolist")

  ;; Date picker
  (define-command-title "date-picker.save" "Save")
  (define-command-title "date-picker.toggle-search-focus" "Toggle search focus")
  (define-command-title "date-picker.toggle-time" "Toggle time")
  (define-command-title "date-picker.delete" "Remove date")
  (define-command-title "date-picker.plus1day" "+1 day")
  (define-command-title "date-picker.minus1day" "-1 day")
  (define-command-title "date-picker.plus1week" "+1 week")
  (define-command-title "date-picker.minus1week" "-1 week")
  (define-key "date-picker" "s-s" ".save")
  (define-key "date-picker" "s-f" ".toggle-search-focus")
  (define-key "date-picker" "s-t" ".toggle-time")
  (define-key "date-picker" "s-d" ".delete")
  (define-key "date-picker" "C-<down>" ".plus1day")
  (define-key "date-picker" "C-<up>" ".minus1day")
  (define-key "date-picker" "C-<right>" ".plus1week")
  (define-key "date-picker" "C-<left>" ".minus1week")

  ;; REPL
  (define-command-title "repl.close" "Close")
  (define-key "repl" "<escape>" ".close")

  ;; REPL toolbar
  (define-command-title "repl-toolbar-items.icon-up" "Previous command")
  (define-key "repl-toolbar-items" "<up>" ".icon-up")

  ;; Property selector (e.g. state, priority)
  (define-command-title "property.next" "Next property")
  (define-command-title "property.previous" "Previous property")
  (define-command-title "property.save" "Select")
  (define-command-title "property.cancel" "Cancel")
  (define-key "property" "<down>" ".next")
  (define-key "property" "<up>" ".previous")
  (define-key "property" "<return>" ".save")
  (define-key "property" "<escape>" ".cancel")

  ;; Tags dialog
  (define-command-title "tags.next" "Next tag")
  (define-command-title "tags.previous" "Previous tag")
  (define-command-title "tags.toggle-search-focus" "Toggle search focus")
  (define-command-title "tags.toggle-tag" "Toggle selected tag")
  (define-command-title "tags.save" "Save")
  (define-key "tags" "<down>" ".next")
  (define-key "tags" "<up>" ".previous")
  (define-key "tags" "s-f" ".toggle-search-focus")
  (define-key "tags" "<return>" ".toggle-tag")
  (define-key "tags" "s-s" ".save")

  ;; Outliner

  (define-command-title "outliner.add-at-end" "Add a new item at end of outline")
  (define-command-title "outliner.save" "Save")
  (define-command-title "outliner.select-first-item" "Select first item")
  (define-command-title "outliner.toggle-item-fold" "Toggle item fold")
  (define-command-title "outliner.edit-org" "Edit file as text")
  (define-command-title "outliner.export" "Export")
  (define-key "outliner" "s-n" ".add-at-end")
  (define-key "outliner" "s-s" ".save")
  (define-key "outliner" "s-<return>" ".select-first-item")
  (define-key "outliner" "s-o" ".toggle-item-fold")
  (define-key "outliner" "s-e" ".edit-org")
  (define-key "outliner" "s-p" ".export")

  ;; Outliner item editor (i.e. when an item is selected)
  (define-command-title "outliner-item.move-left" "Outdent/move item left")
  (define-command-title "outliner-item.move-right" "Indent/move item right")
  (define-command-title "outliner-item.move-up" "Move node up")
  (define-command-title "outliner-item.move-down" "Move node down")
  (define-command-title "outliner-item.add-below" "New node below")
  (define-command-title "outliner-item.add-above" "New node above")
  (define-command-title "outliner-item.select-previous" "Select previous node")
  (define-command-title "outliner-item.select-next" "Select next node")
  (define-command-title "outliner-item.show-details" "Show item details")
  (define-command-title "outliner-item.show-notes" "Show item notes")
  (define-key "outliner-item" "C-s-<left>" ".move-left")
  (define-key "outliner-item" "C-s-<right>" ".move-right")
  (define-key "outliner-item" "C-s-<up>" ".move-up")
  (define-key "outliner-item" "C-s-<down>" ".move-down")
  (define-key "outliner-item" "s-<return>" ".add-below")
  (define-key "outliner-item" "S-s-<return>" ".add-above")
  (define-key "outliner-item" "C-M-<up>" ".select-previous")
  (define-key "outliner-item" "C-M-<down>" ".select-next")
  (define-key "outliner-item" "S-s-n" ".show-notes")
  (define-key "outliner-item" "S-s-d" ".show-details")

  ;; Export/rendered file
  (define-command-title "export.done" "Dismiss")
  (define-key "export" "<escape>" ".done")

  ;; Templates list
  (define-command-title "templates-list.done" "Dismiss")
  (define-command-title "templates-list.next-template" "Next template")
  (define-command-title "templates-list.previous-template" "Previous template")
  (define-command-title "templates-list.use" "New item using template")
  (define-key "templates-list" "<escape>" ".done")
  (define-key "templates-list" "<down>" ".next-template")
  (define-key "templates-list" "<up>" ".previous-template")
  (define-key "templates-list" "<return>" ".use")
#+END_SRC
* REPL
** Defaults
#+begin_src scheme
  (defvar repl-prompt "> "
    "Text shown before where you enter a command.")
  (defvar repl-welcome "beorg REPL\n\n"
    "Text shown when the REPL is started.")

  (defvar repl-font "Menlo 15"
    "The font to use in the REPL. The format is '<FONT NAME> <FONT SIZE>'. For example 'Menlo 15'.")

  (defvar repl-toolbar-items '(("(" (begin (insert "()") (backward-char)))
                               (")" (insert ")"))
                               ("icon-left" (backward-char))
                               ("icon-right" (forward-char))
                               ("icon-up" (repl-history-up))
                               ("define" (begin (insert "(define )")
                                                (backward-char))))
    "A list of buttons to show above the keyboard when using the REPL. The list is a list of lists stating the button text and the code to run. For example '((\"<\" (backward-char)) (\">\" (forward-char))) defines a toolbar with the buttons < and > which respectively execute the functions backward-char and forward-char.\n\nIf the button text is a valid icon name then a built-in icon will be used instead.")

  ;; History
  (define repl-history-size 50)
  (define repl-history (make-vector repl-history-size))
  (define repl-history-next-index 0)
  (define repl-history-offset 0)
  (define repl-history-max-index 0)
  (define (repl-history-add line)
    (begin
      (vector-set! repl-history repl-history-next-index line)
      (if (< repl-history-next-index repl-history-size) (define repl-history-max-index (1+ repl-history-max-index)))
      (define repl-history-offset 0)
      (define repl-history-next-index
        (if (= (1+ repl-history-next-index) repl-history-size)
            0
            (1+ repl-history-next-index)))))
  (define (repl-set-line text)
    (let* ((start-of-line
            (1+ (string-search-backward "\n" (buffer-substring (point-min) (point-max)))))
           (start-of-user-text
            (if start-of-line (+ start-of-line (string-length repl-prompt) 1) repl-prompt)))
      (delete-region start-of-user-text (point-max))
      (goto-char (point-max))
      (insert text)))
  (define (repl-history-up)
    (let ((index (mod (- repl-history-next-index repl-history-offset 1) repl-history-size)))
      (if (< index repl-history-max-index)
          (begin
            (repl-set-line (vector-ref repl-history index))
            (define repl-history-offset (1+ repl-history-offset))))))
#+end_src
* UI
#+begin_src scheme
  (defvar ui-start-tab "agenda" "The tab to show on start. Should be one of agenda, todo, files")
  (defvar ui-swap-item-swipe-direction #f "Whether the swipe direction on items in the agenda or TODO tab should be swapped. If #t then swiping left-to-right will show state change options rather than editing the item in the outliner.")
#+end_src
* Org mode
This section contains any functions or variables related to the Org mode file format
#+begin_src scheme
  (defvar org-tags-column -77 
    "This controls alignment of tags when an org file is saved by beorg. The number is the column number at which to write the tags assuming they wouldn't overwrite the heading text. If negative refers to the line length - the length of the tags text.")
  (defvar org-remove-property-drawers-from-render-output #t
    "LOGBOOK and PROPERTIES drawers will be removed when rendering HTML.")
  (defvar org-remove-dates-from-render-output #t
    "SCHEDULED, DEADLINE and CLOSED lines will be removed when rendering HTML.")
  (defvar org-allow-math #f
    "Allow MathJax to be used.")
#+end_src
* Sync
#+begin_src scheme
  (defvar after-manual-sync-hook (lambda () (log-debug "Sync complete"))
    "The function bound to after-manual-sync-hook is called when a manually initiated sync has completed. Intended use for this is to open a URL to an app such as Working Copy's URL scheme to commit a git repository.")
  (defvar sync-hide-progress #f "If #t then don't show the 'Syncing org files...' view when a sync is taking place. Sync progress is not shown in any case if you are using iCloud.")
#+end_src

Download now for iPhone and iPad

Follow the latest beorg news on Twitter

Privacy Policy | Press Kit