From: yamaoka Date: Fri, 11 Jan 2002 11:59:51 +0000 (+0000) Subject: * gnus-clfns.el (butlast): Fix a serious bug that it behaved like `nbutlast'. X-Git-Tag: t-gnus-6_15_5-02-quimby~15 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=afd94a412d01931f4fe551fb09ae086c0fa6eb48;p=elisp%2Fgnus.git- * 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. --- diff --git a/ChangeLog b/ChangeLog index 07e9b4f..ea25a5e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2002-01-11 Katsumi Yamaoka + * 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. diff --git a/lisp/gnus-clfns.el b/lisp/gnus-clfns.el index 123b9b1..8f927bc 100644 --- a/lisp/gnus-clfns.el +++ b/lisp/gnus-clfns.el @@ -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 ;; 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) @@ -47,12 +49,16 @@ (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)