summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYoni Rabkin <yoni@rabkins.net>2020-12-11 14:29:00 -0500
committerYoni Rabkin <yoni@rabkins.net>2020-12-11 14:29:00 -0500
commitd567c5942a06fa2604d065101c990d3743bf5f13 (patch)
tree25e6e3118731137f0de1d36aab845a7662baaf6c
parenta99fc59d344d3819972f87674bf93f90ca0d7c03 (diff)
* rt-liberation.el: fix n/p in viewer2
Not the best solution, but one that reliably works.
-rw-r--r--rt-liberation.el39
1 files changed, 23 insertions, 16 deletions
diff --git a/rt-liberation.el b/rt-liberation.el
index 3c2962f..d708f43 100644
--- a/rt-liberation.el
+++ b/rt-liberation.el
@@ -243,6 +243,9 @@ This variable is made buffer local for the ticket history")
(defvar rt-liber-display-ticket-at-point-f 'rt-liber-viewer2-display-ticket-at-point
"Function for displaying ticket at point in the browser.")
+(defvar rt-liber-viewer2-section-regexp "^Ticket [0-9]+ by "
+ "Regular expression to match a section in the viewer.")
+
(defvar rt-liber-viewer2-recenter 4
"Argument passed to `recenter' in the viewer.")
@@ -1521,25 +1524,29 @@ ASSOC-BROWSER if non-nil should be a ticket browser."
(defun rt-liber-viewer2-next-section-in ()
(interactive)
- (forward-line)
- (let ((next (next-single-property-change
- (point)
- 'rt-liberation-viewer-header)))
- (if (not next)
- (message "no next section")
- (goto-char next)
- (recenter rt-liber-viewer2-recenter))))
+ (when (looking-at rt-liber-viewer2-section-regexp)
+ (goto-char (1+ (point))))
+ (let ((next (re-search-forward rt-liber-viewer2-section-regexp
+ (point-max)
+ t)))
+ (cond ((not next)
+ (message "no next section"))
+ (t
+ (recenter rt-liber-viewer2-recenter)))
+ (goto-char (point-at-bol))))
(defun rt-liber-viewer2-previous-section-in ()
(interactive)
- (let ((prev (previous-single-property-change
- (point-at-bol)
- 'rt-liberation-viewer-header)))
- (if (not prev)
- (message "no previous section")
- (goto-char prev)
- (forward-line -1)
- (recenter rt-liber-viewer2-recenter))))
+ (when (looking-at rt-liber-viewer2-section-regexp)
+ (goto-char (1- (point))))
+ (let ((prev (re-search-backward rt-liber-viewer2-section-regexp
+ (point-min)
+ t)))
+ (cond ((not prev)
+ (message "no previous section"))
+ (t
+ (recenter rt-liber-viewer2-recenter)))
+ (goto-char (point-at-bol))))
(defun rt-liber-viewer2-answer ()
(interactive)