X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/ac3232837188f7e1c4ffe34b76edede0ccb54f5e..873bc1329fe303cff442efbfe3a25c62ef67099e:/lisp/erc/erc-list.el diff --git a/lisp/erc/erc-list.el b/lisp/erc/erc-list.el index dfbda0daf9..6787787861 100644 --- a/lisp/erc/erc-list.el +++ b/lisp/erc/erc-list.el @@ -1,9 +1,10 @@ -;;; erc-list.el --- /list support for ERC +;;; erc-list.el --- /list support for ERC -*- lexical-binding:t -*- -;; Copyright (C) 2008 Free Software Foundation, Inc. +;; Copyright (C) 2008-2014 Free Software Foundation, Inc. ;; Author: Tom Tromey -;; Version: 0.1 +;; Maintainer: emacs-devel@gnu.org +;; Old-Version: 0.1 ;; Keywords: comm ;; This file is part of GNU Emacs. @@ -29,6 +30,10 @@ (require 'erc) +(defgroup erc-list nil + "Support for the /list command." + :group 'erc) + ;; This is implicitly the width of the channel name column. Pick ;; something small enough that the topic has a chance of being ;; readable, but long enough that most channel names won't make for @@ -117,27 +122,23 @@ (sort-fields col (point-min) (point-max)) (sort-numeric-fields col (point-min) (point-max)))))) -(defvar erc-list-menu-mode-map nil +(defvar erc-list-menu-mode-map + (let ((map (make-keymap))) + (set-keymap-parent map special-mode-map) + (define-key map "k" 'erc-list-kill) + (define-key map "j" 'erc-list-join) + (define-key map "g" 'erc-list-revert) + (define-key map "n" 'next-line) + (define-key map "p" 'previous-line) + map) "Local keymap for `erc-list-mode' buffers.") -(unless erc-list-menu-mode-map - (setq erc-list-menu-mode-map (make-keymap)) - (suppress-keymap erc-list-menu-mode-map) - (define-key erc-list-menu-mode-map "k" 'erc-list-kill) - (define-key erc-list-menu-mode-map "j" 'erc-list-join) - (define-key erc-list-menu-mode-map "g" 'erc-list-revert) - (define-key erc-list-menu-mode-map "n" 'next-line) - (define-key erc-list-menu-mode-map "p" 'previous-line) - (define-key erc-list-menu-mode-map "q" 'quit-window)) - -(defvar erc-list-menu-sort-button-map nil - "Local keymap for ERC list menu mode sorting buttons.") - -(unless erc-list-menu-sort-button-map +(defvar erc-list-menu-sort-button-map (let ((map (make-sparse-keymap))) (define-key map [header-line mouse-1] 'erc-list-menu-sort-by-column) (define-key map [follow-link] 'mouse-face) - (setq erc-list-menu-sort-button-map map))) + map) + "Local keymap for ERC list menu mode sorting buttons.") ;; Helper function that makes a buttonized column header. (defun erc-list-button (title column) @@ -147,7 +148,7 @@ 'mouse-face 'highlight 'keymap erc-list-menu-sort-button-map)) -(define-derived-mode erc-list-menu-mode nil "ERC-List" +(define-derived-mode erc-list-menu-mode special-mode "ERC-List" "Major mode for editing a list of irc channels." (setq header-line-format (concat @@ -163,7 +164,8 @@ ;; Handle a "322" response. This response tells us about a single ;; channel. -(defun erc-list-handle-322 (proc parsed) +;; Called via erc-once-with-server-event with two arguments. +(defun erc-list-handle-322 (_proc parsed) (let* ((args (cdr (erc-response.command-args parsed))) (channel (car args)) (nusers (car (cdr args))) @@ -182,7 +184,7 @@ ;; Arrange for 323 (end of list) to end this. (erc-once-with-server-event 323 - '(progn + (lambda (_proc _parsed) (remove-hook 'erc-server-322-functions 'erc-list-handle-322 t))) ;; Find the list buffer, empty it, and display it. (set (make-local-variable 'erc-list-buffer) @@ -208,15 +210,18 @@ should usually be one or more channels, separated by commas. Please note that this function only works with IRC servers which conform to RFC and send the LIST header (#321) at start of list transmission." (erc-with-server-buffer - (set (make-local-variable 'erc-list-last-argument) line) - (erc-once-with-server-event - 321 - (list 'progn - (list 'erc-list-install-322-handler (current-buffer))))) + (set (make-local-variable 'erc-list-last-argument) line) + (erc-once-with-server-event + 321 + (let ((buf (current-buffer))) + (lambda (_proc _parsed) + (erc-list-install-322-handler buf))))) (erc-server-send (concat "LIST :" (or (and line (substring line 1)) "")))) (put 'erc-cmd-LIST 'do-not-parse-args t) +(provide 'erc-list) + ;;; erc-list.el ends here ;; ;; Local Variables: @@ -224,4 +229,3 @@ to RFC and send the LIST header (#321) at start of list transmission." ;; tab-width: 8 ;; End: -;; arch-tag: 99c5f9cb-6bac-4224-86bf-e394768cd1d0