From 07c135a7ce5769dd2cf3076eab790d2514fef97d Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Wed, 26 Apr 2023 23:43:53 +1000 Subject: Adding functions to navigate to the next and previous failures. Also updated keybindings: n/p for next/previous failures; M-n/M-p for next/previous header; f/b for next/previous header of the same thing. --- buildbot-view.el | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/buildbot-view.el b/buildbot-view.el index 214444d..a45aa60 100644 --- a/buildbot-view.el +++ b/buildbot-view.el @@ -36,7 +36,15 @@ (end-of-line 1) (re-search-forward buildbot-view-header-regex) (beginning-of-line 1))) -(define-key buildbot-view-mode-map "n" 'buildbot-view-next-header) +(define-key buildbot-view-mode-map (kbd "M-n") 'buildbot-view-next-header) + +(defun buildbot-view-next-failed-header (n) + (interactive "p") + (dotimes (_ n) + (end-of-line 1) + (text-property-search-forward 'face 'error) + (beginning-of-line 1))) +(define-key buildbot-view-mode-map "n" 'buildbot-view-next-failed-header) (defun buildbot-view-next-header-same-thing (n) (interactive "p") @@ -46,7 +54,7 @@ (buildbot-view-next-header 1) (while (not (eq (get-text-property (point) 'type) type)) (buildbot-view-next-header 1))))) -(define-key buildbot-view-mode-map (kbd "M-n") +(define-key buildbot-view-mode-map "f" 'buildbot-view-next-header-same-thing) (defun buildbot-view-previous-header (n) @@ -56,7 +64,17 @@ (re-search-backward buildbot-view-header-regex)) (dotimes (_ n) (re-search-backward buildbot-view-header-regex))) -(define-key buildbot-view-mode-map "p" 'buildbot-view-previous-header) +(define-key buildbot-view-mode-map (kbd "M-p") 'buildbot-view-previous-header) + +(defun buildbot-view-previous-failed-header (n) + (interactive "p") + (beginning-of-line 1) + (unless (looking-at buildbot-view-header-regex) + (re-search-backward buildbot-view-header-regex)) + (dotimes (_ n) + (text-property-search-backward 'face 'error)) + (beginning-of-line 1)) +(define-key buildbot-view-mode-map "p" 'buildbot-view-previous-failed-header) (defun buildbot-view-previous-header-same-thing (n) (interactive "p") @@ -66,7 +84,7 @@ (buildbot-view-previous-header 1) (while (not (eq (get-text-property (point) 'type) type)) (buildbot-view-previous-header 1))))) -(define-key buildbot-view-mode-map (kbd "M-p") +(define-key buildbot-view-mode-map (kbd "b") 'buildbot-view-previous-header-same-thing) (defun buildbot-view-format-revision-info (revision-info) -- cgit v1.2.3