Skip to content

Commit

Permalink
Fix: (org-ql-view--format-element) Font-lock Org syntax
Browse files Browse the repository at this point in the history
Not sure why I overlooked this for so long (links already worked,
which is probably why).
  • Loading branch information
alphapapa committed Sep 16, 2024
1 parent fff110a commit b6f8a31
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 47 deletions.
1 change: 1 addition & 0 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,7 @@ Simple links may also be written manually in either sexp or non-sexp form, like:
*Fixes*
+ Customization group for face ~org-ql-view-due-date~.
+ Command ~org-ql-refile~ uses the base buffer when refiling to an indirect buffer.
+ Apply Org syntax font-locking to items in ~org-ql-view~ buffers.

*** helm-org-ql

Expand Down
21 changes: 21 additions & 0 deletions org-ql-view.el
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,22 @@ with human-readable strings."
(font-lock-ensure)
(buffer-string))))

(defun org-ql-view--font-lock-as-org (s)
"Return string S font-locked as in `org-mode'."
;; This works like `org-fontify-like-in-org-mode', but uses a single
;; buffer instead of a new one every time.
;; TODO(C): Submit these improvements upstream.
(let ((buffer (or (get-buffer " *org-ql-view--font-lock-as-org*")
(with-current-buffer (get-buffer-create " *org-ql-view--font-lock-as-org*")
(buffer-disable-undo)
(org-mode)
(current-buffer)))))
(with-current-buffer buffer
(insert s)
(font-lock-ensure)
(prog1 (buffer-string)
(erase-buffer)))))

(defun org-ql-view--buffer (&optional name)
"Return `org-ql-view' buffer, creating it if necessary.
If NAME is non-nil, return buffer by that name instead of using
Expand Down Expand Up @@ -898,6 +914,11 @@ return an empty string."
;; (which would also make it easier to do it independently of faces, etc).
(title (--> (org-ql-view--add-faces element)
(org-element-property :raw-value it)))
;; TODO(B): Needs refactoring. A function like `org-ql-view--add-faces'
;; should return a list of faces to be added.
(title-faces (get-text-property 0 'face title))
(title (org-ql-view--font-lock-as-org title))
(_ (add-face-text-property 0 (length title) title-faces t title))
(todo-keyword (-some--> (org-element-property :todo-keyword element)
(org-ql-view--add-todo-face
(substring-no-properties it))))
Expand Down
95 changes: 48 additions & 47 deletions org-ql.info
Original file line number Diff line number Diff line change
Expand Up @@ -1112,6 +1112,7 @@ File: README.info, Node: 09-pre, Next: 089, Up: Changelog
• Customization group for face ‘org-ql-view-due-date’.
• Command ‘org-ql-refile’ uses the base buffer when refiling to an
indirect buffer.
• Apply Org syntax font-locking to items in ‘org-ql-view’ buffers.

* Menu:

Expand Down Expand Up @@ -2157,53 +2158,53 @@ Node: Links39051
Node: Tips39738
Node: Changelog40062
Node: 09-pre41029
Node: helm-org-ql (1)41976
Node: 08942117
Node: 08843259
Node: 08744335
Node: 08645563
Node: 08545797
Node: 08446453
Node: 08346905
Node: 08247246
Node: 08147639
Node: 0848062
Node: 07450788
Node: 07351013
Node: 07251747
Node: 07152668
Node: 0753479
Node: 06356345
Node: 06256878
Node: 06157185
Node: 0657755
Node: 05260811
Node: 05161113
Node: 0561538
Node: 04963069
Node: 04863351
Node: 04763700
Node: 04664109
Node: 04564517
Node: 04464878
Node: 04365237
Node: 04265440
Node: 04165601
Node: 0465848
Node: 03269949
Node: 03170352
Node: 0370549
Node: 02373849
Node: 02274083
Node: 02174363
Node: 0274568
Node: 0178646
Node: Development78747
Node: Copyright assignment78980
Node: Notes79570
Node: Comparison with Org Agenda searches79734
Node: org-sidebar80623
Node: License80902
Node: helm-org-ql (1)42052
Node: 08942193
Node: 08843335
Node: 08744411
Node: 08645639
Node: 08545873
Node: 08446529
Node: 08346981
Node: 08247322
Node: 08147715
Node: 0848138
Node: 07450864
Node: 07351089
Node: 07251823
Node: 07152744
Node: 0753555
Node: 06356421
Node: 06256954
Node: 06157261
Node: 0657831
Node: 05260887
Node: 05161189
Node: 0561614
Node: 04963145
Node: 04863427
Node: 04763776
Node: 04664185
Node: 04564593
Node: 04464954
Node: 04365313
Node: 04265516
Node: 04165677
Node: 0465924
Node: 03270025
Node: 03170428
Node: 0370625
Node: 02373925
Node: 02274159
Node: 02174439
Node: 0274644
Node: 0178722
Node: Development78823
Node: Copyright assignment79056
Node: Notes79646
Node: Comparison with Org Agenda searches79810
Node: org-sidebar80699
Node: License80978

End Tag Table

Expand Down

0 comments on commit b6f8a31

Please sign in to comment.