Skip to content

Commit

Permalink
Fix: Links to headings with stats cookies in dynamic blocks
Browse files Browse the repository at this point in the history
Fixes #248.  Closes #249.

Thanks to Maikol Solis (@maikol-solis) for reporting, and to him and
Ihor Radchenko (@yantar92) for helping plan the fix.
  • Loading branch information
alphapapa committed Mar 18, 2022
1 parent 49b973a commit 1e7700e
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 31 deletions.
3 changes: 2 additions & 1 deletion README.org
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
15 changes: 12 additions & 3 deletions org-ql-search.el
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))))
Expand Down
59 changes: 32 additions & 27 deletions org-ql.info
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 1e7700e

Please sign in to comment.