Skip to content

Commit

Permalink
Add: (defface org-ql-view-title) Use in -view--header-line-format
Browse files Browse the repository at this point in the history
Note that we also add a safety check in ORG-QL-VIEW--LINK-FOLLOW,
because the addition of a call to PROPERTIZE in
ORG-QL-VIEW--HEADER-LINE-FORMAT effectively removes what was
functioning as a safety check there (as CONCAT had been signaling an
error for the unsafe argument, whereas PROPERTIZE, which is called to
apply the new face, does not).  We also change the expected error in
the tests accordingly.
  • Loading branch information
alphapapa committed Sep 11, 2024
1 parent c3519fb commit 1c8c89f
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 52 deletions.
3 changes: 3 additions & 0 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,9 @@ Simple links may also be written manually in either sexp or non-sexp form, like:

** 0.9-pre

*Additions*
+ Face ~org-ql-view-title~, applied to view titles in header line.

*Changes*
+ Command ~org-ql-find~ respects narrowing of the current buffer by default, allowing searching within the narrowed region. (Using one ~C-u~ argument widens the current buffer, and using two ~C-u~ arguments prompts for the buffers to search.)
+ Function ~org-ql-completing-read~ accepts a new ~NARROWP~ argument, which is passed to ~org-ql-select~.
Expand Down
9 changes: 8 additions & 1 deletion org-ql-view.el
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@
"Face for due dates in `org-ql-view' views."
:group 'org-ql)

(defface org-ql-view-title '((t :weight bold))
"View title in header line."
:group 'org-ql-view)

;;;; Variables

(defvar org-ql-view-buffer-name-prefix "*Org QL View:"
Expand Down Expand Up @@ -459,7 +463,8 @@ subsequent refreshing of the buffer: `org-ql-view-buffers-files',
If TITLE, prepend it to the header."
(let* ((title (if title
(concat (propertize "View:" 'face 'transient-argument)
title " ")
(propertize title 'face 'org-ql-view-title)
" ")
""))
(query-formatted (when query
(org-ql-view--format-query query)))
Expand Down Expand Up @@ -645,6 +650,8 @@ purposes of compatibility with changes in Org 9.4."
(stringp buffers-files)
(cl-every #'stringp buffers-files))
(error "CAUTION: Link not opened because unsafe buffers-files parameter detected: %s" buffers-files))
(unless (or (stringp title) (null title))
(error "CAUTION: Link not opened because unsafe title parameter detected: %S" title))
(when (or (listp query)
(string-match (rx bol (0+ space) "(") query))
;; SAFETY: Query is in sexp form: ask for confirmation, because it could contain arbitrary code.
Expand Down
99 changes: 51 additions & 48 deletions org-ql.info
Original file line number Diff line number Diff line change
Expand Up @@ -1095,7 +1095,10 @@ File: README.info, Node: 09-pre, Next: 089, Up: Changelog
5.1 0.9-pre
===========

*Changes*
*Additions*
• Face ‘org-ql-view-title’, applied to view titles in header line.

*Changes*
• Command ‘org-ql-find’ respects narrowing of the current buffer by
default, allowing searching within the narrowed region. (Using one
‘C-u’ argument widens the current buffer, and using two ‘C-u’
Expand Down Expand Up @@ -2147,53 +2150,53 @@ Node: Links39051
Node: Tips39738
Node: Changelog40062
Node: 09-pre41029
Node: helm-org-ql (1)41575
Node: 08941716
Node: 08842858
Node: 08743934
Node: 08645162
Node: 08545396
Node: 08446052
Node: 08346504
Node: 08246845
Node: 08147238
Node: 0847661
Node: 07450387
Node: 07350612
Node: 07251346
Node: 07152267
Node: 0753078
Node: 06355944
Node: 06256477
Node: 06156784
Node: 0657354
Node: 05260410
Node: 05160712
Node: 0561137
Node: 04962668
Node: 04862950
Node: 04763299
Node: 04663708
Node: 04564116
Node: 04464477
Node: 04364836
Node: 04265039
Node: 04165200
Node: 0465447
Node: 03269548
Node: 03169951
Node: 0370148
Node: 02373448
Node: 02273682
Node: 02173962
Node: 0274167
Node: 0178245
Node: Development78346
Node: Copyright assignment78579
Node: Notes79169
Node: Comparison with Org Agenda searches79333
Node: org-sidebar80222
Node: License80501
Node: helm-org-ql (1)41667
Node: 08941808
Node: 08842950
Node: 08744026
Node: 08645254
Node: 08545488
Node: 08446144
Node: 08346596
Node: 08246937
Node: 08147330
Node: 0847753
Node: 07450479
Node: 07350704
Node: 07251438
Node: 07152359
Node: 0753170
Node: 06356036
Node: 06256569
Node: 06156876
Node: 0657446
Node: 05260502
Node: 05160804
Node: 0561229
Node: 04962760
Node: 04863042
Node: 04763391
Node: 04663800
Node: 04564208
Node: 04464569
Node: 04364928
Node: 04265131
Node: 04165292
Node: 0465539
Node: 03269640
Node: 03170043
Node: 0370240
Node: 02373540
Node: 02273774
Node: 02174054
Node: 0274259
Node: 0178337
Node: Development78438
Node: Copyright assignment78671
Node: Notes79261
Node: Comparison with Org Agenda searches79425
Node: org-sidebar80314
Node: License80593

End Tag Table

Expand Down
6 changes: 3 additions & 3 deletions tests/test-org-ql.el
Original file line number Diff line number Diff line change
Expand Up @@ -1986,13 +1986,13 @@ with keyword arg NOW in PLIST."
(expression-link "[[org-ql-search:todo:?title%3D%28error%20%22UNSAFE%22%29]]"))
(it "Errors for a quoted lambda"
(expect (open-link quoted-lambda-link)
:to-throw 'wrong-type-argument '(characterp lambda)))
:to-throw 'error '("CAUTION: Link not opened because unsafe title parameter detected: (lambda (_ _) (error \"UNSAFE\"))")))
(it "Errors for an unquoted lambda"
(expect (open-link unquoted-lambda-link)
:to-throw 'wrong-type-argument '(characterp lambda)))
:to-throw 'error '("CAUTION: Link not opened because unsafe title parameter detected: (lambda (_ _) (error \"UNSAFE\"))")))
(it "Errors for an expression"
(expect (open-link expression-link)
:to-throw 'wrong-type-argument '(characterp error))))
:to-throw 'error '("CAUTION: Link not opened because unsafe title parameter detected: (error \"UNSAFE\")"))))

(describe "sort parameter"
:var ((quoted-lambda-link "[[org-ql-search:todo:?sort%3D%28lambda%20%28_%20_%29%20%28error%20%22UNSAFE%22%29%29]]")
Expand Down

0 comments on commit 1c8c89f

Please sign in to comment.