From e6e773081e9c9bba98fce7f87d306c9925896146 Mon Sep 17 00:00:00 2001 From: yamaoka Date: Fri, 11 Jan 2002 11:59:28 +0000 Subject: [PATCH] * 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. --- ChangeLog | 5 +++++ lisp/gnus-clfns.el | 15 +++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7085f3f..b33ff5f 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) -- 1.7.10.4