From: Dmitry Gutov Date: Sat, 30 Jun 2012 00:52:38 +0000 (+0400) Subject: Abort when diff buffer is empty X-Git-Url: https://code.delx.au/gnu-emacs-elpa/commitdiff_plain/21530240c963d3e9caff5772a369d993bfb99da4 Abort when diff buffer is empty --- diff --git a/diff-hl.el b/diff-hl.el index 384f91e7c..9c0f4652a 100644 --- a/diff-hl.el +++ b/diff-hl.el @@ -182,20 +182,21 @@ (vc-exec-after `(diff-hl-diff-skip-to ,line)))) (defun diff-hl-diff-skip-to (line) - (diff-beginning-of-hunk t) - (let (found) - (while (and (looking-at diff-hunk-header-re-unified) (not found)) - (let ((hunk-line (string-to-number (match-string 3))) - (len (let ((m (match-string 4))) - (if m (string-to-number m) 1)))) - (if (> line (+ hunk-line len)) - (diff-end-of-hunk) - (setq found t) - (let ((to-go (1+ (- line hunk-line)))) - (while (plusp to-go) - (forward-line 1) - (unless (looking-at "^-") - (decf to-go))))))))) + (unless (eobp) + (diff-beginning-of-hunk t) + (let (found) + (while (and (looking-at diff-hunk-header-re-unified) (not found)) + (let ((hunk-line (string-to-number (match-string 3))) + (len (let ((m (match-string 4))) + (if m (string-to-number m) 1)))) + (if (> line (+ hunk-line len)) + (diff-end-of-hunk) + (setq found t) + (let ((to-go (1+ (- line hunk-line)))) + (while (plusp to-go) + (forward-line 1) + (unless (looking-at "^-") + (decf to-go)))))))))) ;;;###autoload (define-minor-mode diff-hl-mode