Add: (defface org-ql-view-title) Use in -view--header-line-format

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.
This commit is contained in:
Adam Porter 2024-09-10 22:11:10 -05:00
parent c3519fb4a0
commit 1c8c89f264
4 changed files with 65 additions and 52 deletions

View file

@ -556,6 +556,9 @@ Simple links may also be written manually in either sexp or non-sexp form, like:
** 0.9-pre ** 0.9-pre
*Additions*
+ Face ~org-ql-view-title~, applied to view titles in header line.
*Changes* *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.) + 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~. + Function ~org-ql-completing-read~ accepts a new ~NARROWP~ argument, which is passed to ~org-ql-select~.

View file

@ -59,6 +59,10 @@
"Face for due dates in `org-ql-view' views." "Face for due dates in `org-ql-view' views."
:group 'org-ql) :group 'org-ql)
(defface org-ql-view-title '((t :weight bold))
"View title in header line."
:group 'org-ql-view)
;;;; Variables ;;;; Variables
(defvar org-ql-view-buffer-name-prefix "*Org QL View:" (defvar org-ql-view-buffer-name-prefix "*Org QL View:"
@ -459,7 +463,8 @@ subsequent refreshing of the buffer: `org-ql-view-buffers-files',
If TITLE, prepend it to the header." If TITLE, prepend it to the header."
(let* ((title (if title (let* ((title (if title
(concat (propertize "View:" 'face 'transient-argument) (concat (propertize "View:" 'face 'transient-argument)
title " ") (propertize title 'face 'org-ql-view-title)
" ")
"")) ""))
(query-formatted (when query (query-formatted (when query
(org-ql-view--format-query query))) (org-ql-view--format-query query)))
@ -645,6 +650,8 @@ purposes of compatibility with changes in Org 9.4."
(stringp buffers-files) (stringp buffers-files)
(cl-every #'stringp buffers-files)) (cl-every #'stringp buffers-files))
(error "CAUTION: Link not opened because unsafe buffers-files parameter detected: %s" 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) (when (or (listp query)
(string-match (rx bol (0+ space) "(") query)) (string-match (rx bol (0+ space) "(") query))
;; SAFETY: Query is in sexp form: ask for confirmation, because it could contain arbitrary code. ;; SAFETY: Query is in sexp form: ask for confirmation, because it could contain arbitrary code.

View file

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

View file

@ -1986,13 +1986,13 @@ with keyword arg NOW in PLIST."
(expression-link "[[org-ql-search:todo:?title%3D%28error%20%22UNSAFE%22%29]]")) (expression-link "[[org-ql-search:todo:?title%3D%28error%20%22UNSAFE%22%29]]"))
(it "Errors for a quoted lambda" (it "Errors for a quoted lambda"
(expect (open-link quoted-lambda-link) (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" (it "Errors for an unquoted lambda"
(expect (open-link unquoted-lambda-link) (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" (it "Errors for an expression"
(expect (open-link expression-link) (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" (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]]") :var ((quoted-lambda-link "[[org-ql-search:todo:?sort%3D%28lambda%20%28_%20_%29%20%28error%20%22UNSAFE%22%29%29]]")