* gnus-clfns.el (butlast): Fix a serious bug that it behaved like `nbutlast'.
authoryamaoka <yamaoka>
Fri, 11 Jan 2002 11:59:28 +0000 (11:59 +0000)
committeryamaoka <yamaoka>
Fri, 11 Jan 2002 11:59:28 +0000 (11:59 +0000)
 Special thanks to Keiichi-san for the great discovery.
(last, butlast): Use the native function if Emacs 21+ is used.

ChangeLog
lisp/gnus-clfns.el

index 7085f3f..b33ff5f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2002-01-11  Katsumi Yamaoka  <yamaoka@jpl.org>
 
+       * lisp/gnus-clfns.el (butlast): Fix a serious bug that it behaved
+       like `nbutlast'.  Special thanks to Keiichi-san for the great
+       discovery.
+       (last, butlast): Use the native function if Emacs 21+ is used.
+
        * lisp/gnus.el (gnus-product-variable-file-list): Add a check for
        the value of `gnus-use-correct-string-widths' in the forms.
 
index 123b9b1..8f927bc 100644 (file)
@@ -1,5 +1,6 @@
 ;;; gnus-clfns.el --- compiler macros for emulating cl functions
-;; Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+
+;; Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
 
 ;; Author: Kastsumi Yamaoka <yamaoka@jpl.org>
 ;; Keywords: cl, compile
@@ -36,7 +37,8 @@
 
   (define-compiler-macro butlast (&whole form x &optional n)
     (if (and (fboundp 'butlast)
-            (subrp (symbol-function 'butlast)))
+            (or (>= emacs-major-version 21)
+                (subrp (symbol-function 'butlast))))
        form
       (if n
          `(let ((x ,x)
                 (or n (setq n 1))
                 (and (< n m)
                      (progn
-                       (if (> n 0) (setcdr (nthcdr (- (1- m) n) x) nil))
+                       (if (> n 0)
+                           (progn
+                             (setq x (copy-sequence x))
+                             (setcdr (nthcdr (- (1- m) n) x) nil)))
                        x)))))
        `(let* ((x ,x)
                (m (length x)))
           (and (< 1 m)
                (progn
+                 (setq x (copy-sequence x))
                  (setcdr (nthcdr (- m 2) x) nil)
                  x))))))
 
@@ -88,7 +94,8 @@
 
   (define-compiler-macro last (&whole form x &optional n)
     (if (and (fboundp 'last)
-            (subrp (symbol-function 'last)))
+            (or (>= emacs-major-version 21)
+                (subrp (symbol-function 'last))))
        form
       (if n
          `(let* ((x ,x)