summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
authorKaroly Lorentey <lorentey@elte.hu>2004-02-17 01:52:25 +0000
committerKaroly Lorentey <lorentey@elte.hu>2004-02-17 01:52:25 +0000
commite581a4668750ed98d77f13500c983439770ec600 (patch)
treeccbc5c82753658d45458e9306feb41203ae3757b /lisp/emacs-lisp
parent806c1866e6cdfe84bd8353dda02c4c8c61267480 (diff)
parent0f98bc23509b4e909cc92237e4b082c6866da258 (diff)
downloademacs-e581a4668750ed98d77f13500c983439770ec600.tar.gz
emacs-e581a4668750ed98d77f13500c983439770ec600.tar.bz2
emacs-e581a4668750ed98d77f13500c983439770ec600.zip
Merged in changes from CVS HEAD
Patches applied: * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-71 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-72 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-73 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-74 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-75 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-76 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-77 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-78 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-79 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-80 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-81 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-82 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-83 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-84 Add lisp/emacs-lisp/macroexp.el * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-85 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-86 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-87 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-88 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-89 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-90 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-91 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-92 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-93 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-94 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-95 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-96 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-97 Update from CVS git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-77
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r--lisp/emacs-lisp/cl-macs.el8
-rw-r--r--lisp/emacs-lisp/lisp-mnt.el6
-rw-r--r--lisp/emacs-lisp/lisp-mode.el2
-rw-r--r--lisp/emacs-lisp/macroexp.el197
-rw-r--r--lisp/emacs-lisp/rx.el3
5 files changed, 206 insertions, 10 deletions
diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el
index 038786bb944..6a6b006c2ba 100644
--- a/lisp/emacs-lisp/cl-macs.el
+++ b/lisp/emacs-lisp/cl-macs.el
@@ -1,6 +1,6 @@
;;; cl-macs.el --- Common Lisp macros -*-byte-compile-dynamic: t;-*-
-;; Copyright (C) 1993, 2003 Free Software Foundation, Inc.
+;; Copyright (C) 1993, 2003, 2004 Free Software Foundation, Inc.
;; Author: Dave Gillespie <daveg@synaptics.com>
;; Version: 2.02
@@ -2261,8 +2261,7 @@ copier, a `NAME-p' predicate, and setf-able `NAME-SLOT' accessors.
(list (list 'or pred-check
(list 'error
(format "%s accessing a non-%s"
- accessor name)
- 'cl-x))))
+ accessor name)))))
(list (if (eq type 'vector) (list 'aref 'cl-x pos)
(if (= pos 0) '(car cl-x)
(list 'nth pos 'cl-x)))))) forms)
@@ -2340,8 +2339,7 @@ copier, a `NAME-p' predicate, and setf-able `NAME-SLOT' accessors.
(list (list 'or (subst temp 'cl-x pred-form)
(list 'error
(format
- "%s storing a non-%s" accessor name)
- temp))))
+ "%s storing a non-%s" accessor name)))))
(list (if (eq (car (get name 'cl-struct-type)) 'vector)
(list 'aset temp pos store)
(list 'setcar
diff --git a/lisp/emacs-lisp/lisp-mnt.el b/lisp/emacs-lisp/lisp-mnt.el
index 245772dfc54..e67835eb82d 100644
--- a/lisp/emacs-lisp/lisp-mnt.el
+++ b/lisp/emacs-lisp/lisp-mnt.el
@@ -1,6 +1,6 @@
;;; lisp-mnt.el --- utility functions for Emacs Lisp maintainers
-;; Copyright (C) 1992, 1994, 1997, 2000, 2001, 2003 Free Software Foundation, Inc.
+;; Copyright (C) 1992, 1994, 1997, 2000, 2001, 2003, 2004 Free Software Foundation, Inc.
;; Author: Eric S. Raymond <esr@snark.thyrsus.com>
;; Maintainer: FSF
@@ -522,7 +522,7 @@ copyright notice is allowed."
(setq ret
(cond
((null name)
- (format "Package %s does not exist"))
+ "Can't find package name")
((not (lm-authors))
"`Author:' tag missing")
((not (lm-maintainer))
@@ -546,7 +546,7 @@ copyright notice is allowed."
(concat "^;;;[ \t]+" name "[ \t]+ends here[ \t]*$"
"\\|^;;;[ \t]+ End of file[ \t]+" name)
nil t)))
- (format "Can't find the footer line"))
+ "Can't find the footer line")
((not (and (lm-copyright-mark) (lm-crack-copyright)))
"Can't find a valid copyright notice")
((not (or non-fsf-ok
diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el
index 04d00a2bdb5..c2dc3e6a16c 100644
--- a/lisp/emacs-lisp/lisp-mode.el
+++ b/lisp/emacs-lisp/lisp-mode.el
@@ -182,7 +182,7 @@
(make-local-variable 'parse-sexp-ignore-comments)
(setq parse-sexp-ignore-comments t)
(make-local-variable 'outline-regexp)
- (setq outline-regexp ";;;;* \\|(")
+ (setq outline-regexp ";;;;* [^ \t\n]\\|(")
(make-local-variable 'outline-level)
(setq outline-level 'lisp-outline-level)
(make-local-variable 'comment-start)
diff --git a/lisp/emacs-lisp/macroexp.el b/lisp/emacs-lisp/macroexp.el
new file mode 100644
index 00000000000..b5a279bbbf4
--- /dev/null
+++ b/lisp/emacs-lisp/macroexp.el
@@ -0,0 +1,197 @@
+;;; macroexp.el --- Additional macro-expansion support
+;;
+;; Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
+;;
+;; Author: Miles Bader <miles@gnu.org>
+;; Keywords: lisp, compiler, macros
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2, or (at your option)
+;; any later version.
+
+;; GNU Emacs is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; 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, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;;; Commentary:
+;;
+;; This file contains macro-expansions functions that are not defined in
+;; the Lisp core, namely `macroexpand-all', which expands all macros in
+;; a form, not just a top-level one.
+;;
+
+;;; Code:
+
+;; Bound by the top-level `macroexpand-all', and modified to include any
+;; macros defined by `defmacro'.
+(defvar macroexpand-all-environment nil)
+
+(defun maybe-cons (car cdr original-cons)
+ "Return (CAR . CDR), using ORIGINAL-CONS if possible."
+ (if (and (eq car (car original-cons)) (eq cdr (cdr original-cons)))
+ original-cons
+ (cons car cdr)))
+
+;; We use this special macro to iteratively process forms and share list
+;; structure of the result with the input. Doing so recursively using
+;; `maybe-cons' results in excessively deep recursion for very long
+;; input forms.
+(defmacro macroexp-accumulate (#1=#:\(var\ list\) &rest body)
+ "Return a list of the results of evaluating BODY for each element of LIST.
+Evaluate BODY with VAR bound to each `car' from LIST, in turn.
+Return a list of the values of the final form in BODY.
+The list structure of the result will share as much with LIST as
+possible (for instance, when BODY just returns VAR unchanged, the
+result will be eq to LIST)."
+ (let ((var (car #1#))
+ (list (cadr #1#))
+ (shared (make-symbol "shared"))
+ (unshared (make-symbol "unshared"))
+ (tail (make-symbol "tail"))
+ (new-el (make-symbol "new-el")))
+ `(let* ((,shared ,list)
+ (,unshared nil)
+ (,tail ,shared)
+ ,var ,new-el)
+ (while ,tail
+ (setq ,var (car ,tail)
+ ,new-el (progn ,@body))
+ (unless (eq ,var ,new-el)
+ (while (not (eq ,shared ,tail))
+ (push (pop ,shared) ,unshared))
+ (setq ,shared (cdr ,shared))
+ (push ,new-el ,unshared))
+ (setq ,tail (cdr ,tail)))
+ (nconc (nreverse ,unshared) ,shared))))
+(put 'macroexp-accumulate 'lisp-indent-function 1)
+
+(defun macroexpand-all-forms (forms &optional skip)
+ "Return FORMS with macros expanded. FORMS is a list of forms.
+If SKIP is non-nil, then don't expand that many elements at the start of
+FORMS."
+ (macroexp-accumulate (form forms)
+ (if (or (null skip) (zerop skip))
+ (macroexpand-all-1 form)
+ (setq skip (1- skip))
+ form)))
+
+(defun macroexpand-all-clauses (clauses &optional skip)
+ "Return CLAUSES with macros expanded.
+CLAUSES is a list of lists of forms; any clause that's not a list is ignored.
+If SKIP is non-nil, then don't expand that many elements at the start of
+each clause."
+ (macroexp-accumulate (clause clauses)
+ (if (listp clause)
+ (macroexpand-all-forms clause skip)
+ clause)))
+
+(defun macroexpand-all-1 (form)
+ "Expand all macros in FORM.
+This is an internal version of `macroexpand-all'.
+Assumes the caller has bound `macroexpand-all-environment'."
+ (if (and (listp form) (eq (car form) 'backquote-list*))
+ ;; Special-case `backquote-list*', as it is normally a macro that
+ ;; generates exceedingly deep expansions from relatively shallow input
+ ;; forms. We just process it `in reverse' -- first we expand all the
+ ;; arguments, _then_ we expand the top-level definition.
+ (macroexpand (macroexpand-all-forms form 1)
+ macroexpand-all-environment)
+ ;; Normal form; get its expansion, and then expand arguments.
+ (setq form (macroexpand form macroexpand-all-environment))
+ (if (consp form)
+ (let ((fun (car form)))
+ (cond
+ ((eq fun 'cond)
+ (maybe-cons fun (macroexpand-all-clauses (cdr form)) form))
+ ((eq fun 'condition-case)
+ (maybe-cons
+ fun
+ (maybe-cons (cadr form)
+ (maybe-cons (macroexpand-all-1 (nth 2 form))
+ (macroexpand-all-clauses (nthcdr 3 form) 1)
+ (cddr form))
+ (cdr form))
+ form))
+ ((eq fun 'defmacro)
+ (push (cons (cadr form) (cons 'lambda (cddr form)))
+ macroexpand-all-environment)
+ (macroexpand-all-forms form 3))
+ ((eq fun 'defun)
+ (macroexpand-all-forms form 3))
+ ((memq fun '(defvar defconst))
+ (macroexpand-all-forms form 2))
+ ((eq fun 'function)
+ (if (and (consp (cadr form)) (eq (car (cadr form)) 'lambda))
+ (maybe-cons fun
+ (maybe-cons (macroexpand-all-forms (cadr form) 2)
+ nil
+ (cadr form))
+ form)
+ form))
+ ((memq fun '(let let*))
+ (maybe-cons fun
+ (maybe-cons (macroexpand-all-clauses (cadr form) 1)
+ (macroexpand-all-forms (cddr form))
+ (cdr form))
+ form))
+ ((eq fun 'quote)
+ form)
+ ((and (consp fun) (eq (car fun) 'lambda))
+ ;; embedded lambda
+ (maybe-cons (macroexpand-all-forms fun 2)
+ (macroexpand-all-forms (cdr form))
+ form))
+ ;; The following few cases are for normal function calls that
+ ;; are known to funcall one of their arguments. The byte
+ ;; compiler has traditionally handled these functions specially
+ ;; by treating a lambda expression quoted by `quote' as if it
+ ;; were quoted by `function'. We make the same transformation
+ ;; here, so that any code that cares about the difference will
+ ;; see the same transformation.
+ ;; First arg is a function:
+ ((and (memq fun '(apply mapcar mapatoms mapconcat mapc))
+ (consp (cadr form))
+ (eq (car (cadr form)) 'quote))
+ ;; We don't use `maybe-cons' since there's clearly a change.
+ (cons fun
+ (cons (macroexpand-all-1 (cons 'function (cdr (cadr form))))
+ (macroexpand-all-forms (cddr form)))))
+ ;; Second arg is a function:
+ ((and (eq fun 'sort)
+ (consp (nth 2 form))
+ (eq (car (nth 2 form)) 'quote))
+ ;; We don't use `maybe-cons' since there's clearly a change.
+ (cons fun
+ (cons (macroexpand-all-1 (cadr form))
+ (cons (macroexpand-all-1
+ (cons 'function (cdr (nth 2 form))))
+ (macroexpand-all-forms (nthcdr 3 form))))))
+ (t
+ ;; For everything else, we just expand each argument (for
+ ;; setq/setq-default this works alright because the variable names
+ ;; are symbols).
+ (macroexpand-all-forms form 1))))
+ form)))
+
+;;;###autoload
+(defun macroexpand-all (form &optional environment)
+ "Return result of expanding macros at all levels in FORM.
+If no macros are expanded, FORM is returned unchanged.
+The second optional arg ENVIRONMENT specifies an environment of macro
+definitions to shadow the loaded ones for use in file byte-compilation."
+ (let ((macroexpand-all-environment environment))
+ (macroexpand-all-1 form)))
+
+(provide 'macroexp)
+
+;;; arch-tag: af9b8c24-c196-43bc-91e1-a3570790fa5a
+;;; macroexp.el ends here
diff --git a/lisp/emacs-lisp/rx.el b/lisp/emacs-lisp/rx.el
index bc16a84b156..c6f9ce6f4a6 100644
--- a/lisp/emacs-lisp/rx.el
+++ b/lisp/emacs-lisp/rx.el
@@ -345,7 +345,8 @@ matches anything."
(defun rx-not (form)
"Parse and produce code from FORM. FORM is `(not ...)'."
(rx-check form)
- (let ((result (rx-to-string (cadr form) 'no-group)))
+ (let ((result (rx-to-string (cadr form) 'no-group))
+ case-fold-search)
(cond ((string-match "\\`\\[^" result)
(if (= (length result) 4)
(substring result 2 3)