aboutsummaryrefslogtreecommitdiff
path: root/modules/org-config.el
diff options
context:
space:
mode:
Diffstat (limited to 'modules/org-config.el')
-rw-r--r--modules/org-config.el109
1 files changed, 70 insertions, 39 deletions
diff --git a/modules/org-config.el b/modules/org-config.el
index d2a0be34f..8d722ad46 100644
--- a/modules/org-config.el
+++ b/modules/org-config.el
@@ -44,9 +44,6 @@
(setq org-startup-indented t) ;; load org files indented
(setq org-adapt-indentation t) ;; adapt indentation to outline node level
- ;; TASK: this variable doesn't exist. Remove
- ;; (setq org-indent-indentation-per-level 2) ;; indent two character-widths per level
-
;; IMAGES / MEDIA
(setq org-startup-with-inline-images t) ;; preview images by default
(setq org-image-actual-width '(500)) ;; keep image sizes in check
@@ -63,23 +60,8 @@
;; -------------------------- Org Appearance Settings --------------------------
(defun cj/org-appearance-settings()
- "Set foreground, background, and font styles for org mode."
+ "Set org-mode appearance options (org faces are left to the theme)."
(interactive)
- ;; org-hide should use fix-pitch to align indents for proportional fonts
- (set-face-attribute 'org-hide nil :inherit 'fixed-pitch)
- (set-face-attribute 'org-meta-line nil :inherit 'shadow)
-
- ;; Remove foreground and background from block faces
- (set-face-attribute 'org-block nil :foreground 'unspecified :background 'unspecified)
- (set-face-attribute 'org-block-begin-line nil :foreground 'unspecified :background 'unspecified)
- (set-face-attribute 'org-block-end-line nil :foreground 'unspecified :background 'unspecified)
-
- ;; Get rid of the background on column views
- (set-face-attribute 'org-column nil :background 'unspecified)
- (set-face-attribute 'org-column-title nil :background 'unspecified)
-
- ;; make sure org-links are underlined
- (set-face-attribute 'org-link nil :underline t)
(setq org-ellipsis " ▾") ;; change ellipses to down arrow
(setq org-hide-emphasis-markers t) ;; hide emphasis markers (org-appear shows them when editing)
@@ -147,6 +129,72 @@ edge, less the tag width.")
(add-hook 'org-mode-hook #'cj/org--manage-tag-display-prop)
(font-lock-add-keywords 'org-mode cj/org-right-align-tags-keyword t)
+;; ------------------------ Org Table Header Highlighting --------------------
+;; Org faces the whole table -- header rows included -- with `org-table'; it has
+;; no in-buffer header-row face. `org-table-header' is used only by the sticky
+;; header line of `org-table-header-line-mode'. This font-lock keyword prepends
+;; `org-table-header' onto a table's header rows (the non-hline rows above its
+;; first hline), so the themed header style lands in place in the buffer.
+
+(declare-function org-at-table-p "org")
+(declare-function org-at-table-hline-p "org")
+(declare-function org-table-begin "org-table")
+(declare-function org-table-end "org-table")
+
+(defcustom cj/org-fontify-table-headers t
+ "When non-nil, highlight org table header rows with the `org-table-header' face.
+A header row is a non-hline table row above its table's first hline. Org has no
+in-buffer header-row face of its own, so this supplies one, deferring its whole
+appearance to the themed `org-table-header' face."
+ :type 'boolean
+ :group 'org)
+
+(defun cj/--org-table-first-hline-position ()
+ "Return the start position of the first hline in the table at point, or nil.
+Point must be inside an org table."
+ (save-excursion
+ (let ((end (org-table-end))
+ (found nil))
+ (goto-char (org-table-begin))
+ (while (and (not found) (< (point) end))
+ (when (org-at-table-hline-p)
+ (setq found (line-beginning-position)))
+ (forward-line 1))
+ found)))
+
+(defun cj/--org-table-header-row-p ()
+ "Return non-nil if the line at point is a header row of its org table.
+A header row is a non-hline table row positioned above the table's first hline.
+A table with no hline has no header rows."
+ (and (org-at-table-p)
+ (not (org-at-table-hline-p))
+ (let ((hline (cj/--org-table-first-hline-position)))
+ (and hline (< (line-beginning-position) hline)))))
+
+(defun cj/--org-fontify-table-header-matcher (limit)
+ "Font-lock matcher for the next org table header row before LIMIT.
+Returns non-nil when a header row is found, with match group 0 spanning the
+whole row line."
+ (let (beg end found)
+ (while (and (not found)
+ (re-search-forward "^[ \t]*|.*$" limit t))
+ (setq beg (match-beginning 0)
+ end (match-end 0))
+ (save-excursion
+ (goto-char beg)
+ (when (cj/--org-table-header-row-p)
+ (setq found t))))
+ (when found
+ (set-match-data (list beg end))
+ t)))
+
+(defconst cj/org-table-header-keyword
+ '((cj/--org-fontify-table-header-matcher (0 'org-table-header prepend)))
+ "Font-lock keyword prepending `org-table-header' onto org table header rows.")
+
+(when cj/org-fontify-table-headers
+ (font-lock-add-keywords 'org-mode cj/org-table-header-keyword t))
+
;; ----------------------------- Org TODO Settings ---------------------------
(defun cj/org-todo-settings ()
@@ -158,29 +206,12 @@ edge, less the tag width.")
"DELEGATED(x)" "|"
"FAILED(f!)" "DONE(d!)" "CANCELLED(c!)")))
- ;; Keyword and priority colors come from the active theme's dupre-org-*
- ;; faces (themes/dupre-faces.el) rather than hard-coded color names, so they
- ;; match the palette and dim with the rest of an unfocused window
- ;; (auto-dim-config.el remaps each to its -dim variant).
- (setq org-todo-keyword-faces
- '(("TODO" . dupre-org-todo)
- ("PROJECT" . dupre-org-project)
- ("DOING" . dupre-org-doing)
- ("WAITING" . dupre-org-waiting)
- ("VERIFY" . dupre-org-verify)
- ("STALLED" . dupre-org-stalled)
- ("DELEGATED" . dupre-org-todo)
- ("FAILED" . dupre-org-failed)
- ("DONE" . dupre-org-done)
- ("CANCELLED" . dupre-org-done)))
-
+ ;; Keyword and priority faces are defined and wired in org-faces-config.el
+ ;; (loaded just after this module): each keyword and priority maps to its own
+ ;; org-faces-* face, which the active theme recolors.
(setq org-highest-priority ?A)
(setq org-lowest-priority ?D)
(setq org-default-priority ?D)
- (setq org-priority-faces '((?A . dupre-org-priority-a)
- (?B . dupre-org-priority-b)
- (?C . dupre-org-priority-c)
- (?D . dupre-org-priority-d)))
(setq org-enforce-todo-dependencies t)
(setq org-enforce-todo-checkbox-dependencies t)