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-18 10:28:17 -05:00
parent 49b973ab11
commit 1e7700e64e
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.6.1-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: 061-pre, Next: 06, Up: Changelog
5.1 0.6.1-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: 061-pre, Up: Changelog
@ -1595,32 +1600,32 @@ Node: Links35371
Node: Tips36058
Node: Changelog36376
Node: 061-pre37117
Node: 0637228
Node: 05240243
Node: 05140543
Node: 0540960
Node: 04942434
Node: 04842708
Node: 04743055
Node: 04643450
Node: 04543850
Node: 04444211
Node: 04344570
Node: 04244767
Node: 04144928
Node: 0445169
Node: 03249102
Node: 03149481
Node: 0349678
Node: 02352653
Node: 02252881
Node: 02153149
Node: 0253348
Node: 0157383
Node: Notes57484
Node: Comparison with Org Agenda searches57646
Node: org-sidebar58518
Node: License58797
Node: 0637492
Node: 05240507
Node: 05140807
Node: 0541224
Node: 04942698
Node: 04842972
Node: 04743319
Node: 04643714
Node: 04544114
Node: 04444475
Node: 04344834
Node: 04245031
Node: 04145192
Node: 0445433
Node: 03249366
Node: 03149745
Node: 0349942
Node: 02352917
Node: 02253145
Node: 02153413
Node: 0253612
Node: 0157647
Node: Notes57748
Node: Comparison with Org Agenda searches57910
Node: org-sidebar58782
Node: License59061

End Tag Table