aboutsummaryrefslogtreecommitdiff
path: root/sx.el
diff options
context:
space:
mode:
authorArtur Malabarba <bruce.connor.am@gmail.com>2015-01-14 23:13:28 -0200
committerArtur Malabarba <bruce.connor.am@gmail.com>2015-01-14 23:13:28 -0200
commitacd7a66c79878275e7bda307ee07825877b85bbf (patch)
tree534d72b02378fdcf3cf002fe47bbc2ff5f653ddc /sx.el
parentfc5f8f95844c0cc00ee7038c5a577b641de68939 (diff)
Fix find in buffer
Diffstat (limited to 'sx.el')
-rw-r--r--sx.el27
1 files 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