diff options
author | Artur Malabarba <bruce.connor.am@gmail.com> | 2015-01-14 22:47:44 -0200 |
---|---|---|
committer | Artur Malabarba <bruce.connor.am@gmail.com> | 2015-01-14 22:47:44 -0200 |
commit | cd215e056fd092bef5c0867ecd151107516cac09 (patch) | |
tree | 2eaf5334faff91ca2790420b7594709e9cd0249f /sx.el | |
parent | 344db027640cde39888c5fe4e4e4228b1308f95d (diff) |
Implement sx--find-in-buffer
Diffstat (limited to 'sx.el')
-rw-r--r-- | sx.el | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -274,6 +274,26 @@ If DIRECTION is negative, move backwards instead." (goto-char (funcall func (point) prop nil limit)) (get-text-property (point) prop))) +(defun sx--find-in-buffer (type id) + "Move point to an object of TYPE and ID. +That is, move forward from beginning of buffer until +`sx--data-here' is an object of type TYPE with the respective id +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)))) + ;;; Printing request data (defvar sx--overlays nil |