-;; Time-stamp: <2016-05-13 12:58:46 kmodi>
+;; Time-stamp: <2016-05-13 19:21:37 kmodi>
 ;; Hi-lock: (("\\(^;\\{3,\\}\\)\\( *.*\\)" (1 'org-hide prepend) (2 '(:inherit org-level-1 :height 1.3 :weight bold :overline t :underline t) prepend)))
 ;; Hi-Lock: end
 

;; add the below to the end of the org file
;;
;;   #+BIND: foo nil
;;   # Local Variables:
;;   # org-export-allow-bind-keywords: t
;;   # End:


;; Local Variables:
;; eval: (aggressive-indent-mode -1)

      "Recalculate all org tables in the buffer before saving."
      (add-hook 'before-save-hook #'modi/org-table-recalculate-buffer-tables nil :local))
    (add-hook 'org-mode-hook #'modi/org-table-recalculate-before-save)

    (defun org-table-mark-field (n)
      "Mark the current table field.

If N is negative, select (- N) fields to the left of the current field,
including the current field.
If N >= 2, select (1- N) fields to the right of the current field,
including the current field.
If N is 0 or 1 (default), only the current field is selected."
      (interactive "p")
      (let ((bol-point (save-excursion
                         (beginning-of-line)
                         (point)))
            (bof-arg 1)
            (eof-arg 1)
            (p (point))
            bof-p)

        ;; Check if the point is already at the beginning of the current field.
        (when (looking-back "|\\s-*" bol-point)
          (setq bof-p t))

        ;; When selecting current field plus fields to the right
        (when (>= n 2)
          (setq eof-arg n))
        ;; When selecting current field plus fields to the left
        (when (<= n -1)
          (setq bof-arg (- n)))

        (org-table-beginning-of-field bof-arg)
        (when bof-p
          (org-table-next-field))
        (set-mark-command nil)
        (goto-char p)
        (org-table-end-of-field eof-arg)
        (exchange-point-and-mark)))

    (bind-keys
     :map org-mode-map
     :filter (org-at-table-p)
      ("S-SPC" . org-table-mark-field))

;;; Org Entities
    ;; http://www.mail-archive.com/emacs-orgmode@gnu.org/msg100527.html
