From b88e19f07741e19440857801eadac528dcc95348 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Bernardy Date: Mon, 29 Apr 2019 21:37:09 +0200 Subject: [PATCH] fix #53 --- boon-arguments.el | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/boon-arguments.el b/boon-arguments.el index 62ddd9b..50e2b89 100644 --- a/boon-arguments.el +++ b/boon-arguments.el @@ -98,19 +98,20 @@ This item is either the symbol at point, or, if this fails, the sexp at point." (defun boon-select-n-copies (count thing) "Return list of regions with COUNT copies of the THING." (lambda() (save-mark-and-excursion - (let* ((bnds (bounds-of-thing-at-point thing)) - (what (buffer-substring-no-properties (car bnds) (cdr bnds))) - (local-count count) - ;; local-count variable necessary because the argument - ;; is shared between all calls to this closure. - (result nil)) - (goto-char (car bnds)) - (while (and (> local-count 0) (search-forward what nil t)) - (setq local-count (1- local-count)) - (push (boon-mk-reg (match-beginning 0) - (match-end 0)) - result)) - result)))) + (let ((bnds (bounds-of-thing-at-point thing))) + (unless bnds (error "No %s found at point" thing)) + (let* ((what (buffer-substring-no-properties (car bnds) (cdr bnds))) + (local-count count) + ;; local-count variable necessary because the argument + ;; is shared between all calls to this closure. + (result nil)) + (goto-char (car bnds)) + (while (and (> local-count 0) (search-forward what nil t)) + (setq local-count (1- local-count)) + (push (boon-mk-reg (match-beginning 0) + (match-end 0)) + result)) + result))))) (defun boon-select-document () (interactive) (lambda () (boon-regs-from-bounds (cons (point-min) (point-max))))) (defun boon-select-paragraph (count) (interactive "p") (boon-select-n count 'paragraph))