Add: (org-ql-agenda--header-line-format) Move code to new function
This commit is contained in:
parent
b5ccc3294e
commit
cc5756d00d
1 changed files with 21 additions and 17 deletions
|
|
@ -230,25 +230,9 @@ SORT: One or a list of `org-ql' sorting functions, like `date' or
|
|||
(setq-local org-ql-sort sort)
|
||||
(setq-local org-ql-narrow narrow)
|
||||
(setq-local org-ql-super-groups super-groups)
|
||||
(setq-local header-line-format (org-ql-agenda--header-line-format buffers-files query))
|
||||
;; TODO: Derive a minor mode and set keymap there.
|
||||
(local-set-key "g" #'org-ql-search-refresh)
|
||||
(let* ((query-formatted (format "%S" query))
|
||||
(query-formatted (propertize (org-ql-agenda--font-lock-string 'emacs-lisp-mode query-formatted)
|
||||
'help-echo query-formatted))
|
||||
(query-width (length query-formatted))
|
||||
(available-width (- (window-width)
|
||||
(length "In: ")
|
||||
(length "Query: ")
|
||||
query-width 4))
|
||||
(buffers-files-formatted (format "%S" buffers-files))
|
||||
(buffers-files-formatted (propertize (->> buffers-files-formatted
|
||||
(org-ql-agenda--font-lock-string 'emacs-lisp-mode)
|
||||
(s-truncate available-width))
|
||||
'help-echo buffers-files-formatted)))
|
||||
(setq-local header-line-format (concat (propertize "Query: " 'face 'org-agenda-structure)
|
||||
query-formatted " "
|
||||
(propertize "In: " 'face 'org-agenda-structure)
|
||||
buffers-files-formatted)))
|
||||
;; Clear buffer, insert entries, etc.
|
||||
(erase-buffer)
|
||||
(insert entries)
|
||||
|
|
@ -256,6 +240,26 @@ SORT: One or a list of `org-ql' sorting functions, like `date' or
|
|||
(org-agenda-finalize)
|
||||
(goto-char (point-min)))))
|
||||
|
||||
(defun org-ql-agenda--header-line-format (buffers-files query)
|
||||
"Return header-line-format for BUFFERS-FILES and QUERY."
|
||||
(let* ((query-formatted (format "%S" query))
|
||||
(query-formatted (propertize (org-ql-agenda--font-lock-string 'emacs-lisp-mode query-formatted)
|
||||
'help-echo query-formatted))
|
||||
(query-width (length query-formatted))
|
||||
(available-width (- (window-width)
|
||||
(length "In: ")
|
||||
(length "Query: ")
|
||||
query-width 4))
|
||||
(buffers-files-formatted (format "%S" buffers-files))
|
||||
(buffers-files-formatted (propertize (->> buffers-files-formatted
|
||||
(org-ql-agenda--font-lock-string 'emacs-lisp-mode)
|
||||
(s-truncate available-width))
|
||||
'help-echo buffers-files-formatted)))
|
||||
(concat (propertize "Query: " 'face 'org-agenda-structure)
|
||||
query-formatted " "
|
||||
(propertize "In: " 'face 'org-agenda-structure)
|
||||
buffers-files-formatted)))
|
||||
|
||||
(defun org-ql-agenda--font-lock-string (mode s)
|
||||
"Return string S font-locked according to MODE."
|
||||
;; FIXME: Is this the proper way to do this? It works, but I feel like there must be a built-in way...
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue