* riece.el (riece-buffer-alist): Rename from
authorueno <ueno>
Thu, 16 Oct 2003 01:50:18 +0000 (01:50 +0000)
committerueno <ueno>
Thu, 16 Oct 2003 01:50:18 +0000 (01:50 +0000)
riece-buffer-mode-alist.

* riece-misc.el (riece-get-buffer-create): Takes an optional 2nd
argument, init-major-mode, which is used to assert the major-mode
of the created buffer is 'riece-channel-mode.

* riece-naming.el (riece-naming-assert-rename): Merged buffer
renaming logic that riece-handle-nick-message was responsible for.

* riece-globals.el (riece-server-process-alist): Revive.
(riece-process-list): Abolish.
(riece-command-buffer): Set default to nil.
(riece-dialogue-buffer): Ditto.
(riece-others-buffer): Ditto.
(riece-channel-list-buffer): Ditto.
(riece-user-list-buffer): Ditto.
(riece-private-buffer): Abolish.
(riece-wallops-buffer): Abolish.

* riece-display.el (riece-channel-buffer-format): Moved from
riece-globals.
(riece-channel-buffer-alist): New variable.
(riece-channel-buffer-create): Assert the major-mode of the
created buffer is 'riece-channel-mode.
(riece-channel-buffer): New function.
(riece-switch-to-channel): Use riece-channel-buffer instead of
directly using get-buffer.

15 files changed:
lisp/ChangeLog
lisp/riece-300.el
lisp/riece-commands.el
lisp/riece-ctcp.el
lisp/riece-display.el
lisp/riece-filter.el
lisp/riece-globals.el
lisp/riece-handle.el
lisp/riece-message.el
lisp/riece-misc.el
lisp/riece-naming.el
lisp/riece-ndcc.el
lisp/riece-rdcc.el
lisp/riece-server.el
lisp/riece.el

index b47ac68..e65da06 100644 (file)
@@ -1,3 +1,34 @@
+2003-10-16  Daiki Ueno  <ueno@unixuser.org>
+
+       * riece.el (riece-buffer-alist): Rename from
+       riece-buffer-mode-alist.
+
+       * riece-misc.el (riece-get-buffer-create): Takes an optional 2nd
+       argument, init-major-mode, which is used to assert the major-mode
+       of the created buffer is 'riece-channel-mode.
+
+       * riece-naming.el (riece-naming-assert-rename): Merged buffer
+       renaming logic that riece-handle-nick-message was responsible for.
+
+       * riece-globals.el (riece-server-process-alist): Revive.
+       (riece-process-list): Abolish.
+       (riece-command-buffer): Set default to nil.
+       (riece-dialogue-buffer): Ditto.
+       (riece-others-buffer): Ditto.
+       (riece-channel-list-buffer): Ditto.
+       (riece-user-list-buffer): Ditto.
+       (riece-private-buffer): Abolish.
+       (riece-wallops-buffer): Abolish.
+
+       * riece-display.el (riece-channel-buffer-format): Moved from
+       riece-globals.
+       (riece-channel-buffer-alist): New variable.
+       (riece-channel-buffer-create): Assert the major-mode of the
+       created buffer is 'riece-channel-mode.
+       (riece-channel-buffer): New function.
+       (riece-switch-to-channel): Use riece-channel-buffer instead of
+       directly using get-buffer.
+
 2003-10-14  Daiki Ueno  <ueno@unixuser.org>
 
        * riece-commands.el (riece-command-toggle-away): Check user away
index 3f9f0b5..4ec44e8 100644 (file)
        (riece-channel-set-topic (riece-get-channel channel) topic)
        (let* ((channel-identity (riece-make-identity channel
                                                      riece-server-name))
-              (buffer (riece-channel-buffer-name channel-identity)))
+              (buffer (riece-channel-buffer channel-identity)))
          (riece-insert-info buffer (concat visible " users, topic: "
                                            topic "\n"))
          (riece-insert-info
          (setq modes (cdr modes)))
        (let* ((channel-identity (riece-make-identity channel
                                                      riece-server-name))
-              (buffer (riece-channel-buffer-name channel-identity)))
+              (buffer (riece-channel-buffer channel-identity)))
          (riece-insert-info buffer (concat "Mode: " mode-string "\n"))
          (riece-insert-info
           (if (and riece-channel-buffer-mode
       (let* ((channel (match-string 1 string))
             (message (substring string (match-end 0)))
             (channel-identity (riece-make-identity channel riece-server-name))
-            (buffer (riece-channel-buffer-name channel-identity)))
+            (buffer (riece-channel-buffer channel-identity)))
        (if remove
            (riece-channel-set-topic (riece-get-channel channel) nil)
          (riece-channel-set-topic (riece-get-channel channel) message)
       (let* ((channel (match-string 1 string))
             (user (substring string (match-end 0)))
             (channel-identity (riece-make-identity channel riece-server-name))
-            (buffer (riece-channel-buffer-name channel-identity)))
+            (buffer (riece-channel-buffer channel-identity)))
        (riece-insert-info buffer (concat "Inviting " user "\n"))
        (riece-insert-info
         (if (and riece-channel-buffer-mode
             (flag (match-string 8 string))
             (hops (match-string 9 string))
             (name (substring string (match-end 0)))
-            (buffer (riece-channel-buffer-name
-                     (riece-make-identity channel riece-server-name)))
+            (buffer (riece-channel-buffer (riece-make-identity
+                                           channel riece-server-name)))
             (info (format "%10s = %s (%s) [%s, %s, %s hops, on %s]"
                           (concat
                            (if (memq flag '(?@ ?+))
index fe04361..3439412 100644 (file)
@@ -586,10 +586,10 @@ If prefix argument ARG is non-nil, toggle frozen status."
                 (read-string "Message: ")
               (or riece-quit-message
                   (riece-extended-version))))
-           (process-list riece-process-list))
-       (while process-list
-         (riece-quit-server-process (car process-list) message)
-         (setq process-list (cdr process-list))))))
+           (alist riece-server-process-alist))
+       (while alist
+         (riece-quit-server-process (cdr (car alist)) message)
+         (setq alist (cdr alist))))))
 
 (defun riece-command-raw (command)
   "Enter raw IRC command, which is sent to the server."
@@ -627,13 +627,7 @@ If prefix argument ARG is non-nil, toggle frozen status."
 
 (defun riece-command-close-server (server-name &optional message)
   (interactive
-   (list (completing-read
-         "Server: "
-         (mapcar
-          (lambda (process)
-            (with-current-buffer (process-buffer process)
-              (list riece-server-name)))
-          riece-process-list))
+   (list (completing-read "Server: " riece-server-process-alist)
         (if current-prefix-arg
             (read-string "Message: ")
           (or riece-quit-message
@@ -643,13 +637,7 @@ If prefix argument ARG is non-nil, toggle frozen status."
 (defun riece-command-universal-server-name-argument ()
   (interactive)
   (let* ((riece-overriding-server-name
-         (completing-read
-          "Server: "
-          (mapcar
-           (lambda (process)
-             (with-current-buffer (process-buffer process)
-               (list riece-server-name)))
-           riece-process-list)))
+         (completing-read "Server: " riece-server-process-alist)))
         (command
          (key-binding (read-key-sequence
                        (format "Command to execute on \"%s\":"
index 804b705..240c9ac 100644 (file)
@@ -84,8 +84,8 @@
 
 (defun riece-handle-ctcp-version-request (prefix target string)
   (let ((buffer (if (riece-channel-p target)
-                   (riece-channel-buffer-name
-                    (riece-make-identity target riece-server-name))))
+                   (riece-channel-buffer (riece-make-identity
+                                          target riece-server-name))))
        (user (riece-prefix-nickname prefix)))
     (riece-send-string
      (format "NOTICE %s :\1VERSION %s\1\r\n" user (riece-extended-version)))
 
 (defun riece-handle-ctcp-ping-request (prefix target string)
   (let ((buffer (if (riece-channel-p target)
-                   (riece-channel-buffer-name
-                    (riece-make-identity target riece-server-name))))
+                   (riece-channel-buffer (riece-make-identity
+                                          target riece-server-name))))
        (user (riece-prefix-nickname prefix)))
     (riece-send-string
      (if string
 
 (defun riece-handle-ctcp-clientinfo-request (prefix target string)
   (let ((buffer (if (riece-channel-p target)
-                   (riece-channel-buffer-name
-                    (riece-make-identity target riece-server-name))))
+                   (riece-channel-buffer (riece-make-identity
+                                          target riece-server-name))))
        (user (riece-prefix-nickname prefix)))
     (riece-send-string
      (format "NOTICE %s :\1CLIENTINFO %s\1\r\n"
 
 (defun riece-handle-ctcp-action-request (prefix target string)
   (let ((buffer (if (riece-channel-p target)
-                   (riece-channel-buffer-name
-                    (riece-make-identity target riece-server-name))))
+                   (riece-channel-buffer (riece-make-identity
+                                          target riece-server-name))))
        (user (riece-prefix-nickname prefix)))
     (riece-insert-change buffer (concat user " " string "\n"))
     (riece-insert-change
   (riece-send-string (format "PRIVMSG %s :\1ACTION %s\1\r\n"
                             (riece-identity-prefix channel)
                             action))
-  (let ((buffer (riece-channel-buffer-name
-                (riece-make-identity channel riece-server-name))))
+  (let ((buffer (riece-channel-buffer (riece-make-identity
+                                      channel riece-server-name))))
     (riece-insert-change
      buffer
      (concat (riece-identity-prefix (riece-current-nickname)) " " action "\n"))
index 33144dd..44a1254 100644 (file)
 (require 'riece-misc)
 (require 'riece-layout)
 
+(defvar riece-channel-buffer-format "*Channel:%s*"
+  "Format of channel message buffer.")
+(defvar riece-channel-buffer-alist nil
+  "An alist mapping identities to channel buffers.")
+
 (defvar riece-update-buffer-functions nil
   "Functions to redisplay the buffer.
 Local to the buffer in `riece-buffer-list'.")
@@ -187,7 +192,11 @@ Local to the buffer in `riece-buffer-list'.")
   (autoload 'riece-channel-mode "riece"))
 (defun riece-channel-buffer-create (identity)
   (with-current-buffer
-      (riece-get-buffer-create (riece-channel-buffer-name identity))
+      (riece-get-buffer-create (riece-channel-buffer-name identity)
+                              'riece-channel-mode)
+    (setq riece-channel-buffer-alist
+         (cons (cons identity (current-buffer))
+               riece-channel-buffer-alist))
     (unless (eq major-mode 'riece-channel-mode)
       (riece-channel-mode)
       (let (buffer-read-only)
@@ -199,11 +208,13 @@ Local to the buffer in `riece-buffer-list'.")
        (run-hook-with-args 'riece-channel-buffer-create-functions identity)))
     (current-buffer)))
 
+(defun riece-channel-buffer (identity)
+  (cdr (riece-identity-assoc identity riece-channel-buffer-alist)))
+
 (defun riece-switch-to-channel (identity)
   (let ((last riece-current-channel))
     (setq riece-current-channel identity
-         riece-channel-buffer (get-buffer (riece-channel-buffer-name
-                                           riece-current-channel)))
+         riece-channel-buffer (riece-channel-buffer riece-current-channel))
     (run-hook-with-args 'riece-after-switch-to-channel-functions last)))
 
 (defun riece-join-channel (identity)
index 89abe6f..f522c48 100644 (file)
       (riece-redisplay-buffers)
       (riece-close-server-process process)
       ;; If no server process is available, exit.
-      (unless riece-process-list
+      (unless riece-server-process-alist
        (riece-exit)))))
 
 (provide 'riece-filter)
index 705a735..ef5f3bc 100644 (file)
@@ -30,9 +30,9 @@
 (defconst riece-user-regexp
   "[][\\\\`_^{|}A-Za-z][][\\\\`_^{|}A-Za-z0-9-]\\{0,8\\}")
 
-;;; Miscellaneous global variables:
-(defvar riece-process-list nil
-  "List of processes opened in the current session.")
+;;; Global variables:
+(defvar riece-server-process-alist nil
+  "An alist mapping server names to processes.")
 
 (defvar riece-current-channel nil
   "The channel you currently have joined.")
@@ -120,23 +120,19 @@ Local to the channel buffers.")
 (defvar riece-freeze-indicator "-")
 
 ;;; Buffers:
-(defvar riece-command-buffer "*Commands*"
-  "Name of command input buffer.")
-(defvar riece-dialogue-buffer "*Dialogue*"
-  "Name of dialogue output buffer.")
-(defvar riece-private-buffer "*Private*"
-  "Name of private message buffer.")
-(defvar riece-others-buffer "*Others*"
-  "Name of others message buffer.")
+(defvar riece-command-buffer nil
+  "The command buffer.")
+(defvar riece-dialogue-buffer nil
+  "Buffer for whole conversation.")
+(defvar riece-others-buffer nil
+  "Buffer for other messages.")
+(defvar riece-channel-list-buffer nil
+  "Buffer for channel list.")
+(defvar riece-user-list-buffer nil
+  "Buffer for user list.")
+
 (defvar riece-channel-buffer nil
-  "Name of channel message buffer.")
-(defvar riece-channel-buffer-format "*Channel:%s*"
-  "Format of channel message buffer.")
-(defvar riece-channel-list-buffer "*Channels*"
-  "Name of channel list buffer.")
-(defvar riece-user-list-buffer " *Users*"
-  "Name of user list buffer.")
-(defvar riece-wallops-buffer " *WALLOPS*")
+  "Buffer for messages arrived in the current channel.")
 
 (defvar riece-buffer-list nil)
 (defvar riece-overriding-server-name nil)
index e35515e..6d36577 100644 (file)
                             (riece-make-identity channel riece-server-name))
                           channels))))
     (riece-naming-assert-rename old new)
-    (let ((pointer (riece-identity-member old-identity
-                                         riece-current-channels)))
-      (when pointer
-       (setcar pointer new-identity)
-       (with-current-buffer (riece-channel-buffer-name new-identity)
-         (rename-buffer (riece-channel-buffer-name new-identity)))
-       (if (riece-identity-equal new-identity riece-current-channel)
-           (riece-switch-to-channel new-identity))
-       (setq channels (cons new-identity channels))))
+    (if (riece-identity-member old-identity riece-current-channels)
+       (setq channels (cons new channels)))
     (riece-insert-change (mapcar
                          (lambda (channel)
-                           (riece-channel-buffer-name
-                            (riece-make-identity channel riece-server-name)))
+                           (riece-channel-buffer (riece-make-identity
+                                                  channel riece-server-name)))
                          channels)
                         (format "%s -> %s\n"
                                 (riece-format-identity old-identity t)
       (riece-naming-assert-join user (car channels))
       (let* ((channel-identity (riece-make-identity (car channels)
                                                    riece-server-name))
-            (buffer (get-buffer (riece-channel-buffer-name
-                                 channel-identity))))
+            (buffer (riece-channel-buffer channel-identity)))
        (riece-insert-change
         buffer
         (format "%s (%s) has joined %s\n"
       (riece-naming-assert-part user (car channels))
       (let* ((channel-identity (riece-make-identity (car channels)
                                                    riece-server-name))
-            (buffer (get-buffer (riece-channel-buffer-name
-                                 channel-identity))))
+            (buffer (riece-channel-buffer channel-identity)))
        (riece-insert-change
         buffer
         (concat
         (channel-identity (riece-make-identity channel riece-server-name))
         (user-identity (riece-make-identity user riece-server-name)))
     (riece-naming-assert-part user channel)
-    (let ((buffer (get-buffer (riece-channel-buffer-name channel-identity))))
+    (let ((buffer (riece-channel-buffer channel-identity)))
       (riece-insert-change
        buffer
        (concat
     (let ((buffers
           (mapcar
            (lambda (channel)
-             (get-buffer
-              (riece-channel-buffer-name
-               (riece-make-identity channel riece-server-name))))
+             (riece-channel-buffer (riece-make-identity channel
+                                                        riece-server-name)))
            channels)))
       (riece-insert-change
        buffers
     (let ((buffers
           (mapcar
            (lambda (channel)
-             (get-buffer
-              (riece-channel-buffer-name
-               (riece-make-identity channel riece-server-name))))
+             (riece-channel-buffer (riece-make-identity channel
+                                                        riece-server-name)))
            channels)))
       (riece-insert-change
        buffers
         (user-identity (riece-make-identity user riece-server-name))
         (channel-identity (riece-make-identity channel riece-server-name)))
     (riece-channel-set-topic (riece-get-channel channel) topic)
-    (let ((buffer (get-buffer (riece-channel-buffer-name channel-identity))))
+    (let ((buffer (riece-channel-buffer channel-identity)))
       (riece-insert-change
        buffer
        (format "Topic by %s: %s\n"
            string (substring string (match-end 0)))
       (riece-parse-channel-modes string channel)
       (let* ((channel-identity (riece-make-identity channel riece-server-name))
-            (buffer (get-buffer (riece-channel-buffer-name
-                                 channel-identity))))
+            (buffer (riece-channel-buffer channel-identity)))
        (riece-insert-change
         buffer
         (format "Mode by %s: %s\n"
index bac5784..60702eb 100644 (file)
       (unless riece-current-channel
        (riece-switch-to-channel target))
       (riece-redisplay-buffers))
-    (riece-channel-buffer-name target)))
+    (riece-channel-buffer target)))
 
 (defun riece-message-parent-buffers (message buffer)
   "Return the parents of BUFFER where MESSAGE should appear.
index d3a21d4..c4fa7bc 100644 (file)
 (require 'riece-server)
 (require 'riece-user)
 
-(defun riece-get-buffer-create (name)
-  (let ((buffer (get-buffer-create name)))
+(defun riece-get-buffer-create (name &optional init-major-mode)
+  (let ((buffer (get-buffer name)))
+    (unless (and buffer
+                (or (null init-major-mode)
+                    (eq (with-current-buffer buffer
+                          major-mode)
+                        init-major-mode)))
+      (setq buffer (generate-new-buffer name)))
     (unless (memq buffer riece-buffer-list)
       (setq riece-buffer-list (cons buffer riece-buffer-list)))
     buffer))
@@ -59,7 +65,7 @@
   (while buffers
     (run-hooks 'riece-before-insert-functions)
     (save-excursion
-      (set-buffer (riece-get-buffer-create (car buffers)))
+      (set-buffer (car buffers))
       (let ((inhibit-read-only t)
            buffer-read-only
            (start (goto-char (point-max))))
index ca9d8a0..4c1a91f 100644 (file)
       (if pointer
          (setcar pointer new-name))
       (setq channels (cdr channels)))
-    (riece-rename-user old-name new-name)))
+    (riece-rename-user old-name new-name))
+  ;; Rename the channel buffer.
+  (let* ((old-identity (riece-make-identity old-name riece-server-name))
+        (new-identity (riece-make-identity new-name riece-server-name))
+        (pointer (riece-identity-member old-identity riece-current-channels)))
+    (when pointer
+      (setcar pointer new-identity)
+      (with-current-buffer (riece-channel-buffer old-identity)
+       (rename-buffer (riece-channel-buffer-name new-identity) t)
+       (setq riece-channel-buffer-alist
+             (cons (cons new-identity (current-buffer))
+                   (delq (riece-identity-assoc old-identity
+                                               riece-channel-buffer-alist)
+                         riece-channel-buffer-alist))))
+      (if (riece-identity-equal old-identity riece-current-channel)
+         (riece-switch-to-channel new-identity)))))
 
 (provide 'riece-naming)
 
index a5a9ae8..dd0553a 100644 (file)
@@ -195,8 +195,8 @@ Only used for sending files."
            (port (string-to-number (match-string 3 message)))
            (size (string-to-number (match-string 4 message)))
            (buffer (if (riece-channel-p target)
-                       (riece-channel-buffer-name
-                        (riece-make-identity target riece-server-name))))
+                       (riece-channel-buffer (riece-make-identity
+                                              target riece-server-name))))
            (user (riece-prefix-nickname prefix)))
        (setq riece-ndcc-requests
              (cons (list user file address port size)
index 46429ce..9328098 100644 (file)
@@ -271,8 +271,8 @@ puts(\"#{" address " >> 24 & 0xFF}.#{" address " >> 16 & 0xFF}.#{"
            (port (string-to-number (match-string 3 message)))
            (size (string-to-number (match-string 4 message)))
            (buffer (if (riece-channel-p target)
-                       (riece-channel-buffer-name
-                        (riece-make-identity target riece-server-name))))
+                       (riece-channel-buffer (riece-make-identity
+                                              target riece-server-name))))
            (user (riece-prefix-nickname prefix)))
        (setq riece-rdcc-requests
              (cons (list user file address port size)
index 2b18ba1..7a918ff 100644 (file)
@@ -93,7 +93,7 @@ the `riece-server-keyword-map' variable."
     (format "IRC<%s>" server-name)))
 
 (defun riece-server-process (server-name)
-  (get-process (riece-server-process-name server-name)))
+  (cdr (assoc server-name riece-server-process-alist)))
 
 (defmacro riece-with-server-buffer (server-name &rest body)
   `(let ((process (riece-server-process ,server-name)))
@@ -165,8 +165,9 @@ the `riece-server-keyword-map' variable."
        (setq riece-last-nickname riece-real-nickname
              riece-nick-accepted 'sent
              riece-coding-system coding))
-      (setq riece-process-list
-           (cons process riece-process-list)))))
+      (setq riece-server-process-alist
+           (cons (cons server-name process)
+                 riece-server-process-alist)))))
 
 (defun riece-reset-process-buffer (process)
   (save-excursion
@@ -197,25 +198,27 @@ the `riece-server-keyword-map' variable."
   (if riece-debug
       (delete-process process)
     (kill-buffer (process-buffer process)))
-  (setq riece-process-list (delq process riece-process-list)))
+  (setq riece-server-process-alist
+       (delq (rassq process riece-server-process-alist)
+             riece-server-process-alist)))
 
 (defun riece-server-opened (&optional server-name)
-  (let ((process-list riece-process-list))
+  (let ((alist riece-server-process-alist))
     (catch 'found
-      (while process-list
-       (if (memq (process-status (car process-list)) '(open run))
+      (while alist
+       (if (memq (process-status (cdr (car alist))) '(open run))
            (throw 'found t))
-       (setq process-list (cdr process-list))))))
+       (setq alist (cdr alist))))))
 
 (eval-when-compile
   (autoload 'riece-exit "riece"))
 (defun riece-quit-server-process (process &optional message)
   (run-at-time riece-quit-timeout nil
               (lambda (process)
-                (when (memq process riece-process-list)
+                (when (rassq process riece-server-process-alist)
                   (riece-close-server-process process)
                   ;; If no server process is available, exit.
-                  (unless riece-process-list
+                  (unless riece-server-process-alist
                     (riece-exit))))
               process)
   (riece-process-send-string process
index 3cf1ef3..2f3b858 100644 (file)
 
 (put 'riece-command-mode 'mode-class 'special)
 (put 'riece-dialogue-mode 'mode-class 'special)
+(put 'riece-others-mode 'derived-mode-parent 'riece-dialogue-mode)
 (put 'riece-channel-list-mode 'mode-class 'special)
 (put 'riece-user-list-mode 'mode-class 'special)
 (put 'riece-channel-mode 'derived-mode-parent 'riece-dialogue-mode)
-(put 'riece-others-mode 'derived-mode-parent 'riece-dialogue-mode)
 
-(defvar riece-buffer-mode-alist
-  '((riece-command-buffer . riece-command-mode)
-    (riece-dialogue-buffer . riece-dialogue-mode)
-    (riece-others-buffer . riece-others-mode)
-    (riece-user-list-buffer . riece-user-list-mode)
-    (riece-channel-list-buffer . riece-channel-list-mode)
-    (riece-private-buffer . riece-dialogue-mode)
-    (riece-wallops-buffer)))
-    
+(defvar riece-buffer-alist
+  '((riece-command-buffer "*Commands*" riece-command-mode)
+    (riece-dialogue-buffer "*Dialogue*" riece-dialogue-mode)
+    (riece-others-buffer "*Others*" riece-others-mode)
+    (riece-channel-list-buffer "*Channels*" riece-channel-list-mode)
+    (riece-user-list-buffer " *Users*" riece-user-list-mode)))
+
 (defvar riece-select-keys
   '("1" riece-command-switch-to-channel-by-number-1
     "2" riece-command-switch-to-channel-by-number-2
@@ -267,6 +265,7 @@ If optional argument CONFIRM is non-nil, ask which IRC server to connect."
   (setq riece-server nil
        riece-current-channels nil
        riece-current-channel nil
+       riece-channel-buffer-alist nil
        riece-user-indicator nil
        riece-long-channel-indicator "None"
        riece-channel-list-indicator "No channel"
@@ -402,14 +401,15 @@ Instead, these commands are available:
   (run-hooks 'riece-user-list-mode-hook))
 
 (defun riece-create-buffers ()
-  (let ((alist riece-buffer-mode-alist))
+  (let ((alist riece-buffer-alist))
     (while alist
       (save-excursion
-       (set-buffer (riece-get-buffer-create
-                    (symbol-value (car (car alist)))))
-       (unless (or (null (cdr (car alist)))
-                   (eq major-mode (cdr (car alist))))
-         (funcall (cdr (car alist))))
+       (set-buffer (apply #'riece-get-buffer-create
+                          (cdr (car alist))))
+       (set (car (car alist)) (current-buffer))
+       (unless (or (null (nth 2 (car alist)))
+                   (eq major-mode (nth 2 (car alist))))
+         (funcall (nth 2 (car alist))))
        (setq alist (cdr alist))))))
 
 (defun riece-load-and-build-addon-dependencies (addons)