Add/Fix: org-ql-view-mode, and check when refreshing

Use a derived major mode for org-ql-view buffers, and ensure that mode
is active when calling org-ql-view-refresh, to avoid interfering with
buffers in other modes if the user calls the command by accident.

See
<b87156f2bb>.
Thanks to Alois Janíček (@AloisJanicek) for discovering the bug.

Released as 0.4.3.
This commit is contained in:
Adam Porter 2020-03-14 13:53:46 -05:00
parent 4b1e253ee9
commit ba7d4a2e82
4 changed files with 77 additions and 56 deletions

View file

@ -398,6 +398,11 @@ Expands into a call to ~org-ql-select~ with the same arguments. For convenience
/Note:/ Breaking changes may be made before version 1.0, but in the event of major changes, attempts at backward compatibility will be made with obsolescence declarations, translation of arguments, etc. Users who need stability guarantees before 1.0 may choose to use tagged stable releases. /Note:/ Breaking changes may be made before version 1.0, but in the event of major changes, attempts at backward compatibility will be made with obsolescence declarations, translation of arguments, etc. Users who need stability guarantees before 1.0 may choose to use tagged stable releases.
** 0.4.3
*Fixed*
+ When =org-ql-view-refresh= is called, ensure the buffer is an Org QL View buffer.
** 0.4.2 ** 0.4.2
*Fixed* *Fixed*

View file

@ -309,6 +309,8 @@ TYPE may be `ts', `ts-active', `ts-inactive', `clocked', or
If PROMPT is non-nil (interactively, with prefix), prompt to If PROMPT is non-nil (interactively, with prefix), prompt to
update search arguments." update search arguments."
(interactive "P") (interactive "P")
(unless (eq major-mode 'org-ql-view-mode)
(user-error "Not an Org QL View buffer"))
(let* ((current-line (buffer-substring-no-properties (line-beginning-position) (line-end-position))) (let* ((current-line (buffer-substring-no-properties (line-beginning-position) (line-end-position)))
(old-pos (point)) (old-pos (point))
(defaults (list org-ql-view-buffers-files (defaults (list org-ql-view-buffers-files
@ -354,6 +356,10 @@ update search arguments."
;;;; Functions ;;;; Functions
(define-derived-mode org-ql-view-mode org-agenda-mode "Org QL View"
"Major mode for `org-ql-view' buffers."
(setf buffer-read-only t))
(defun org-ql-view--list-buffer () (defun org-ql-view--list-buffer ()
"Return view list buffer." "Return view list buffer."
(with-current-buffer (get-buffer-create "*Org QL View List*") (with-current-buffer (get-buffer-create "*Org QL View List*")
@ -468,9 +474,8 @@ with human-readable strings."
If NAME is non-nil, return buffer by that name instead of using If NAME is non-nil, return buffer by that name instead of using
default buffer." default buffer."
(with-current-buffer (get-buffer-create (or name (concat org-ql-view-buffer-name-prefix "*"))) (with-current-buffer (get-buffer-create (or name (concat org-ql-view-buffer-name-prefix "*")))
(unless (eq major-mode 'org-agenda-mode) (unless (eq major-mode 'org-ql-view-mode)
(org-agenda-mode) (org-ql-view-mode))
(setf buffer-read-only t))
(current-buffer))) (current-buffer)))
(defun org-ql-view--format-relative-date (difference) (defun org-ql-view--format-relative-date (difference)

View file

@ -2,7 +2,7 @@
;; Author: Adam Porter <adam@alphapapa.net> ;; Author: Adam Porter <adam@alphapapa.net>
;; Url: https://github.com/alphapapa/org-ql ;; Url: https://github.com/alphapapa/org-ql
;; Version: 0.4.2 ;; Version: 0.4.3
;; Package-Requires: ((emacs "26.1") (dash "2.13") (dash-functional "1.2.0") (f "0.17.2") (org "9.0") (org-super-agenda "1.2-pre") (ov "1.0.6") (peg "0.6") (s "1.12.0") (ts "0.2-pre")) ;; Package-Requires: ((emacs "26.1") (dash "2.13") (dash-functional "1.2.0") (f "0.17.2") (org "9.0") (org-super-agenda "1.2-pre") (ov "1.0.6") (peg "0.6") (s "1.12.0") (ts "0.2-pre"))
;; Keywords: hypermedia, outlines, Org, agenda ;; Keywords: hypermedia, outlines, Org, agenda

View file

@ -63,6 +63,7 @@ Functions / Macros
Changelog Changelog
* 0.4.3: 043.
* 0.4.2: 042. * 0.4.2: 042.
* 0.4.1: 041. * 0.4.1: 041.
* 0.4: 04. * 0.4: 04.
@ -95,9 +96,7 @@ File: README.info, Node: Contents, Next: Screenshots, Prev: Top, Up: Top
1 Contents 1 Contents
********** **********
• • • • • • • •
• •
• • • • • •
 
File: README.info, Node: Screenshots, Next: Installation, Prev: Contents, Up: Top File: README.info, Node: Screenshots, Next: Installation, Prev: Contents, Up: Top
@ -705,6 +704,7 @@ releases.
* Menu: * Menu:
* 0.4.3: 043.
* 0.4.2: 042. * 0.4.2: 042.
* 0.4.1: 041. * 0.4.1: 041.
* 0.4: 04. * 0.4: 04.
@ -718,9 +718,19 @@ releases.
* 0.1: 01. * 0.1: 01.
 
File: README.info, Node: 042, Next: 041, Up: Changelog File: README.info, Node: 043, Next: 042, Up: Changelog
5.1 0.4.2 5.1 0.4.3
=========
*Fixed*
• When org-ql-view-refresh is called, ensure the buffer is an Org QL
View buffer.

File: README.info, Node: 042, Next: 041, Prev: 043, Up: Changelog
5.2 0.4.2
========= =========
*Fixed* *Fixed*
@ -729,7 +739,7 @@ File: README.info, Node: 042, Next: 041, Up: Changelog
 
File: README.info, Node: 041, Next: 04, Prev: 042, Up: Changelog File: README.info, Node: 041, Next: 04, Prev: 042, Up: Changelog
5.2 0.4.1 5.3 0.4.1
========= =========
*Fixed* *Fixed*
@ -739,7 +749,7 @@ File: README.info, Node: 041, Next: 04, Prev: 042, Up: Changelog
 
File: README.info, Node: 04, Next: 032, Prev: 041, Up: Changelog File: README.info, Node: 04, Next: 032, Prev: 041, Up: Changelog
5.3 0.4 5.4 0.4
======= =======
_Note:_ The next release, 0.5, may include changes which will require _Note:_ The next release, 0.5, may include changes which will require
@ -820,7 +830,7 @@ as they will be pushed to the master branch when ready.
 
File: README.info, Node: 032, Next: 031, Prev: 04, Up: Changelog File: README.info, Node: 032, Next: 031, Prev: 04, Up: Changelog
5.4 0.3.2 5.5 0.3.2
========= =========
*Fixed* *Fixed*
@ -833,7 +843,7 @@ File: README.info, Node: 032, Next: 031, Prev: 04, Up: Changelog
 
File: README.info, Node: 031, Next: 03, Prev: 032, Up: Changelog File: README.info, Node: 031, Next: 03, Prev: 032, Up: Changelog
5.5 0.3.1 5.6 0.3.1
========= =========
*Fixed* *Fixed*
@ -843,7 +853,7 @@ File: README.info, Node: 031, Next: 03, Prev: 032, Up: Changelog
 
File: README.info, Node: 03, Next: 023, Prev: 031, Up: Changelog File: README.info, Node: 03, Next: 023, Prev: 031, Up: Changelog
5.6 0.3 5.7 0.3
======= =======
*Added* *Added*
@ -908,7 +918,7 @@ File: README.info, Node: 03, Next: 023, Prev: 031, Up: Changelog
 
File: README.info, Node: 023, Next: 022, Prev: 03, Up: Changelog File: README.info, Node: 023, Next: 022, Prev: 03, Up: Changelog
5.7 0.2.3 5.8 0.2.3
========= =========
*Fixed* *Fixed*
@ -918,7 +928,7 @@ File: README.info, Node: 023, Next: 022, Prev: 03, Up: Changelog
 
File: README.info, Node: 022, Next: 021, Prev: 023, Up: Changelog File: README.info, Node: 022, Next: 021, Prev: 023, Up: Changelog
5.8 0.2.2 5.9 0.2.2
========= =========
*Fixed* *Fixed*
@ -929,8 +939,8 @@ File: README.info, Node: 022, Next: 021, Prev: 023, Up: Changelog
 
File: README.info, Node: 021, Next: 02, Prev: 022, Up: Changelog File: README.info, Node: 021, Next: 02, Prev: 022, Up: Changelog
5.9 0.2.1 5.10 0.2.1
========= ==========
*Fixed* *Fixed*
• (descendants) selector matched against parent heading instead of • (descendants) selector matched against parent heading instead of
@ -939,7 +949,7 @@ File: README.info, Node: 021, Next: 02, Prev: 022, Up: Changelog
 
File: README.info, Node: 02, Next: 01, Prev: 021, Up: Changelog File: README.info, Node: 02, Next: 01, Prev: 021, Up: Changelog
5.10 0.2 5.11 0.2
======== ========
*Added* *Added*
@ -1022,7 +1032,7 @@ File: README.info, Node: 02, Next: 01, Prev: 021, Up: Changelog
 
File: README.info, Node: 01, Prev: 02, Up: Changelog File: README.info, Node: 01, Prev: 02, Up: Changelog
5.11 0.1 5.12 0.1
======== ========
First tagged release. First tagged release.
@ -1083,42 +1093,43 @@ GPLv3
 
Tag Table: Tag Table:
Node: Top225 Node: Top225
Node: Contents1432 Node: Contents1447
Node: Screenshots1606 Node: Screenshots1574
Node: Installation1724 Node: Installation1692
Node: Quelpa2362 Node: Quelpa2330
Node: Usage2805 Node: Usage2773
Node: Commands3154 Node: Commands3122
Node: org-ql-search3627 Node: org-ql-search3595
Node: helm-org-ql5275 Node: helm-org-ql5243
Node: org-ql-view5687 Node: org-ql-view5655
Node: org-ql-view-sidebar5885 Node: org-ql-view-sidebar5853
Node: org-ql-view-recent-items6241 Node: org-ql-view-recent-items6209
Node: org-ql-sparse-tree6725 Node: org-ql-sparse-tree6693
Node: Queries7525 Node: Queries7493
Node: Non-sexp query syntax8433 Node: Non-sexp query syntax8401
Node: General predicates10140 Node: General predicates10108
Node: Ancestor/descendant predicates14947 Node: Ancestor/descendant predicates14915
Node: Date/time predicates16075 Node: Date/time predicates16043
Node: Functions / Macros18730 Node: Functions / Macros18698
Node: Agenda-like views18963 Node: Agenda-like views18931
Node: Listing / acting-on results20368 Node: Listing / acting-on results20336
Node: Changelog24970 Node: Changelog24938
Node: 04225529 Node: 04325512
Node: 04125676 Node: 04225695
Node: 0425915 Node: 04125854
Node: 03229846 Node: 0426093
Node: 03130223 Node: 03230024
Node: 0330418 Node: 03130401
Node: 02333391 Node: 0330596
Node: 02233617 Node: 02333569
Node: 02133883 Node: 02233795
Node: 0234080 Node: 02134061
Node: 0138115 Node: 0234260
Node: Notes38216 Node: 0138295
Node: Comparison with Org Agenda searches38378 Node: Notes38396
Node: org-sidebar39249 Node: Comparison with Org Agenda searches38558
Node: License39528 Node: org-sidebar39429
Node: License39708
 
End Tag Table End Tag Table