This functions much better in the presence of real multiple values, and is
more correct even in their absence.
It would be really helpful if there were some indication, when posting to
erc-help(a)lists.sourceforge.net, that it was no longer active, by the way.
:-) . I’m about to post another mail with a patch I posted to that address
back near the middle of July.
xemacs-packages/erc/ChangeLog addition:
2009-08-13 Aidan Kehoe <kehoea(a)parhasard.net>
* erc-compat.el (erc-destructuring-bind): New macro, like
#'destructuring-bind, but no error if EXPR doesn't give a result
fitting into ARGS.
* erc-backend.el:
Use #'destructuring-bind instead of #'multiple-value-bind where we
know the result of EXPR will fit ARGS; use
#'erc-destructuring-bind where we know it won't.
* erc-list.el (erc-chanlist-322):
Use #'erc-destructuring-bind, not #'multiple-value-bind.
* erc.el (erc-banlist-store):
Use #'erc-destructuring-bind, not #'multiple-value-bind.
XEmacs Packages source patch:
Diff command: cvs -q diff -Nu
Files affected: xemacs-packages/erc/erc.el xemacs-packages/erc/erc-list.el
xemacs-packages/erc/erc-compat.el xemacs-packages/erc/erc-backend.el
Index: xemacs-packages/erc/erc-backend.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/packages/xemacs-packages/erc/erc-backend.el,v
retrieving revision 1.6
diff -u -r1.6 erc-backend.el
--- xemacs-packages/erc/erc-backend.el 2006/05/01 21:48:27 1.6
+++ xemacs-packages/erc/erc-backend.el 2009/08/13 14:27:37
@@ -1017,7 +1017,7 @@
nil
(let ((target (first (erc-response.command-args parsed)))
(chnl (erc-response.contents parsed)))
- (multiple-value-bind (nick login host)
+ (destructuring-bind (nick login host)
(erc-parse-user (erc-response.sender parsed))
(setq erc-invitation chnl)
(when (string= target (erc-current-nick))
@@ -1031,7 +1031,7 @@
nil
(let ((chnl (erc-response.contents parsed))
(buffer nil))
- (multiple-value-bind (nick login host)
+ (destructuring-bind (nick login host)
(erc-parse-user (erc-response.sender parsed))
;; strip the stupid combined JOIN facility (IRC 2.9)
(if (string-match "^\\(.*\\)?\^g.*$" chnl)
@@ -1072,7 +1072,7 @@
(tgt (second (erc-response.command-args parsed)))
(reason (erc-trim-string (erc-response.contents parsed)))
(buffer (erc-get-buffer ch proc)))
- (multiple-value-bind (nick login host)
+ (destructuring-bind (nick login host)
(erc-parse-user (erc-response.sender parsed))
(erc-remove-channel-member buffer tgt)
(cond
@@ -1099,7 +1099,7 @@
(let ((tgt (first (erc-response.command-args parsed)))
(mode (mapconcat 'identity (cdr (erc-response.command-args parsed))
" ")))
- (multiple-value-bind (nick login host)
+ (destructuring-bind (nick login host)
(erc-parse-user (erc-response.sender parsed))
(erc-log (format "MODE: %s -> %s: %s" nick tgt mode))
;; dirty hack
@@ -1124,7 +1124,7 @@
"Handle nick change messages." nil
(let ((nn (erc-response.contents parsed))
bufs)
- (multiple-value-bind (nick login host)
+ (destructuring-bind (nick login host)
(erc-parse-user (erc-response.sender parsed))
(setq bufs (erc-buffer-list-with-nick nick proc))
(erc-log (format "NICK: %s -> %s" nick nn))
@@ -1162,7 +1162,7 @@
(let* ((chnl (first (erc-response.command-args parsed)))
(reason (erc-trim-string (erc-response.contents parsed)))
(buffer (erc-get-buffer chnl proc)))
- (multiple-value-bind (nick login host)
+ (destructuring-bind (nick login host)
(erc-parse-user (erc-response.sender parsed))
(erc-remove-channel-member buffer nick)
(erc-display-message parsed 'notice buffer
@@ -1270,7 +1270,7 @@
nil nil
(let ((reason (erc-response.contents parsed))
bufs)
- (multiple-value-bind (nick login host)
+ (destructuring-bind (nick login host)
(erc-parse-user (erc-response.sender parsed))
(setq bufs (erc-buffer-list-with-nick nick proc))
(erc-remove-user nick)
@@ -1284,7 +1284,7 @@
(let* ((ch (first (erc-response.command-args parsed)))
(topic (erc-trim-string (erc-response.contents parsed)))
(time (format-time-string "%T %m/%d/%y" (current-time))))
- (multiple-value-bind (nick login host)
+ (destructuring-bind (nick login host)
(erc-parse-user (erc-response.sender parsed))
(erc-update-channel-member ch nick nick nil nil nil host login)
(erc-update-channel-topic ch (format "%s\C-o (%s, %s)" topic nick time))
@@ -1295,7 +1295,7 @@
(define-erc-response-handler (WALLOPS)
nil nil
(let ((message (erc-response.contents parsed)))
- (multiple-value-bind (nick login host)
+ (destructuring-bind (nick login host)
(erc-parse-user (erc-response.sender parsed))
(erc-display-message
parsed 'notice nil
@@ -1325,7 +1325,7 @@
(define-erc-response-handler (004)
nil nil
- (multiple-value-bind (server-name server-version)
+ (erc-destructuring-bind (server-name server-version)
(cdr (erc-response.command-args parsed))
(setq erc-server-version server-version)
(setq erc-server-announced-name server-name)
@@ -1419,7 +1419,7 @@
"WHOIS/WHOWAS notices." nil
(let ((fname (erc-response.contents parsed))
(catalog-entry (intern (format "s%s" (erc-response.command parsed)))))
- (multiple-value-bind (nick user host)
+ (erc-destructuring-bind (nick user host)
(cdr (erc-response.command-args parsed))
(erc-update-user-nick nick nick host nil fname user)
(erc-display-message
@@ -1428,7 +1428,7 @@
(define-erc-response-handler (312)
nil nil
- (multiple-value-bind (nick server-host)
+ (erc-destructuring-bind (nick server-host)
(cdr (erc-response.command-args parsed))
(erc-display-message
parsed 'notice 'active 's312
@@ -1450,7 +1450,7 @@
(define-erc-response-handler (317)
"IDLE notice." nil
- (multiple-value-bind (nick seconds-idle on-since time)
+ (erc-destructuring-bind (nick seconds-idle on-since time)
(cdr (erc-response.command-args parsed))
(setq time (when on-since
(format-time-string "%T %Y/%m/%d"
@@ -1486,7 +1486,7 @@
(define-erc-response-handler (322)
"LIST notice." nil
(let ((topic (erc-response.contents parsed)))
- (multiple-value-bind (channel num-users)
+ (erc-destructuring-bind (channel num-users)
(cdr (erc-response.command-args parsed))
(add-to-list 'erc-channel-list (list channel))
(erc-update-channel-topic channel topic)
@@ -1548,7 +1548,7 @@
(define-erc-response-handler (333)
;; Who set the topic, and when
nil nil
- (multiple-value-bind (channel nick time)
+ (erc-destructuring-bind (channel nick time)
(cdr (erc-response.command-args parsed))
(setq time (format-time-string "%T %Y/%m/%d"
(erc-string-to-emacs-time time)))
@@ -1561,14 +1561,14 @@
(define-erc-response-handler (341)
"Let user know when an INVITE attempt has been sent successfully."
nil
- (multiple-value-bind (nick channel)
+ (erc-destructuring-bind (nick channel)
(cdr (erc-response.command-args parsed))
(erc-display-message parsed 'notice (erc-get-buffer channel proc)
's341 ?n nick ?c channel)))
(define-erc-response-handler (352)
"WHO notice." nil
- (multiple-value-bind (channel user host server nick away-flag)
+ (erc-destructuring-bind (channel user host server nick away-flag)
(cdr (erc-response.command-args parsed))
(let ((full-name (erc-response.contents parsed))
hopcount)
@@ -1598,7 +1598,7 @@
(define-erc-response-handler (367)
"Channel ban list entries" nil
- (multiple-value-bind (channel banmask setter time)
+ (erc-destructuring-bind (channel banmask setter time)
(cdr (erc-response.command-args parsed))
(erc-display-message parsed 'notice 'active 's367
?c channel
@@ -1617,7 +1617,7 @@
;; FIXME: Yet more magic numbers in original code, I'm guessing this
;; command takes two arguments, and doesn't have any "contents". --
;; Lawrence 2004/05/10
- (multiple-value-bind (from to)
+ (erc-destructuring-bind (from to)
(cdr (erc-response.command-args parsed))
(erc-display-message parsed 'notice 'active
's379 ?c from ?f to)))
Index: xemacs-packages/erc/erc-compat.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/packages/xemacs-packages/erc/erc-compat.el,v
retrieving revision 1.8
diff -u -r1.8 erc-compat.el
--- xemacs-packages/erc/erc-compat.el 2006/02/19 12:57:28 1.8
+++ xemacs-packages/erc/erc-compat.el 2009/08/13 14:27:37
@@ -423,6 +423,10 @@
(setq i (1+ i) start (1+ start)))
res))))))
+(defmacro erc-destructuring-bind (args expr &rest body)
+ "Like `destructuring-bind', but don't error if ARGS don't fit
EXPR."
+ `(loop for ,args = ,expr return (progn ,@body)))
+
(provide 'erc-compat)
;;; erc-compat.el ends here
Index: xemacs-packages/erc/erc-list.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/packages/xemacs-packages/erc/erc-list.el,v
retrieving revision 1.11
diff -u -r1.11 erc-list.el
--- xemacs-packages/erc/erc-list.el 2006/02/19 12:57:28 1.11
+++ xemacs-packages/erc/erc-list.el 2009/08/13 14:27:37
@@ -257,7 +257,7 @@
The message carries information about one channel for the LIST
command."
- (multiple-value-bind (channel num-users)
+ (erc-destructuring-bind (channel num-users)
(cdr (erc-response.command-args parsed))
(let ((topic (erc-response.contents parsed)))
(with-current-buffer erc-chanlist-buffer
Index: xemacs-packages/erc/erc.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/packages/xemacs-packages/erc/erc.el,v
retrieving revision 1.15
diff -u -r1.15 erc.el
--- xemacs-packages/erc/erc.el 2006/05/01 21:48:28 1.15
+++ xemacs-packages/erc/erc.el 2009/08/13 14:27:39
@@ -3934,7 +3934,7 @@
(defun erc-banlist-store (proc parsed)
"Record ban entries for a channel."
- (multiple-value-bind (channel mask whoset)
+ (erc-destructuring-bind (channel mask whoset)
(cdr (erc-response.command-args parsed))
;; Determine to which buffer the message corresponds
(let ((buffer (erc-get-buffer channel proc)))
--
¿Dónde estará ahora mi sobrino Yoghurtu Nghe, que tuvo que huir
precipitadamente de la aldea por culpa de la escasez de rinocerontes?
_______________________________________________
XEmacs-Patches mailing list
XEmacs-Patches(a)xemacs.org
http://calypso.tux.org/cgi-bin/mailman/listinfo/xemacs-patches