]> code.delx.au - gnu-emacs/blobdiff - lisp/erc/erc-button.el
Update copyright year to 2015
[gnu-emacs] / lisp / erc / erc-button.el
index 3a897347dea3ab64e56a71b133e9fe5085312e67..380ea7c3d8c37dced9f30a8b878f0ef74ff9c78b 100644 (file)
@@ -1,8 +1,9 @@
-;; erc-button.el --- A way of buttonizing certain things in ERC buffers
+;; erc-button.el --- A way of buttonizing certain things in ERC buffers  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1996-2004, 2006-2011 Free Software Foundation, Inc.
+;; Copyright (C) 1996-2004, 2006-2015 Free Software Foundation, Inc.
 
 ;; Author: Mario Lang <mlang@delysid.org>
+;; Maintainer: emacs-devel@gnu.org
 ;; Keywords: irc, button, url, regexp
 ;; URL: http://www.emacswiki.org/cgi-bin/wiki.pl?ErcButton
 
@@ -25,7 +26,7 @@
 
 ;; Heavily borrowed from gnus-art.el. Thanks to the original authors.
 ;; This buttonizes nicks and other stuff to make it all clickable.
-;; To enable, add to your ~/.emacs:
+;; To enable, add to your init file:
 ;; (require 'erc-button)
 ;; (erc-button-mode 1)
 ;;
@@ -66,7 +67,7 @@
 
 ;;; Variables
 
-(defface erc-button '((t (:bold t)))
+(defface erc-button '((t :weight bold))
   "ERC button face."
   :group 'erc-faces)
 
@@ -115,13 +116,13 @@ longer than `erc-fill-column'."
   :type 'boolean)
 
 (defcustom erc-button-rfc-url "http://www.faqs.org/rfcs/rfc%s.html"
-  "*URL used to browse rfc references.
+  "URL used to browse rfc references.
 %s is replaced by the number."
   :group 'erc-button
   :type 'string)
 
 (defcustom erc-button-google-url "http://www.google.com/search?q=%s"
-  "*URL used to browse Google search references.
+  "URL used to browse Google search references.
 %s is replaced by the search string."
   :group 'erc-button
   :type 'string)
@@ -134,7 +135,7 @@ longer than `erc-fill-column'."
   '(('nicknames 0 erc-button-buttonize-nicks erc-nick-popup 0)
     (erc-button-url-regexp 0 t browse-url 0)
     ("<URL: *\\([^<> ]+\\) *>" 0 t browse-url 1)
-    ("(\\(\\([^~\n \t@][^\n \t@]*\\)@\\([a-zA-Z0-9.:-]+\\)\\)" 1 t finger 2 3)
+;;; ("(\\(\\([^~\n \t@][^\n \t@]*\\)@\\([a-zA-Z0-9.:-]+\\)\\)" 1 t finger 2 3)
     ;; emacs internal
     ("[`]\\([a-zA-Z][-a-zA-Z_0-9]+\\)[']" 1 t erc-button-describe-symbol 1)
     ;; pseudo links
@@ -155,7 +156,7 @@ longer than `erc-fill-column'."
      1)
     ;; other
     ("\\s-\\(@\\([0-9][0-9][0-9]\\)\\)" 1 t erc-button-beats-to-time 2))
-  "*Alist of regexps matching buttons in ERC buffers.
+  "Alist of regexps matching buttons in ERC buffers.
 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
 
 REGEXP is the string matching text around the button or a symbol
@@ -182,11 +183,14 @@ PAR is a number of a regexp grouping whose text will be passed to
   'nicknames, these are ignored, and CALLBACK will be called with
   the nickname matched as the argument."
   :group 'erc-button
+  :version "24.1"                       ; remove finger (bug#4443)
   :type '(repeat
           (list :tag "Button"
                 (choice :tag "Matches"
                         regexp
                         (variable :tag "Variable containing regexp")
+                        ;; FIXME It really does mean 'nicknames
+                        ;; rather than just nicknames.
                         (const :tag "Nicknames" 'nicknames))
                 (integer :tag "Number of the regexp section that matches")
                 (choice :tag "When to buttonize"
@@ -198,12 +202,12 @@ PAR is a number of a regexp grouping whose text will be passed to
                         (integer :tag "Regexp section number")))))
 
 (defcustom erc-emacswiki-url "http://www.emacswiki.org/cgi-bin/wiki.pl?"
-  "*URL of the EmacsWiki Homepage."
+  "URL of the EmacsWiki Homepage."
   :group 'erc-button
   :type 'string)
 
 (defcustom erc-emacswiki-lisp-url "http://www.emacswiki.org/elisp/"
-  "*URL of the EmacsWiki ELisp area."
+  "URL of the EmacsWiki ELisp area."
   :group 'erc-button
   :type 'string)
 
@@ -265,7 +269,7 @@ specified by `erc-button-alist'."
             (inhibit-point-motion-hooks t)
             (inhibit-field-text-motion t)
             (alist erc-button-alist)
-            entry regexp data)
+            regexp)
         (erc-button-remove-old-buttons)
         (dolist (entry alist)
           (if (equal (car entry) (quote (quote nicknames)))
@@ -405,7 +409,7 @@ REGEXP is the regular expression which matched for this button."
 ;; Since Emacs runs this directly, rather than with
 ;; widget-button-click, we need to fake an extra arg in the
 ;; interactive spec.
-(defun erc-button-click-button (ignore event)
+(defun erc-button-click-button (_ignore event)
   "Call `erc-button-press-button'."
   (interactive "P\ne")
   (save-excursion
@@ -414,7 +418,7 @@ REGEXP is the regular expression which matched for this button."
 
 ;; XEmacs calls this via widget-button-press with a bunch of arguments
 ;; which we don't care about.
-(defun erc-button-press-button (&rest ignore)
+(defun erc-button-press-button (&rest _ignore)
   "Check text at point for a callback function.
 If the text at point has a `erc-callback' property,
 call it with the value of the `erc-data' text property."
@@ -430,19 +434,22 @@ 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))
+  ;; FIXME: This is an abuse of completion-at-point-functions.
+  (when (< (point) (erc-beg-of-input-line))
+    (let ((start (point)))
       (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))))
+        (let ((here start))
+          ;; FIXME: Use next-single-property-change.
+          (while (and (get-text-property here 'erc-callback)
+                      (not (= here (point-max))))
+            (setq here (1+ here)))
+          (while (not (or (get-text-property here 'erc-callback)
+                          (= 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."
@@ -488,7 +495,7 @@ For use on `completion-at-point-functions'."
     ("Query" . (erc-cmd-QUERY nick))
     ("Whois" . (erc-cmd-WHOIS nick))
     ("Lastlog" . (erc-cmd-LASTLOG nick)))
-  "*An alist of possible actions to take on a nickname.
+  "An alist of possible actions to take on a nickname.
 An entry looks like (\"Action\" . SEXP) where SEXP is evaluated with
 the variable `nick' bound to the nick in question.
 
@@ -509,7 +516,7 @@ Examples:
          (code (cdr (assoc action erc-nick-popup-alist))))
     (when code
       (erc-set-active-buffer (current-buffer))
-      (eval code))))
+      (eval code `((nick . ,nick))))))
 
 ;;; Callback functions
 (defun erc-button-describe-symbol (symbol-name)