From acd7a66c79878275e7bda307ee07825877b85bbf Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Wed, 14 Jan 2015 23:13:28 -0200 Subject: Fix find in buffer --- sx.el | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/sx.el b/sx.el index d6c5335..8ae7a65 100644 --- a/sx.el +++ b/sx.el @@ -282,17 +282,22 @@ ID. TYPE is either question, answer, or comment. ID is an integer." - (goto-char (point-min)) - (let (done) - (while (not done) - (let-alist (sx--goto-property-change 'sx--data-here 1) - (setq done (or (eobp) - (= id (cl-case type - (answer .answer_id) - (comment .comment_id) - (question .question_id))))))) - (unless done - (sx-message "Can't find the specified %s" type)))) + (let* ((id-symbol (cl-case type + (answer 'answer_id) + (comment 'comment_id) + (question 'question_id))) + (pos + (save-excursion + (goto-char (point-min)) + (while (not (or (eobp) + (let ((data (sx--data-here type t))) + (and data + (= id (or (cdr (assq id-symbol data)))))))) + (forward-char 1)) + (point)))) + (if (equal pos (point-max)) + (sx-message "Can't find the specified %s" type) + (goto-char pos)))) ;;; Printing request data -- cgit v1.2.3