Commit d0fcaff5 authored by Stefan Monnier's avatar Stefan Monnier

* lisp/erc/erc.el: Use lexical-binding.

(erc-user-full-name): Minor CSE simplification.
(erc-mode-map): Assume command-remapping is available.
(erc-once-with-server-event): Replace `forms' arg with a function arg.
(erc-once-with-server-event-global): Remove.
(erc-ison-p): Adjust to change in erc-once-with-server-event.
(erc-get-buffer-create): Remove arg `proc'.
(iswitchb-make-buflist-hook): Declare.
(erc-setup-buffer): Use pcase; avoid ((lambda ..) ..).
(read-passwd): Assume it exists.
(erc-display-line, erc-cmd-IDLE): Avoid add-to-list, adjust to change
in erc-once-with-server-event.
(erc-cmd-JOIN, erc-set-channel-limit, erc-set-channel-key)
(erc-add-query): Minor CSE simplification.
(erc-cmd-BANLIST, erc-cmd-MASSUNBAN): Adjust to change
in erc-once-with-server-event.
(erc-echo-notice-in-user-and-target-buffers): Avoid add-to-list.
* lisp/erc/erc-track.el: Use lexical-binding.
(erc-make-mode-line-buffer-name): Use closures instead of `(lambda...).
(erc-faces-in): Avoid add-to-list.
* lisp/erc/erc-notify.el: Use lexical-binding.
(erc-notify-timer): Adjust to change in erc-once-with-server-event.
(erc-notify-QUIT): Use a closure instead of `(lambda...).
* lisp/erc/erc-list.el: Use lexical-binding.
(erc-list-install-322-handler, erc-cmd-LIST): Adjust to change in
erc-once-with-server-event.
* lisp/erc/erc-button.el: Use lexical-binding.
(erc-button-next-function): Use a closure instead of `(lambda...).
parent 8352b530
2013-08-22 Stefan Monnier <monnier@iro.umontreal.ca>
* erc.el: Use lexical-binding.
(erc-user-full-name): Minor CSE simplification.
(erc-mode-map): Assume command-remapping is available.
(erc-once-with-server-event): Replace `forms' arg with a function arg.
(erc-once-with-server-event-global): Remove.
(erc-ison-p): Adjust to change in erc-once-with-server-event.
(erc-get-buffer-create): Remove arg `proc'.
(iswitchb-make-buflist-hook): Declare.
(erc-setup-buffer): Use pcase; avoid ((lambda ..) ..).
(read-passwd): Assume it exists.
(erc-display-line, erc-cmd-IDLE): Avoid add-to-list, adjust to change
in erc-once-with-server-event.
(erc-cmd-JOIN, erc-set-channel-limit, erc-set-channel-key)
(erc-add-query): Minor CSE simplification.
(erc-cmd-BANLIST, erc-cmd-MASSUNBAN): Adjust to change
in erc-once-with-server-event.
(erc-echo-notice-in-user-and-target-buffers): Avoid add-to-list.
* erc-track.el: Use lexical-binding.
(erc-make-mode-line-buffer-name): Use closures instead of `(lambda...).
(erc-faces-in): Avoid add-to-list.
* erc-notify.el: Use lexical-binding.
(erc-notify-timer): Adjust to change in erc-once-with-server-event.
(erc-notify-QUIT): Use a closure instead of `(lambda...).
* erc-list.el: Use lexical-binding.
(erc-list-install-322-handler, erc-cmd-LIST): Adjust to change in
erc-once-with-server-event.
* erc-button.el: Use lexical-binding.
(erc-button-next-function): Use a closure instead of `(lambda...).
2013-05-30 Glenn Morris <rgm@gnu.org>
* erc-backend.el: Require erc at run-time too.
......
;; 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-2013 Free Software Foundation, Inc.
......@@ -432,19 +432,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'."
(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))))
;; FIXME: This is an abuse of completion-at-point-functions.
(when (< (point) (erc-beg-of-input-line))
(let ((start (point)))
(lambda ()
(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."
......
;;; erc-list.el --- /list support for ERC
;;; erc-list.el --- /list support for ERC -*- lexical-binding:t -*-
;; Copyright (C) 2008-2013 Free Software Foundation, Inc.
......@@ -183,7 +183,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)
......@@ -209,11 +209,12 @@ 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)
......
;;; erc-notify.el --- Online status change notification
;;; erc-notify.el --- Online status change notification -*- lexical-binding:t -*-
;; Copyright (C) 2002-2004, 2006-2013 Free Software Foundation, Inc.
......@@ -115,27 +115,28 @@ changes."
erc-notify-interval))
(erc-once-with-server-event
303
'(let* ((server (erc-response.sender parsed))
(ison-list (delete "" (split-string
(erc-response.contents parsed))))
(new-list ison-list)
(old-list (erc-with-server-buffer erc-last-ison)))
(while new-list
(when (not (erc-member-ignore-case (car new-list) old-list))
(run-hook-with-args 'erc-notify-signon-hook server (car new-list))
(erc-display-message
parsed 'notice proc
'notify_on ?n (car new-list) ?m (erc-network-name)))
(setq new-list (cdr new-list)))
(while old-list
(when (not (erc-member-ignore-case (car old-list) ison-list))
(run-hook-with-args 'erc-notify-signoff-hook server (car old-list))
(erc-display-message
parsed 'notice proc
'notify_off ?n (car old-list) ?m (erc-network-name)))
(setq old-list (cdr old-list)))
(setq erc-last-ison ison-list)
t))
(lambda (proc parsed)
(let* ((server (erc-response.sender parsed))
(ison-list (delete "" (split-string
(erc-response.contents parsed))))
(new-list ison-list)
(old-list (erc-with-server-buffer erc-last-ison)))
(while new-list
(when (not (erc-member-ignore-case (car new-list) old-list))
(run-hook-with-args 'erc-notify-signon-hook server (car new-list))
(erc-display-message
parsed 'notice proc
'notify_on ?n (car new-list) ?m (erc-network-name)))
(setq new-list (cdr new-list)))
(while old-list
(when (not (erc-member-ignore-case (car old-list) ison-list))
(run-hook-with-args 'erc-notify-signoff-hook server (car old-list))
(erc-display-message
parsed 'notice proc
'notify_off ?n (car old-list) ?m (erc-network-name)))
(setq old-list (cdr old-list)))
(setq erc-last-ison ison-list)
t)))
(erc-server-send
(concat "ISON " (mapconcat 'identity erc-notify-list " ")))
(setq erc-last-ison-time now)))
......@@ -179,10 +180,11 @@ nick from `erc-last-ison' to prevent any further notifications."
(let ((nick (erc-extract-nick (erc-response.sender parsed))))
(when (and (erc-member-ignore-case nick erc-notify-list)
(erc-member-ignore-case nick erc-last-ison))
(setq erc-last-ison (erc-delete-if `(lambda (el)
(string= ,(erc-downcase nick)
(erc-downcase el)))
erc-last-ison))
(setq erc-last-ison (erc-delete-if
(let ((nick-down (erc-downcase nick)))
(lambda (el)
(string= nick-down (erc-downcase el))))
erc-last-ison))
(run-hook-with-args 'erc-notify-signoff-hook
(or erc-server-announced-name erc-session-server)
nick)
......
;;; erc-track.el --- Track modified channel buffers
;;; erc-track.el --- Track modified channel buffers -*- lexical-binding:t -*-
;; Copyright (C) 2002-2013 Free Software Foundation, Inc.
......@@ -710,7 +710,7 @@ inactive."
to consider when `erc-track-visibility' is set to
only consider active buffers visible.")
(defun erc-user-is-active (&rest ignore)
(defun erc-user-is-active (&rest _ignore)
"Set `erc-buffer-activity'."
(when erc-server-connected
(setq erc-buffer-activity (erc-current-time))
......@@ -745,7 +745,7 @@ only consider active buffers visible.")
times. Without it, you cannot debug `erc-modified-channels-display',
because the debugger also cases changes to the window-configuration.")
(defun erc-modified-channels-update (&rest args)
(defun erc-modified-channels-update (&rest _args)
"This function updates the information in `erc-modified-channels-alist'
according to buffer visibility. It calls
`erc-modified-channels-display' at the end. This should usually be
......@@ -791,19 +791,19 @@ If FACES are provided, color STRING with them."
(int-to-string count))
(copy-sequence string))))
(define-key map (vector 'mode-line 'mouse-2)
`(lambda (e)
(interactive "e")
(save-selected-window
(select-window
(posn-window (event-start e)))
(switch-to-buffer ,buffer))))
(lambda (e)
(interactive "e")
(save-selected-window
(select-window
(posn-window (event-start e)))
(switch-to-buffer buffer))))
(define-key map (vector 'mode-line 'mouse-3)
`(lambda (e)
(interactive "e")
(save-selected-window
(select-window
(posn-window (event-start e)))
(switch-to-buffer-other-window ,buffer))))
(lambda (e)
(interactive "e")
(save-selected-window
(select-window
(posn-window (event-start e)))
(switch-to-buffer-other-window buffer))))
(put-text-property 0 (length name) 'local-map map name)
(put-text-property
0 (length name)
......@@ -976,8 +976,9 @@ is in `erc-mode'."
cur)
(while (and (setq i (next-single-property-change i 'face str m))
(not (= i m)))
(when (setq cur (get-text-property i 'face str))
(add-to-list 'faces cur)))
(and (setq cur (get-text-property i 'face str))
(not (member cur faces))
(push cur faces)))
faces))
(cl-assert
......
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment