Skip to content

Commit

Permalink
fix: fix up inconsistent header-line
Browse files Browse the repository at this point in the history
Introduce new option `org-sticky-header-default-face` which allows to use either the org buffer heading theme or the default Emacs `header-line` theme. Corresponding foreground faces are added.
Update function `org-sticky-header--heading-string` and use `pcase-let*`.
  • Loading branch information
andruska committed Nov 22, 2023
1 parent 6978759 commit a8bac78
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions org-sticky-header.el
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ is enabled."
"Show priority before heading text."
:type 'boolean)

(defcustom org-sticky-header-default-face nil
"Using `header-line' default theme instead of `org-level-faces'."
:type 'boolean)

;;;; Functions

(defun org-sticky-header-goto-heading (event)
Expand Down Expand Up @@ -184,22 +188,18 @@ is enabled."
(defun org-sticky-header--heading-string ()
"Return string for heading at point.
According to `org-sticky-header' options."
;; TODO: Update minimum Emacs version and use `pcase-let*'.
(let* ((components (org-heading-components))
(level (nth 0 components))
(keyword (nth 2 components))
(priority (nth 3 components))
(heading (org-link-display-format (nth 4 components)))
(face (nth (1- level) org-level-faces)))
(pcase-let* ((`(,level _ ,keyword ,priority ,heading) (org-heading-components))
(face (unless org-sticky-header-default-face (nth (1- level) org-level-faces))))
(concat
(when (and org-sticky-header-show-keyword keyword)
(concat (propertize keyword 'face (org-get-todo-face keyword))
" "))
(when (and org-sticky-header-show-priority priority)
(concat (propertize (concat "[#" (char-to-string priority) "]")
'face 'org-priority)
" "))
(propertize heading 'face face))))
(when (and org-sticky-header-show-keyword keyword)
(concat (propertize keyword
'face `((:foreground ,(face-foreground (org-get-todo-face keyword) nil 1)) ,face))
" "))
(when (and org-sticky-header-show-priority priority)
(concat (propertize (concat "[#" (char-to-string priority) "]")
'face `((:foreground ,(face-foreground 'org-priority nil 1)) ,face))
" "))
(propertize (org-link-display-format heading) 'face face))))

(defun org-sticky-header--get-prefix ()
"Return prefix string depending on value of `org-sticky-header-prefix'."
Expand Down

0 comments on commit a8bac78

Please sign in to comment.