Catch up with the changes incorporated in XEmacs package.
[elisp/liece.git] / lisp / liece-xemacs.el
index 37d30aa..e12aec4 100644 (file)
@@ -240,11 +240,11 @@ If optional argument FORCE is non-nil, always update toolbar."
         (let (file)
           (make-glyph
            (nconc
-            (if (setq file (liece-locate-icon-file
-                            "liece-pointer.xpm"))
+            (if (and (featurep 'xpm)
+                     (setq file (liece-locate-icon-file "liece-pointer.xpm")))
                 (list (vector 'xpm :file file)))
-            (if (setq file (liece-locate-icon-file
-                            "liece-pointer.xbm"))
+            (if (and (featurep 'xbm)
+                     (setq file (liece-locate-icon-file "liece-pointer.xbm")))
                 (list (vector 'xbm :file file)))
             '([string :data "Liece:"]))))))
     (set-glyph-face glyph 'modeline-buffer-id)
@@ -308,7 +308,8 @@ Modify whole identification by side effect."
    (let ((glyph
          (make-glyph
           (nconc
-           (if (setq file (liece-locate-icon-file file))
+           (if (and (featurep 'xpm)
+                    (setq file (liece-locate-icon-file file)))
                (list (vector 'xpm :file file)))
            (if string
                (list (vector 'string :data string)))))))
@@ -422,15 +423,6 @@ Always two arguments are passed, OBJECT and NICK."
       (let ((filename (match-string 1 (cdr object))))
        (liece-command-dcc-send filename nick))))
 
-(defadvice easy-menu-add-item
-  (around liece-fix-menu-path-switch-buffer activate)
-  "Advice for XEmacs 20.4 or earlier."
-  (save-excursion
-    (set-buffer liece-command-buffer)
-    (add-menu-button
-     (cons (car (ad-get-arg 0)) (ad-get-arg 1))
-     (ad-get-arg 2) (ad-get-arg 3))))
-
 (eval-and-compile
   (setq liece-x-face-insert-function
        (function liece-x-face-insert-with-xemacs))
@@ -440,11 +432,8 @@ Always two arguments are passed, OBJECT and NICK."
       (let ((glyph (cdr-safe (assoc nick liece-glyph-cache))))
        (unless glyph
          (setq glyph (make-glyph
-                      (cond
-                       ((and (featurep 'xface)
-                             (memq (console-type) '(x mswindows)))
-                        `[xface :data ,str])
-                       (t `[string :data ,str]))))
+                      (list (vector 'xface :data str)
+                            (vector 'string :data str))))
          (when glyph
            (push (cons nick glyph) liece-glyph-cache)
            (set-glyph-face glyph 'default)))
@@ -501,7 +490,9 @@ Always two arguments are passed, OBJECT and NICK."
   "Display splash logo in HEIGHT."
   (or (bolp) (insert "\n"))
   (let ((bow (point))
-       (glyph (make-glyph `[xpm :data ,liece-xemacs-logo]))
+       (glyph (make-glyph
+               (list (vector 'xpm :data liece-xemacs-logo)
+                     [nothing])))
        (lh (/ (window-pixel-height) (window-height)))
        (lw (/ (window-pixel-width) (window-width)))
        (liece-insert-environment-version nil)
@@ -513,10 +504,9 @@ Always two arguments are passed, OBJECT and NICK."
     (insert-char ?\  (max 0 (/ (- (window-width)
                                  (/ (glyph-width glyph) lw))
                               2)))
-    (when (and (featurep 'xpm) (memq (console-type) '(x mswindows)))
-      (set-extent-end-glyph
-       (make-extent (point) (point))
-       glyph))
+    (set-extent-end-glyph
+     (make-extent (point) (point))
+     glyph)
     (insert "\n")
     (insert-char ?\  (max 0 (/ (- (window-width) (length (liece-version))) 2)))
     (setq bov (point))
@@ -539,10 +529,10 @@ If ARG is given, don't hide splash buffer."
               (unwind-protect
                   (progn
                     (setq config (current-window-configuration))
-                    (switch-to-buffer
-                     (setq buffer (generate-new-buffer
-                                   (concat (if arg "*" " *")
-                                           (liece-version) "*"))))
+                   (setq buffer (generate-new-buffer
+                                 (concat (if arg "*" " *")
+                                         (liece-version) "*")))
+                    (switch-to-buffer buffer)
                     (delete-other-windows)
                     (liece-xemacs-splash-at-point)
                     (set-buffer-modified-p nil)
@@ -552,40 +542,44 @@ If ARG is given, don't hide splash buffer."
                   (set-window-configuration config)
                   (redisplay-frame frame)))))))
 
-(or (eq 'stream (device-type))
-    (liece-xemacs-splash))
+(unless (or liece-inhibit-startup-message
+           (eq 'stream (device-type)))
+  (liece-xemacs-splash))
 
 ;;; @ unread mark
 ;;; 
 (defun liece-xemacs-unread-mark (chnl)
   (if liece-display-unread-mark
-    (with-current-buffer liece-channel-list-buffer
-      (let* ((buffer-read-only nil)
-             (file (liece-xemacs-icon-path
-                   liece-xemacs-unread-icon))
-            (glyph (make-glyph (vector 'xpm ':file file)))
-            ext)
-       (goto-char (point-min))
-       (when (re-search-forward (concat "^ ?[0-9]+: " chnl "$") nil t)
-          (goto-char (match-end 0))
-         (insert " ")
-         (setq ext (make-extent (match-end 0) (1+ (match-end 0))))
-         (set-extent-end-glyph ext glyph))))))
+      (with-current-buffer liece-channel-list-buffer
+        (let* ((buffer-read-only nil)
+              (file (liece-locate-icon-file liece-xemacs-unread-icon))
+              (glyph
+               (make-glyph
+                (nconc (if (and (featurep 'xpm) file)
+                           (list (vector 'xpm :file file)))
+                       (list (vector 'string
+                                     :data liece-channel-unread-character)))))
+              ext)
+         (goto-char (point-min))
+         (when (re-search-forward (concat "^ ?[0-9]+: " chnl "$") nil t)
+            (goto-char (match-end 0))
+           (insert " ")
+           (setq ext (make-extent (match-end 0) (1+ (match-end 0))))
+           (set-extent-end-glyph ext glyph))))))
 
 (defun liece-xemacs-read-mark (chnl)
   (if liece-display-unread-mark
-    (with-current-buffer liece-channel-list-buffer
-      (let ((buffer-read-only nil))
-       (goto-char (point-min))
-       (when (re-search-forward (concat "^ ?[0-9]+: " chnl " $") nil t)
-          (goto-char (1- (match-end 0)))
-         (delete-char 1))))))
+      (with-current-buffer liece-channel-list-buffer
+        (let ((buffer-read-only nil))
+         (goto-char (point-min))
+         (when (re-search-forward (concat "^ ?[0-9]+: " chnl " $") nil t)
+            (goto-char (1- (match-end 0)))
+           (delete-char 1))))))
 
 (defun liece-xemacs-redisplay-unread-mark ()
   (if liece-display-unread-mark
-    (let ((chnl))
       (dolist (chnl liece-channel-unread-list)
-        (liece-xemacs-unread-mark chnl)))))
+        (liece-xemacs-unread-mark chnl))))
 
 \f
 ;;; @ emulation functions
@@ -620,15 +614,9 @@ If ARG is given, don't hide splash buffer."
 (add-hook 'liece-nick-replace-hook 'liece-xemacs-glyph-nick-region)
 (add-hook 'liece-nick-replace-hook 'liece-xemacs-set-drop-functions)
 
-(if (and (featurep 'xpm)
-        (memq (console-type) '(x gtk mswindows)))
-    (progn
-      (fset 'liece-redisplay-unread-mark 'liece-xemacs-redisplay-unread-mark)
-      (add-hook 'liece-channel-unread-hook 'liece-xemacs-unread-mark)
-      (add-hook 'liece-channel-read-hook 'liece-xemacs-read-mark))
-  (fset 'liece-redisplay-unread-mark 'liece-emacs-redisplay-unread-mark)
-  (add-hook 'liece-channel-unread-hook 'liece-emacs-unread-mark)
-  (add-hook 'liece-channel-read-hook 'liece-emacs-read-mark))
+(fset 'liece-redisplay-unread-mark 'liece-xemacs-redisplay-unread-mark)
+(add-hook 'liece-channel-unread-functions 'liece-xemacs-unread-mark)
+(add-hook 'liece-channel-read-functions 'liece-xemacs-read-mark)
 
 (provide 'liece-xemacs)