Make "^C<fg>[,<bg>]" ctlseq matching robuster.
[riece] / lisp / riece-user.el
index 8a3f974..c780e61 100644 (file)
 
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
 
 ;;; Code:
 
 (require 'riece-identity)
 (require 'riece-mode)
+(require 'riece-cache)
 
 ;;; User object:
 (defun riece-find-user (name)
   "Get a user object named NAME from the server buffer."
+  (riece-cache-get riece-user-cache name)
   (let ((symbol (intern-soft (riece-identity-canonicalize-prefix name)
-                            riece-obarray)))
-     (if symbol
-        (symbol-value symbol))))
+                            riece-user-obarray)))
+    (if symbol
+       (symbol-value symbol))))
 
 (defun riece-forget-user (name)
+  (riece-cache-delete riece-user-cache name)
   (let ((symbol (intern-soft (riece-identity-canonicalize-prefix name))))
     (when symbol
       (makunbound symbol)
-      (unintern (symbol-name symbol) riece-obarray))))
+      (unintern (symbol-name symbol) riece-user-obarray))))
 
 (defun riece-rename-user (old-name new-name)
+  (riece-cache-delete riece-user-cache old-name)
+  (riece-cache-set riece-user-cache new-name new-name)
   (unless (equal (riece-identity-canonicalize-prefix old-name)
                 (riece-identity-canonicalize-prefix new-name))
     (let ((symbol (intern-soft (riece-identity-canonicalize-prefix old-name)
-                              riece-obarray)))
+                              riece-user-obarray)))
       (when symbol
        (set (intern (riece-identity-canonicalize-prefix new-name)
-                    riece-obarray)
+                    riece-user-obarray)
             (symbol-value symbol))
        (makunbound symbol)
-       (unintern (symbol-name symbol) riece-obarray)))))
+       (unintern (symbol-name symbol) riece-user-obarray)))))
 
 (defun riece-make-user (channels user-at-host modes away operator)
   "Make an instance of user object.
@@ -60,11 +65,14 @@ away status, respectively."
 
 (defun riece-get-user (name)
   (let ((symbol (intern-soft (riece-identity-canonicalize-prefix name)
-                            riece-obarray)))
+                            riece-user-obarray)))
      (if symbol
-        (symbol-value symbol)
+        (progn
+          (riece-cache-get riece-user-cache name)
+          (symbol-value symbol))
+       (riece-cache-set riece-user-cache name name)
        (set (intern (riece-identity-canonicalize-prefix name)
-                   riece-obarray)
+                   riece-user-obarray)
            (riece-make-user nil nil nil nil nil)))))
 
 (defun riece-user-channels (user)