Mercurial > emacs
annotate lisp/emacs-lisp/cl-compat.el @ 10219:d97313bb6f39
(bibtex-string, bibtex-preamble): Use forward-line.
(sort-subr): Don't call autload for this--that's done in loaddefs.el.
(bibtex-mode): Add autoload cookie.
Changed keybinding for bibtex-print-help-message
(from \C-ch to \C-c?). Therefore, describe-mode is not longer on
\C-c?. Also, changed prefix \C-cn for bibtex-narrow functions to
\C-c\C-r.
(bibtex-string-files): Changed documentation.
(bibtex-mode-map): Inscriptions of menu bar changed from "Entry
Types" to "Entry-Types" and "Bibtex Edit" to "BibTeX-Edit".
(bibtex-string-files): Changed documentation.
(bibtex-mode): If environment variable BIBINPUTS isn't defined,
string files are searched in the current directory.
(bibtex-completion-candidates): Now buffer-local to allow
evaluation of different bibtex-string-files in different buffers.
(bibtex-autokey-edit-before-use, bibtex-clean-entry): New variable
that determines, if the user is allowed to edit auto-generated
reference keys before they are used.
(bibtex-generate-autokey, bibtex-clean-entry): New function to
generate an autokey if necessary.
(bibtex-autokey-names, bibtex-autokey-name-change-strings,
bibtex-autokey-name-length, bibtex-autokey-name-separator,
bibtex-autokey-year-length, bibtex-autokey-titlewords,
bibtex-autokey-title-terminators,
bibtex-autokey-titlewords-stretch,
bibtex-autokey-titleword-first-ignore,
bibtex-autokey-titleword-abbrevs,
bibtex-autokey-titleword-change-strings,
bibtex-autokey-titleword-length,
bibtex-autokey-titleword-separator,
bibtex-autokey-name-year-separator,
bibtex-autokey-year-title-separator): New variables related to
bibtex-generate-autokey.
(bibtex-find-entry-location): Optional second parameter maybedup
to tell it that entering a duplicate entry isn't to report by an
error but by the return value of the function (necessary for
bibtex-clean-entry to find the correct position of an entry with
an autogenerated key without disturbing the user with unwanted
messages).
(bibtex-help-message): New variable to avoid printing of help
messages in the echo area.
(assoc-of-regexp): New function to match an alist of regexps.
(bibtex-string-files, bibtex-completion-candidates, bibtex-mode):
New variables to allow bibtex-complete-string to work on strings
initialized from a variable and from @String definitions in a list
of files, too.
(bibtex-predefined-strings, bibtex-entry-field-alist): Changed to
user options.
(bibtex-mode): Changed doc string.
(many functions and variables): Changed documentation strings of
variables and functions to hold a complete sentence in the first
line.
(bibtex-print-help-message): Now line dependent and reports if it
is called outside a BibTeX field.
(validate-bibtex-buffer): Completely rewritten to validate, if
buffer is syntactically correct.
(find-bibtex-duplicates): Moved into validate-bibtex-buffer.
(ispell-abstract, bibtex-ispell-abstract, ispell-bibtex-entry,
bibtex-ispell-entry, beginning-of-bibtex-entry,
bibtex-beginning-of-entry, end-of-bibtex-entry,
bibtex-end-of-entry, hide-bibtex-entry-bodies,
bibtex-hide-entry-bodies, narrow-to-bibtex-entry,
bibtex-narrow-to-entry, sort-bibtex-entries, bibtex-sort-entries,
validate-bibtex-buffer, bibtex-validate-buffer,
find-bibtex-entry-location, bibtex-find-entry-location): All
interactive functions are renamed, so that any interface function
begins with "bibtex-". Mapping:
ispell-abstract --> bibtex-ispell-abstract
ispell-bibtex-entry --> bibtex-ispell-entry
beginning-of-bibtex-entry --> bibtex-beginning-of-entry
end-of-bibtex-entry --> bibtex-end-of-entry
hide-bibtex-entry-bodies --> bibtex-hide-entry-bodies
narrow-to-bibtex-entry --> bibtex-narrow-to-entry
sort-bibtex-entries --> bibtex-sort-entries
validate-bibtex-buffer --> bibtex-validate-buffer
find-bibtex-entry-location --> bibtex-find-entry-location
(bibtex-maintain-sorted-entries,
bibtex-sort-ignore-string-entries): Default is now t.
(bibtex-complete-string): String list is built from additional
string list bibtex-predefined-string and current strings in file.
(string-equalp): Deleted and substituted by string-equal.
(assoc-string-equalp): Renamed to assoc-ignore-case.
(bibtex-entry): Reference key can be entered with completion. All
reference keys that are defined in buffer and all labels that
appear in crossreference entries are object to completion.
(Entry types): Changed order of entries in menu "entry types".
(bibtex-entry-field-alist): Changed order of entries slightly to
be more conform with standard BibTeX style layouts.
(bibtex-mode-map): Uniform keybindings for \C-c\C-e prefix (often
used types on control keys, sometimes used types on normal keys,
rarely used types on shift keys, almost never used types on meta
keys).
(bibtex-mode-map): Function narrow-to-bibtex-entry and counterpart
widen and function hide-bibtex-entry-bodies and counterpart
show-all bounded to appropriate local keys.
(bibtex-abbrev-table): Deleted
(bibtex-current-entry-label, put-string-on-kill-ring): Deleted
(AUCTeX provides all the functionality needed for citation
completion).
(bibtex-enclosing-reference, bibtex-pop-previous, bibtex-pop-next,
bibtex-clean-entry): Hacked for speed (bibtex-pop-previous and
bibtex-pop-next were to slow for larger BibTeX files).
(bibtex-pop-previous, bibtex-pop-next): Delimiters from previous
or next entry are changed to actual delimters if necessary.
(bibtex-entry): Fixed bug (False entry wasn't reported in error
message if bibtex-entry was called with undefined reference name).
(bibtex-entry-field-alist, bibtex-entry, bibtex-make-field,
bibtex-next-field, bibtex-clean-entry): Every reference entry now
contains a comment in addition to the name of the reference. This
comment appears in the echo area if you start editing that field
(after calling bibtex-next-field).
(bibtex-include-OPTcrossref, bibtex-entry): Changed
bibtex-include-OPTcrossref from single boolean variable to hold a
list of reference names which should have a crossref field.
(bibtex-complete-word): New function, which completes word
fragment before point to the longest prefix of predefined strings
in the buffer in the same way that ispell-complete-word operates
for words found in the dictionary.
(bibtex-reference-head): Start of bibtex-reference-head changed
from "^[ \t]*\\(" to "^\\( \\|\t\\)*\\(" (bibtex-pop-previous and
bibtex-pop-next didn't work, probably due to a bug in
re-search-forward).
(several functions): Added support for {} as field delimiters
(better than '"' for accented characters.
(bibtex-clean-entry): If optional field crossref is empty or
missing, former optional fields (if bibtex-include-OPTcrossref was
t) are necessary again. bibtex-clean-entry complains if they are
empty but not if they are missing, so you can intenionally omit
them, e. g. for a pseudo @Journal entry (needed for
crossreferences) made out of an @article with missing non-optional
fields.
Menu bar entries aren't centered anymore.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Fri, 23 Dec 1994 04:18:29 +0000 |
parents | bc5dccc5375f |
children | ac7375e60931 |
rev | line source |
---|---|
4355 | 1 ;; cl-compat.el --- Common Lisp extensions for GNU Emacs Lisp (compatibility) |
2 | |
3 ;; Copyright (C) 1993 Free Software Foundation, Inc. | |
4 | |
5 ;; Author: Dave Gillespie <daveg@synaptics.com> | |
6 ;; Version: 2.02 | |
7 ;; Keywords: extensions | |
8 | |
9 ;; This file is part of GNU Emacs. | |
10 | |
11 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
12 ;; it under the terms of the GNU General Public License as published by | |
13 ;; the Free Software Foundation; either version 1, or (at your option) | |
14 ;; any later version. | |
15 | |
16 ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 ;; GNU General Public License for more details. | |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
22 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
23 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
24 | |
7942 | 25 ;;; Commentary: |
4355 | 26 |
27 ;; These are extensions to Emacs Lisp that provide a degree of | |
28 ;; Common Lisp compatibility, beyond what is already built-in | |
29 ;; in Emacs Lisp. | |
30 ;; | |
31 ;; This package was written by Dave Gillespie; it is a complete | |
32 ;; rewrite of Cesar Quiroz's original cl.el package of December 1986. | |
33 ;; | |
34 ;; This package works with Emacs 18, Emacs 19, and Lucid Emacs 19. | |
35 ;; | |
36 ;; Bug reports, comments, and suggestions are welcome! | |
37 | |
38 ;; This file contains emulations of internal routines of the older | |
39 ;; CL package which users may have called directly from their code. | |
40 ;; Use (require 'cl-compat) to get these routines. | |
41 | |
42 ;; See cl.el for Change Log. | |
43 | |
44 | |
7942 | 45 ;;; Code: |
4355 | 46 |
47 ;; Require at load-time, but not when compiling cl-compat. | |
48 (or (featurep 'cl) (require 'cl)) | |
49 | |
50 | |
51 ;;; Keyword routines not supported by new package. | |
52 | |
53 (defmacro defkeyword (x &optional doc) | |
54 (list* 'defconst x (list 'quote x) (and doc (list doc)))) | |
55 | |
56 (defun keywordp (sym) | |
57 (and (symbolp sym) (eq (aref (symbol-name sym) 0) ?\:) (set sym sym))) | |
58 | |
59 (defun keyword-of (sym) | |
60 (or (keywordp sym) (keywordp (intern (format ":%s" sym))))) | |
61 | |
62 | |
63 ;;; Multiple values. Note that the new package uses a different | |
64 ;;; convention for multiple values. The following definitions | |
65 ;;; emulate the old convention; all function names have been changed | |
66 ;;; by capitalizing the first letter: Values, Multiple-value-*, | |
67 ;;; to avoid conflict with the new-style definitions in cl-macs. | |
68 | |
69 (put 'Multiple-value-bind 'lisp-indent-function 2) | |
70 (put 'Multiple-value-setq 'lisp-indent-function 2) | |
71 (put 'Multiple-value-call 'lisp-indent-function 1) | |
72 (put 'Multiple-value-prog1 'lisp-indent-function 1) | |
73 | |
74 (defvar *mvalues-values* nil) | |
75 | |
76 (defun Values (&rest val-forms) | |
77 (setq *mvalues-values* val-forms) | |
78 (car val-forms)) | |
79 | |
80 (defun Values-list (val-forms) | |
81 (apply 'values val-forms)) | |
82 | |
83 (defmacro Multiple-value-list (form) | |
84 (list 'let* (list '(*mvalues-values* nil) (list '*mvalues-temp* form)) | |
85 '(or (and (eq *mvalues-temp* (car *mvalues-values*)) *mvalues-values*) | |
86 (list *mvalues-temp*)))) | |
87 | |
88 (defmacro Multiple-value-call (function &rest args) | |
89 (list 'apply function | |
90 (cons 'append | |
91 (mapcar (function (lambda (x) (list 'Multiple-value-list x))) | |
92 args)))) | |
93 | |
94 (defmacro Multiple-value-bind (vars form &rest body) | |
95 (list* 'multiple-value-bind vars (list 'Multiple-value-list form) body)) | |
96 | |
97 (defmacro Multiple-value-setq (vars form) | |
98 (list 'multiple-value-setq vars (list 'Multiple-value-list form))) | |
99 | |
100 (defmacro Multiple-value-prog1 (form &rest body) | |
101 (list 'prog1 form (list* 'let '((*mvalues-values* nil)) body))) | |
102 | |
103 | |
104 ;;; Routines for parsing keyword arguments. | |
105 | |
106 (defun build-klist (arglist keys &optional allow-others) | |
107 (let ((res (Multiple-value-call 'mapcar* 'cons (unzip-lists arglist)))) | |
108 (or allow-others | |
109 (let ((bad (set-difference (mapcar 'car res) keys))) | |
110 (if bad (error "Bad keywords: %s not in %s" bad keys)))) | |
111 res)) | |
112 | |
113 (defun extract-from-klist (klist key &optional def) | |
114 (let ((res (assq key klist))) (if res (cdr res) def))) | |
115 | |
116 (defun keyword-argument-supplied-p (klist key) | |
117 (assq key klist)) | |
118 | |
119 (defun elt-satisfies-test-p (item elt klist) | |
120 (let ((test-not (cdr (assq ':test-not klist))) | |
121 (test (cdr (assq ':test klist))) | |
122 (key (cdr (assq ':key klist)))) | |
123 (if key (setq elt (funcall key elt))) | |
124 (if test-not (not (funcall test-not item elt)) | |
125 (funcall (or test 'eql) item elt)))) | |
126 | |
127 | |
128 ;;; Rounding functions with old-style multiple value returns. | |
129 | |
130 (defun cl-floor (a &optional b) (Values-list (floor* a b))) | |
131 (defun cl-ceiling (a &optional b) (Values-list (ceiling* a b))) | |
132 (defun cl-round (a &optional b) (Values-list (round* a b))) | |
133 (defun cl-truncate (a &optional b) (Values-list (truncate* a b))) | |
134 | |
135 (defun safe-idiv (a b) | |
136 (let* ((q (/ (abs a) (abs b))) | |
137 (s (* (signum a) (signum b)))) | |
138 (Values q (- a (* s q b)) s))) | |
139 | |
140 | |
141 ;; Internal routines. | |
142 | |
143 (defun pair-with-newsyms (oldforms) | |
144 (let ((newsyms (mapcar (function (lambda (x) (gensym))) oldforms))) | |
145 (Values (mapcar* 'list newsyms oldforms) newsyms))) | |
146 | |
147 (defun zip-lists (evens odds) | |
148 (mapcan 'list evens odds)) | |
149 | |
150 (defun unzip-lists (list) | |
151 (let ((e nil) (o nil)) | |
152 (while list | |
153 (setq e (cons (car list) e) o (cons (cadr list) o) list (cddr list))) | |
154 (Values (nreverse e) (nreverse o)))) | |
155 | |
156 (defun reassemble-argslists (list) | |
157 (let ((n (apply 'min (mapcar 'length list))) (res nil)) | |
158 (while (>= (setq n (1- n)) 0) | |
159 (setq res (cons (mapcar (function (lambda (x) (elt x n))) list) res))) | |
160 res)) | |
161 | |
162 (defun duplicate-symbols-p (list) | |
163 (let ((res nil)) | |
164 (while list | |
165 (if (memq (car list) (cdr list)) (setq res (cons (car list) res))) | |
166 (setq list (cdr list))) | |
167 res)) | |
168 | |
169 | |
170 ;;; Setf internals. | |
171 | |
172 (defun setnth (n list x) | |
173 (setcar (nthcdr n list) x)) | |
174 | |
175 (defun setnthcdr (n list x) | |
176 (setcdr (nthcdr (1- n) list) x)) | |
177 | |
178 (defun setelt (seq n x) | |
179 (if (consp seq) (setcar (nthcdr n seq) x) (aset seq n x))) | |
180 | |
181 | |
182 ;;; Functions omitted: case-clausify, check-do-stepforms, check-do-endforms, | |
183 ;;; extract-do-inits, extract-do[*]-steps, select-stepping-forms, | |
184 ;;; elt-satisfies-if[-not]-p, with-keyword-args, mv-bind-clausify, | |
185 ;;; all names with embedded `$'. | |
186 | |
187 | |
188 (provide 'cl-compat) | |
189 | |
190 ;;; cl-compat.el ends here | |
191 |