Subject: bug#9487: 24.0.50; forward search link broken in ERC

From: Antoine Levitt <[email-masked]>
Date: Mon, 12 Sep 2011 21:18:41 +0200

12/09/11 20:29, Ivan Kanis
> Launch ERC and wait for someone to post a link
> Move to the top of the buffer
> Press TAB
>
> I get the following error:
>
> Debugger entered--Lisp error: (void-variable here)
>   call-interactively(erc-button-next nil nil)

Confirmed. It looks like a lexical vs dynamic binding issue, apparently
introduced by commit 104018. The following fixes it for me, but I'm not
sure whether the preferred way of fixing this is the patch, or turning
lexical-binding on. Stefan?

=== modified file 'lisp/erc/erc-button.el'
--- lisp/erc/erc-button.el	2011-04-26 13:50:09 +0000
+++ lisp/erc/erc-button.el	2011-09-12 19:16:01 +0000
@@ -430,19 +430,19 @@
 (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."