*** empty log message ***
[gnus] / lisp / gnus-ems.el
index 07ff7aa..2438b31 100644 (file)
@@ -1,7 +1,7 @@
 ;;; gnus-ems.el --- functions for making Gnus work under different Emacsen
-;; Copyright (C) 1995 Free Software Foundation, Inc.
+;; Copyright (C) 1995,96,97,98 Free Software Foundation, Inc.
 
-;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
+;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
 ;; Keywords: news
 
 ;; This file is part of GNU Emacs.
 ;; GNU General Public License for more details.
 
 ;; 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, 675 Mass Ave, Cambridge, MA 02139, USA.
+;; 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.
 
 ;;; Commentary:
 
 ;;; Code:
 
+(eval-when-compile (require 'cl))
+
+;;; Function aliases later to be redefined for XEmacs usage.
+
+(defvar gnus-xemacs (string-match "XEmacs\\|Lucid" emacs-version)
+  "Non-nil if running under XEmacs.")
+
 (defvar gnus-mouse-2 [mouse-2])
-(defvar gnus-easymenu 'easymenu)
-(defvar gnus-group-mode-hook ())
-(defvar gnus-summary-mode-hook ())
-(defvar gnus-article-mode-hook ())
-
-(defalias 'gnus-make-overlay 'make-overlay)
-(defalias 'gnus-overlay-put 'overlay-put)
-(defalias 'gnus-move-overlay 'move-overlay)
-
-;; Don't warn about these undefined variables.
-                                       ;defined in gnus.el
-(defvar gnus-active-hashtb)
-(defvar gnus-article-buffer)
-(defvar gnus-auto-center-summary)
-(defvar gnus-buffer-list)
-(defvar gnus-current-headers)
-(defvar gnus-level-killed)
-(defvar gnus-level-zombie)
-(defvar gnus-newsgroup-bookmarks)
-(defvar gnus-newsgroup-dependencies)
-(defvar gnus-newsgroup-headers-hashtb-by-number)
-(defvar gnus-newsgroup-selected-overlay)
-(defvar gnus-newsrc-hashtb)
-(defvar gnus-read-mark)
-(defvar gnus-refer-article-method)
-(defvar gnus-reffed-article-number)
-(defvar gnus-unread-mark)
-(defvar gnus-version)
-(defvar gnus-view-pseudos)
-(defvar gnus-view-pseudos-separately)
-(defvar gnus-visual)
-(defvar gnus-zombie-list)
-                                       ;defined in gnus-msg.el
-(defvar gnus-article-copy)
-(defvar gnus-check-before-posting)
-                                       ;defined in gnus-vis.el
-(defvar gnus-article-button-face)
-(defvar gnus-article-mouse-face)
-(defvar gnus-summary-selected-face)
-
-
-;; We do not byte-compile this file, because error messages are such a
-;; bore.  
-
-(eval
- '(progn
-    (if (string-match "XEmacs\\|Lucid" emacs-version)
-       ()
-      ;; Added by Per Abrahamsen <amanda@iesd.auc.dk>.
-      (defvar gnus-display-type 
-       (condition-case nil
-           (let ((display-resource (x-get-resource ".displayType" "DisplayType")))
-             (cond (display-resource (intern (downcase display-resource)))
-                   ((x-display-color-p) 'color)
-                   ((x-display-grayscale-p) 'grayscale)
-                   (t 'mono)))
-         (error 'mono))
-       "A symbol indicating the display Emacs is running under.
-The symbol should be one of `color', `grayscale' or `mono'. If Emacs
-guesses this display attribute wrongly, either set this variable in
-your `~/.emacs' or set the resource `Emacs.displayType' in your
-`~/.Xdefaults'. See also `gnus-background-mode'.
-
-This is a meta-variable that will affect what default values other
-variables get.  You would normally not change this variable, but
-pounce directly on the real variables themselves.")
-
-      (defvar gnus-background-mode 
-       (condition-case nil
-           (let ((bg-resource (x-get-resource ".backgroundMode"
-                                              "BackgroundMode"))
-                 (params (frame-parameters)))
-             (cond (bg-resource (intern (downcase bg-resource)))
-                   ((and (cdr (assq 'background-color params))
-                         (< (apply '+ (x-color-values
-                                       (cdr (assq 'background-color params))))
-                            (/ (apply '+ (x-color-values "white")) 3)))
-                    'dark)
-                   (t 'light)))
-         (error 'light))
-       "A symbol indicating the Emacs background brightness.
-The symbol should be one of `light' or `dark'.
-If Emacs guesses this frame attribute wrongly, either set this variable in
-your `~/.emacs' or set the resource `Emacs.backgroundMode' in your
-`~/.Xdefaults'.
-See also `gnus-display-type'.
-
-This is a meta-variable that will affect what default values other
-variables get.  You would normally not change this variable, but
-pounce directly on the real variables themselves."))
-
-    (cond 
-     ((string-match "XEmacs\\|Lucid" emacs-version)
-      ;; XEmacs definitions.
-
-      (setq gnus-mouse-2 [button2])
-      (setq gnus-easymenu 'auc-menu)
-
-      (or (memq 'underline (list-faces))
-         (and (fboundp 'make-face)
-              (funcall (intern "make-face") 'underline)))
-      ;; Must avoid calling set-face-underline-p directly, because it
-      ;; is a defsubst in emacs19, and will make the .elc files non
-      ;; portable!
-      (or (face-differs-from-default-p 'underline)
-         (funcall 'set-face-underline-p 'underline t))
-      (or (fboundp 'set-text-properties)
-         (defun set-text-properties (start end props &optional buffer)
-           (if (or (null buffer) (bufferp buffer))
-               (if props
-                   (while props
-                     (put-text-property 
-                      start end (car props) (nth 1 props) buffer)
-                     (setq props (nthcdr 2 props)))
-                 (remove-text-properties start end ())))))
-
-      (defalias 'gnus-make-overlay 'make-extent)
-      (defalias 'gnus-overlay-put 'set-extent-property)
-      (defun gnus-move-overlay (extent start end &optional buffer)
-       (set-extent-endpoints extent start end))
-
-      (or (boundp 'standard-display-table) (setq standard-display-table nil))
-      (or (boundp 'read-event) (fset 'read-event 'next-command-event))
-
-      ;; Fix by "jeff (j.d.) sparkes" <jsparkes@bnr.ca>.
-      (defvar gnus-display-type (device-class)
-       "A symbol indicating the display Emacs is running under.
-The symbol should be one of `color', `grayscale' or `mono'. If Emacs
-guesses this display attribute wrongly, either set this variable in
-your `~/.emacs' or set the resource `Emacs.displayType' in your
-`~/.Xdefaults'. See also `gnus-background-mode'.
-
-This is a meta-variable that will affect what default values other
-variables get.  You would normally not change this variable, but
-pounce directly on the real variables themselves.")
-
-
-      (or (fboundp 'x-color-values)
-         (fset 'x-color-values 
-               (lambda (color)
-                 (color-instance-rgb-components
-                  (make-color-instance color)))))
-    
-      (defvar gnus-background-mode 
-       (let ((bg-resource 
-              (condition-case ()
-                  (x-get-resource ".backgroundMode" "BackgroundMode" 'string)
-                (error nil)))
-             (params (frame-parameters)))
-         (cond (bg-resource (intern (downcase bg-resource)))
-               ((and (assq 'background-color params)
-                     (< (apply '+ (x-color-values
-                                   (cdr (assq 'background-color params))))
-                        (/ (apply '+ (x-color-values "white")) 3)))
-                'dark)
-               (t 'light)))
-       "A symbol indicating the Emacs background brightness.
-The symbol should be one of `light' or `dark'.
-If Emacs guesses this frame attribute wrongly, either set this variable in
-your `~/.emacs' or set the resource `Emacs.backgroundMode' in your
-`~/.Xdefaults'.
-See also `gnus-display-type'.
-
-This is a meta-variable that will affect what default values other
-variables get.  You would normally not change this variable, but
-pounce directly on the real variables themselves.")
-
-
-      (defun gnus-install-mouse-tracker ()
-       (require 'mode-motion)
-       (setq mode-motion-hook 'mode-motion-highlight-line)))
-
-     ((and (not (string-match "28.9" emacs-version)) 
-          (not (string-match "29" emacs-version)))
-      ;; Remove the `intangible' prop.
-      (let ((props (and (boundp 'gnus-hidden-properties) 
-                       gnus-hidden-properties)))
-       (while (and props (not (eq (car (cdr props)) 'intangible)))
-         (setq props (cdr props)))
-       (and props (setcdr props (cdr (cdr (cdr props))))))
-      (or (fboundp 'buffer-substring-no-properties)
-         (defun buffer-substring-no-properties (beg end)
-           (format "%s" (buffer-substring beg end)))))
-   
-     ((boundp 'MULE)
-      (provide 'gnusutil))
-   
-     )))
+(defvar gnus-mouse-3 [mouse-3])
+(defvar gnus-down-mouse-2 [down-mouse-2])
+(defvar gnus-widget-button-keymap nil)
+(defvar gnus-mode-line-modified
+  (if (or gnus-xemacs
+         (< emacs-major-version 20))
+      '("--**-" . "-----")
+    '("**" "--")))
+
+(eval-and-compile
+  (autoload 'gnus-xmas-define "gnus-xmas")
+  (autoload 'gnus-xmas-redefine "gnus-xmas")
+  (autoload 'appt-select-lowest-window "appt"))
+
+;;; Mule functions.
+
+(defun gnus-mule-cite-add-face (number prefix face)
+  ;; At line NUMBER, ignore PREFIX and add FACE to the rest of the line.
+  (when face
+    (let ((inhibit-point-motion-hooks t)
+         from to)
+      (goto-line number)
+      (unless (eobp)            ; Sometimes things become confused (broken).
+        (if (boundp 'MULE)
+            (forward-char (chars-in-string prefix))
+          (forward-char (length prefix)))
+        (skip-chars-forward " \t")
+        (setq from (point))
+        (end-of-line 1)
+        (skip-chars-backward " \t")
+        (setq to (point))
+        (when (< from to)
+          (push (setq overlay (gnus-make-overlay from to))
+                gnus-cite-overlay-list)
+          (gnus-overlay-put (gnus-make-overlay from to) 'face face))))))
+
+(defun gnus-mule-max-width-function (el max-width)
+  (` (let* ((val (eval (, el)))
+           (valstr (if (numberp val)
+                       (int-to-string val) val)))
+       (if (> (length valstr) (, max-width))
+          (truncate-string-to-width valstr (, max-width))
+        valstr))))
+
+(eval-and-compile
+  (if (string-match "XEmacs\\|Lucid" emacs-version)
+      nil
+
+    (defvar gnus-mouse-face-prop 'mouse-face
+      "Property used for highlighting mouse regions."))
+
+  (cond
+   ((string-match "XEmacs\\|Lucid" emacs-version)
+    (gnus-xmas-define))
+
+   ((boundp 'MULE)
+    (provide 'gnusutil))))
 
 (eval-and-compile
   (cond
@@ -221,432 +98,134 @@ pounce directly on the real variables themselves.")
     (let ((funcs '(mouse-set-point set-face-foreground
                                   set-face-background x-popup-menu)))
       (while funcs
-       (or (fboundp (car funcs))
-           (fset (car funcs) 'gnus-dummy-func))
-       (setq funcs (cdr funcs))))))
-  (or (fboundp 'file-regular-p)
-      (defun file-regular-p (file)
-       (and (not (file-directory-p file))
-            (not (file-symlink-p file))
-            (file-exists-p file))))
-  (or (fboundp 'face-list)
-      (defun face-list (&rest args)))
-  )
-
-(defun gnus-highlight-selected-summary-xemacs ()
-  ;; Highlight selected article in summary buffer
-  (if gnus-summary-selected-face
-      (progn
-       (if gnus-newsgroup-selected-overlay
-           (delete-extent gnus-newsgroup-selected-overlay))
-       (setq gnus-newsgroup-selected-overlay 
-             (make-extent (gnus-point-at-bol) (gnus-point-at-eol)))
-       (set-extent-face gnus-newsgroup-selected-overlay
-                        gnus-summary-selected-face))))
-
-(defun gnus-summary-recenter-xemacs ()
-  (let* ((top (cond ((< (window-height) 4) 0)
-                   ((< (window-height) 7) 1)
-                   (t 2)))
-        (height (- (window-height) 2))
-        (bottom (save-excursion (goto-char (point-max))
-                                (forward-line (- height))
-                                (point)))
-        (window (get-buffer-window (current-buffer))))
-    (and 
-     ;; The user has to want it,
-     gnus-auto-center-summary 
-     ;; the article buffer must be displayed,
-     (get-buffer-window gnus-article-buffer)
-     ;; Set the window start to either `bottom', which is the biggest
-     ;; possible valid number, or the second line from the top,
-     ;; whichever is the least.
-     (set-window-start
-      window (min bottom (save-excursion (forward-line (- top)) 
-                                        (point)))))))
-
-(defun gnus-group-insert-group-line-info-xemacs (group)
-  (let ((entry (gnus-gethash group gnus-newsrc-hashtb)) 
-       (beg (point))
-       active info)
-    (if entry
-       (progn
-         (setq info (nth 2 entry))
-         (gnus-group-insert-group-line 
-          nil group (nth 1 info) (nth 3 info) (car entry) (nth 4 info)))
-      (setq active (gnus-gethash group gnus-active-hashtb))
-         
-      (gnus-group-insert-group-line 
-       nil group (if (member group gnus-zombie-list) gnus-level-zombie
-                  gnus-level-killed)
-       nil (if active (- (1+ (cdr active)) (car active)) 0) nil))
-    (save-excursion
-      (goto-char beg)
-      (remove-text-properties 
-       (1+ (gnus-point-at-bol)) (1+ (gnus-point-at-eol))
-       '(gnus-group nil)))))
-
-(defun gnus-summary-refer-article-xemacs (message-id)
-  "Refer article specified by MESSAGE-ID.
-NOTE: This command only works with newsgroups that use real or simulated NNTP."
-  (interactive "sMessage-ID: ")
-  (if (or (not (stringp message-id))
-         (zerop (length message-id)))
-      ()
-    ;; Construct the correct Message-ID if necessary.
-    ;; Suggested by tale@pawl.rpi.edu.
-    (or (string-match "^<" message-id)
-       (setq message-id (concat "<" message-id)))
-    (or (string-match ">$" message-id)
-       (setq message-id (concat message-id ">")))
-    (let ((header (car (gnus-gethash (downcase message-id)
-                                    gnus-newsgroup-dependencies))))
-      (if header
-         (or (gnus-summary-goto-article (header-number header))
-             ;; The header has been read, but the article had been
-             ;; expunged, so we insert it again.
-             (let ((beg (point)))
-               (gnus-summary-insert-line
-                nil header 0 nil gnus-read-mark nil nil
-                (header-subject header))
-               (save-excursion
-                 (goto-char beg)
-                 (remove-text-properties
-                  (1+ (gnus-point-at-bol)) (1+ (gnus-point-at-eol))
-                  '(gnus-number nil gnus-mark nil gnus-level nil)))
-               (forward-line -1)
-               (header-number header)))
-       (let ((gnus-override-method gnus-refer-article-method)
-             (gnus-ancient-mark gnus-read-mark)
-             (tmp-point (window-start
-                         (get-buffer-window gnus-article-buffer)))
-             number tmp-buf)
-         (and gnus-refer-article-method
-              (gnus-check-server gnus-refer-article-method))
-         ;; Save the old article buffer.
-         (save-excursion
-           (set-buffer gnus-article-buffer)
-