Synch to Gnus 200312310312.
[elisp/gnus.git-] / lisp / dgnushack.el
index 92b9b69..97670f4 100644 (file)
 ;  (cons 'progn (cdr form)))
 ;(defalias 'byte-compile-file-form-defsubst 'byte-compile-file-form-defun)
 
+(when (and (not (featurep 'xemacs))
+          (= emacs-major-version 21)
+          (= emacs-minor-version 3)
+          (condition-case code
+              (let ((byte-compile-error-on-warn t))
+                (byte-optimize-form (quote (pop x)) t)
+                nil)
+            (error (string-match "called for effect"
+                                 (error-message-string code)))))
+  (defadvice byte-optimize-form-code-walker (around silence-warn-for-pop
+                                                   (form for-effect)
+                                                   activate)
+    "Silence the warning \"...called for effect\" for the `pop' form.
+It is effective only when the `pop' macro is defined by cl.el rather
+than subr.el."
+    (let (tmp)
+      (if (and (eq (car-safe form) 'car)
+              for-effect
+              (setq tmp (get 'car 'side-effect-free))
+              (not byte-compile-delete-errors)
+              (not (eq tmp 'error-free))
+              (eq (car-safe (cadr form)) 'prog1)
+              (let ((var (cadr (cadr form)))
+                    (last (nth 2 (cadr form))))
+                (and (symbolp var)
+                     (null (nthcdr 3 (cadr form)))
+                     (eq (car-safe last) 'setq)
+                     (eq (cadr last) var)
+                     (eq (car-safe (nth 2 last)) 'cdr)
+                     (eq (cadr (nth 2 last)) var))))
+         (progn
+           (put 'car 'side-effect-free 'error-free)
+           (unwind-protect
+               ad-do-it
+             (put 'car 'side-effect-free tmp)))
+       ad-do-it))))
+
 (when (boundp 'MULE)
   (let (current-load-list)
     ;; Make the function to be silent at compile-time.
@@ -632,15 +669,11 @@ dgnushack-compile-verbosely.  All other users should continue to use
 dgnushack-compile."
   (dgnushack-compile t))
 
-(defun dgnushack-compile-verbosely ()
-  "Call dgnushack-compile with warnings ENABLED.  If you are compiling
-patches to gnus, you should consider modifying make.bat to call
-dgnushack-compile-verbosely.  All other users should continue to use
-dgnushack-compile."
-  (dgnushack-compile t))
-
 (defun dgnushack-compile (&optional warn)
   ;;(setq byte-compile-dynamic t)
+  (when (and (not (featurep 'xemacs))
+            (< emacs-major-version 21))
+    (setq max-specpdl-size 1200))
   (unless warn
     (setq byte-compile-warnings
          '(free-vars unresolved callargs redefine)))
@@ -698,7 +731,13 @@ Modify to suit your needs."))
 (defun dgnushack-make-cus-load ()
   (when (condition-case nil
            (load "cus-dep")
-         (error nil))
+         (error
+          (when (boundp 'MULE)
+            (if (file-exists-p "../contrib/cus-dep.el")
+                ;; Use cus-dep.el of the version of Emacs 20.7.
+                (load-file "../contrib/cus-dep.el")
+              (error "\
+You need contrib/cus-dep.el to build T-gnus with Mule 2.3@19.34; exiting.")))))
     (let ((cusload-base-file dgnushack-cus-load-file))
       (if (fboundp 'custom-make-dependencies)
          (custom-make-dependencies)