Fix: Links to headings with stats cookies in dynamic blocks

Fixes #248.  Closes #249.

Thanks to Maikol Solis (@maikol-solis) for reporting, and to him and
Ihor Radchenko (@yantar92) for helping plan the fix.
This commit is contained in:
Adam Porter 2022-03-01 02:38:26 -06:00
parent 00d95e1f0f
commit af18eac2b8
3 changed files with 46 additions and 31 deletions

View file

@ -524,7 +524,8 @@ Simple links may also be written manually in either sexp or non-sexp form, like:
** 0.7-pre
Nothing new yet.
*Fixed*
+ In dynamic blocks, links to headings with statistics cookies were broken. (Fixes [[https://github.com/alphapapa/org-ql/issues/248][#248]]. Thanks to [[https://github.com/maikol-solis][Maikol Solis]] and [[https://github.com/yantar92][Ihor Radchenko]].)
** 0.6

View file

@ -38,6 +38,15 @@
(require 'org-ql)
(require 'org-ql-view)
;;;; Compatibility
(defalias 'org-ql-search--link-heading-search-string
(cond ((fboundp 'org-link--normalize-string) #'org-link--normalize-string)
((fboundp 'org-link-heading-search-string) #'org-link-heading-search-string)
((fboundp 'org-make-org-heading-search-string) #'org-make-org-heading-search-string)
(t (warn "org-ql: Unable to define alias `org-ql-search--link-heading-search-string'. This may affect links in dynamic blocks. Please report this as a bug.")
#'identity)))
;;;; Variables
(defvar org-ql-block-header nil
@ -285,9 +294,9 @@ For example, an org-ql dynamic block header could look like:
(list (cons 'todo (lambda (element)
(org-element-property :todo-keyword element)))
(cons 'heading (lambda (element)
(org-make-link-string (org-element-property :raw-value element)
(org-link-display-format
(org-element-property :raw-value element)))))
(let ((normalized-heading
(org-ql-search--link-heading-search-string (org-element-property :raw-value element))))
(org-make-link-string normalized-heading (org-link-display-format normalized-heading)))))
(cons 'priority (lambda (element)
(--when-let (org-element-property :priority element)
(char-to-string it))))

View file

@ -988,7 +988,12 @@ File: README.info, Node: 07-pre, Next: 06, Up: Changelog
5.1 0.7-pre
===========
Nothing new yet.
*Fixed*
• In dynamic blocks, links to headings with statistics cookies were
broken. (Fixes #248
(https://github.com/alphapapa/org-ql/issues/248). Thanks to Maikol
Solis (https://github.com/maikol-solis) and Ihor Radchenko
(https://github.com/yantar92).)

File: README.info, Node: 06, Next: 052, Prev: 07-pre, Up: Changelog
@ -1595,32 +1600,32 @@ Node: Links35368
Node: Tips36055
Node: Changelog36373
Node: 07-pre37111
Node: 0637217
Node: 05240231
Node: 05140531
Node: 0540948
Node: 04942422
Node: 04842696
Node: 04743043
Node: 04643438
Node: 04543838
Node: 04444199
Node: 04344558
Node: 04244755
Node: 04144916
Node: 0445157
Node: 03249090
Node: 03149469
Node: 0349666
Node: 02352641
Node: 02252869
Node: 02153137
Node: 0253336
Node: 0157371
Node: Notes57472
Node: Comparison with Org Agenda searches57634
Node: org-sidebar58506
Node: License58785
Node: 0637481
Node: 05240495
Node: 05140795
Node: 0541212
Node: 04942686
Node: 04842960
Node: 04743307
Node: 04643702
Node: 04544102
Node: 04444463
Node: 04344822
Node: 04245019
Node: 04145180
Node: 0445421
Node: 03249354
Node: 03149733
Node: 0349930
Node: 02352905
Node: 02253133
Node: 02153401
Node: 0253600
Node: 0157635
Node: Notes57736
Node: Comparison with Org Agenda searches57898
Node: org-sidebar58770
Node: License59049

End Tag Table