* erc-button.el (erc-button-next-function): Scoping fix (Bug#9487).
[bpt/emacs.git] / lisp / erc / erc-button.el
index 3a89734..7fbbbc3 100644 (file)
@@ -430,19 +430,19 @@ call it with the value of the `erc-data' text property."
 (defun erc-button-next-function ()
   "Pseudo completion function that actually jumps to the next button.
 For use on `completion-at-point-functions'."
-  (let ((here (point)))
-    (when (< here (erc-beg-of-input-line))
-      (lambda ()
-        (while (and (get-text-property here 'erc-callback)
-                    (not (= here (point-max))))
-          (setq here (1+ here)))
-        (while (and (not (get-text-property here 'erc-callback))
-                    (not (= here (point-max))))
-          (setq here (1+ here)))
-        (if (< here (point-max))
-            (goto-char here)
-          (error "No next button"))
-        t))))
+    (when (< (point) (erc-beg-of-input-line))
+      `(lambda ()
+         (let ((here ,(point)))
+           (while (and (get-text-property here 'erc-callback)
+                       (not (= here (point-max))))
+             (setq here (1+ here)))
+           (while (and (not (get-text-property here 'erc-callback))
+                       (not (= here (point-max))))
+             (setq here (1+ here)))
+           (if (< here (point-max))
+               (goto-char here)
+             (error "No next button"))
+           t))))
 
 (defun erc-button-next ()
   "Go to the next button in this buffer."