Mercurial > emacs
view lisp/emacs-lisp/cl.el @ 94414:d86cb59eea9f
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
* org/org.el (org-html-level-start): Always have id's in HTML
(org-export-as-html): Use `org-link-protocols' to
retrieve the export form of the link.
(org-add-link-type): Final parameter renamed from PUBLISH. Better
documentation of how it is to be used. Avoid double entries for
the same link type.
(org-add-link-props): New function.
(org-modules-loaded): New variable.
(org-load-modules-maybe, org-set-modules): New function.
(org-modules): New option.
(org-mode, org-cycle, orgstruct-mode, org-run-like-in-org-mode)
(orgtbl-mode, org-store-link, org-insert-link-global)
(org-open-at-point): Call `org-load-modules-maybe'.
(org-search-view): Add more text properties.
(org-agenda-schedule, org-agenda-deadline): Allow also in
search-type agendas.
(org-search-view): Order of arguments has been changed.
Interpret prefix-arg as TODO-ONLY.
(org-agenda, org-run-agenda-series, org-agenda-manipulate-query):
Take new argument order of `org-search-view' into account.
(org-todo-only): New variable.
(org-search-syntax-table): New variable and function.
(org-search-view): Do the search with the special syntax table.
(define-obsolete-function-alias): Make work with XEmacs.
(org-add-planning-info): Use old date as default when modifying an
existing deadline or scheduled item.
(org-agenda-compute-time-span): Make argument N optional.
(org-agenda-format-date-aligned): Require `cal-iso'.
(org-agenda-list): Include week into into agenda heading, don't
list it at each date (only on Mondays).
(org-read-date-analyze): Define local variable `iso-date'.
(org-agenda-format-date-aligned): Remove dependency on
`calendar-time-from-absolute'.
(org-remember-apply-template, org-go-to-remember-target):
Interpret filenames relative to `org-directory'.
(org-complete): Silently fail when trying to complete
keywords that don't have a default value.
(org-get-current-options): Added a #+DATE: option.
(org-additional-option-like-keywords): Removed "DATE:" from the
list of additional keywords.
(org-export-as-html): Removed (current-time) as unnecessary second
argument of `format-time-string'.
(org-clock-find-position): Handle special case at end of
buffer.
(org-agenda-day-view): New argument DAY-OF-YEAR, pass it on to
`org-agenda-change-time-span'.
(org-agenda-week-view): New argument ISO-WEEK, pass it on to
`org-agenda-change-time-span'.
(org-agenda-month-view): New argument MONTH, pass it on to
`org-agenda-change-time-span'.
(org-agenda-year-view): New argument YEAR, pass it on to
`org-agenda-change-time-span'.
(org-agenda-change-time-span): New optional argument N, pass it on
to `org-agenda-compute-time-span'.
(org-agenda-compute-time-span): New argument N, interpret it by
changing the starting day.
(org-small-year-to-year): New function.
(org-scheduled-past-days): Respect
`org-scheduled-past-days'.
(org-auto-repeat-maybe): Make sure that repeating
dates are pushed into the future, and that the shift is at least
one interval, never 0.
(org-update-checkbox-count): Fix bug with checkbox
counting.
(org-add-note): New command.
(org-add-log-setup): Renamed from `org-add-log-maybe'.
(org-log-note-headings): New entry for plain notes (i.e. notes not
related to state changes or clocking).
(org-get-org-file): Check for availability of
`remember-data-file'.
(org-cached-entry-get): Allow a regexp value for
`org-use-property-inheritance'.
(org-use-property-inheritance): Allow regexp value. Fix bug in
customization type.
(org-use-tag-inheritance): Allow a list and a regexp value for
this variable.
(org-scan-tags, org-get-tags-at): Implement selective tag
inheritance.
(org-entry-get): Respect value `selective' for the INHERIT
argument.
(org-tag-inherit-p, org-property-inherit-p): New functions.
(org-agenda-format-date-aligned): Allow 10 characters for
weekday, to acomodate German locale.
(org-add-archive-files): New function.
(org-agenda-files): New argument `ext', to
get archive files as well.
(org-tbl-menu): Protect the use of variables that
are only available when org-table.el gets loaded.
(org-read-agenda-file-list): Error if `org-agenda-files' is a
single directory.
(org-open-file): Allow a batch process to trigger
waiting after executing a system command.
(org-store-link): Link to headline when there is not
target and no region in an org-mode buffer when creating a link.
(org-link-types-re): New variable.
(org-make-link-regexps): Compute `org-link-types-re'.
(org-make-link-description-function): New option.
(org-agenda-date, org-agenda-date-weekend): New faces.
(org-archive-sibling-heading): New option.
(org-archive-to-archive-sibling): New function.
(org-iswitchb): New command.
(org-buffer-list): New function.
(org-agenda-columns): Also try the #+COLUMNS line in
the buffer associated with the entry at point (or with the first
entry in the agenda view).
(org-modules): Add entry for org-bibtex.el.
(org-completion-fallback-command): Moved into `org-completion'
group.
(org-clock-heading-function): Moved to `org-progress' group.
(org-auto-repeat-maybe): Make sure that a note can
be enforces if `org-log-repeat' is `note'.
(org-modules): Allow additional symbols for external
packages.
(org-ctrl-c-ctrl-c): Allow for `org-clock-overlays' to be
undefined.
(org-clock-goto): Hide drawers after showing an
entry with `org-clock-goto.'
(org-shiftup, org-shiftdown, org-shiftright, org-shiftleft): Try
also a clocktable block shift.
(org-clocktable-try-shift): New function.
(org-columns-hscoll-title): New function.
(org-columns-previous-hscroll): New variable.
(org-columns-full-header-line-format): New variable.
(org-columns-display-here-title, org-columns-remove-overlays):
Install `org-columns-hscoll-title' in post-command-hook.
* org/org.el: Split into many small files.
* org/org-agenda.el: New file, split off from org.el.
* org/org-archive.el: New file, split off from org.el.
* org/org-bbdb.el: New file.
* org/org-bibtex.el: New file, split off from org.el.
* org/org-clock.el: New file, split off from org.el.
* org/org-colview.el: New file, split off from org.el.
* org/org-compat.el: New file, split off from org.el.
* org/org-exp.el: New file, split off from org.el.
* org/org-faces.el: New file, split off from org.el.
* org/org-gnus.el: New file, split off from org.el.
* org/org-info.el: New file, split off from org.el.
* org/org-infojs.el: New file.
* org/org-irc.el: New file.
* org/org-macs.el: New file, split off from org.el.
* org/org-mew.el: New file.
* org/org-mhe.el: New file, split off from org.el.
* org/org-publish.el: New file, split off from org.el.
* org/org-remember.el: New file, split off from org.el.
* org/org-rmail.el: New file, split off from org.el.
* org/org-table.el: New file, split off from org.el.
* org/org-vm.el: New file, split off from org.el.
* org/org-wl.el: New file, split off from org.el.
2008-04-27 Jason Riedy <jason@acm.org>
* lisp/org-table.el (orgtbl-to-generic): Add a :remove-nil-lines
parameter that supresses lines that evaluate to NIL.
(orgtbl-get-fmt): New inline function for
picking apart formats that may be lists.
(orgtbl-apply-fmt): New inline function for applying formats that
may be functions.
(orgtbl-eval-str): New inline function for strings that may be
functions.
(orgtbl-format-line, orgtbl-to-generic): Use and document.
(orgtbl-to-latex, orgtbl-to-texinfo): Document.
(*orgtbl-llfmt*, *orgtbl-llstart*)
(*orgtbl-llend*): Dynamic variables for last-line formatting.
(orgtbl-format-section): Shift formatting to support detecting the
last line and formatting it specially.
(orgtbl-to-generic): Document :ll* formats. Set to the non-ll
formats unless overridden.
(orgtbl-to-latex): Suggest using :llend to suppress the final \\.
(*orgtbl-table*, *orgtbl-rtn*): Dynamically
bound variables to hold the input collection of lines and output
formatted text.
(*orgtbl-hline*, *orgtbl-sep*, *orgtbl-fmt*, *orgtbl-efmt*,
(*orgtbl-lfmt*, *orgtbl-lstart*, *orgtbl-lend*): Dynamically bound
format parameters.
(orgtbl-format-line): New function encapsulating formatting for a
single line.
(orgtbl-format-section): Similar for each section. Rebinding the
dynamic vars customizes the formatting for each section.
(orgtbl-to-generic): Use orgtbl-format-line and
orgtbl-format-section.
(org-get-param): Now unused, so delete.
(orgtbl-gather-send-defs): New function to
gather all the SEND definitions before a table.
(orgtbl-send-replace-tbl): New function to find the RECEIVE
corresponding to the current name.
(orgtbl-send-table): Use the previous two functions and implement
multiple destinations for each table.
* doc/org.texi (A LaTeX example): Note that fmt may be a
one-argument function, and efmt may be a two-argument function.
(Radio tables): Document multiple destinations.
2008-04-27 Carsten Dominik <dominik@science.uva.nl>
* org/org-agenda.el (org-add-to-diary-list): New function.
(org-prefix-has-effort): New variable.
(org-sort-agenda-noeffort-is-high): New option.
(org-agenda-columns-show-summaries)
(org-agenda-columns-compute-summary-properties): New options.
(org-format-agenda-item): Compute the duration of the item.
(org-agenda-weekend-days): New variable.
(org-agenda-list, org-timeline): Use the proper faces for dates in
the agenda and timeline buffers.
(org-agenda-archive-to-archive-sibling): New command.
(org-agenda-start-with-clockreport-mode): New option.
(org-agenda-clockreport-parameter-plist): New option.
(org-agenda-clocktable-mode): New variable.
(org-agenda-deadline-leaders): Allow a function value for the
deadline leader.
(org-agenda-get-deadlines): Deal with new function value.
* lisp/org-clock.el (org-clock): New customization group.
(org-clock-into-drawer, org-clock-out-when-done)
(org-clock-in-switch-to-state, org-clock-heading-function): Moved
into the new group.
(org-clock-out-remove-zero-time-clocks): New option.
(org-clock-out): Use `org-clock-out-remove-zero-time-clocks'.
(org-dblock-write:clocktable): Allow a Lisp form for the scope
parameter.
(org-dblock-write:clocktable): Fixed bug with total time
calculation.
(org-dblock-write:clocktable): Request the unrestricted list of
files.
(org-get-clocktable): New function.
(org-dblock-write:clocktable): Make sure :tstart and :tend can not
only be strings but also integers (an absolute day number) and
lists (m d y).
* org/org-colview.el (org-columns-next-allowed-value)
(org-columns-edit-value): Limit the effort for updatig in the
agenda to recomputing a single file.
(org-columns-compute): Only write property value if it has
changed. This avoids raising the buffer-change-flag
unnecessarily.
(org-agenda-colview-summarize)
(org-agenda-colview-compute): New functions.
(org-agenda-columns): Call `org-agenda-colview-summarize'.
* org/org-exp.el (org-export-run-in-background): New option.
(org-export-icalendar): Allow a batch process to trigger waiting
after executing a system command.
(org-export-preprocess-string): Renamed-from
`org-cleaned-string-for-export'.
(org-export-html-style): Made target class look like normal text.
(org-export-as-html): Make use of the better proprocessing in
`org-cleaned-string-for-export'.
(org-cleaned-string-for-export): Better treatment of heuristic
targets, many more internal links will now work in HTML export.
(org-get-current-options): Incorporate LINK_UP, LINK_HOME, and
INFOJS.
(org-export-inbuffer-options-extra): New variable.
(org-export-options-filters): New hook.
(org-infile-export-plist): Find also the settings keywords in
`org-export-inbuffer-options-extra'.
(org-infile-export-plist): Allow multiple #+OPTIONS lines and
multiple #+INFOJS_OPT lines.
(org-export-html-handle-js-options): New function.
(org-export-html-infojs-setup): New option.
(org-export-as-html): Call `org-export-html-handle-js-options'.
Add autoload to all entry points.
(org-skip-comments): Function removed.
* org/org-table.el (org-table-make-reference): Extra parenthesis
around single fields, to make sure that algebraic formulas get
correctly interpreted by calc.
(org-table-current-column): No longer interactive.
* org/org-export-latex.el (org-export-latex-preprocess): Renamed
from `org-export-latex-cleaned-string'.
2008-04-27 Bastien Guerry <bzg@altern.org>
* org/org-publish.el (org-publish-get-base-files-1): New function.
(org-publish-get-base-files): Use it.
(org-publish-temp-files): New variable.
Don't require 'dired-aux anymore.
(org-publish-initial-buffer): New variable.
(org-publish-org-to, org-publish): Use it.
(org-publish-get-base-files-1): Bug fix: get
the proper list of files when recursing thru a directory.
(org-publish-get-base-files): Use the :exclude property to skip
both files and directories.
author | Carsten Dominik <dominik@science.uva.nl> |
---|---|
date | Sun, 27 Apr 2008 18:33:39 +0000 |
parents | 107ccd98fa12 |
children | 606f2d163a64 90a2847062be |
line wrap: on
line source
;;; cl.el --- Common Lisp extensions for Emacs ;; Copyright (C) 1993, 2001, 2002, 2003, 2004, 2005, ;; 2006, 2007, 2008 Free Software Foundation, Inc. ;; Author: Dave Gillespie <daveg@synaptics.com> ;; Version: 2.02 ;; Keywords: extensions ;; 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 3, 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., 51 Franklin Street, Fifth Floor, ;; Boston, MA 02110-1301, USA. ;;; Commentary: ;; These are extensions to Emacs Lisp that provide a degree of ;; Common Lisp compatibility, beyond what is already built-in ;; in Emacs Lisp. ;; ;; This package was written by Dave Gillespie; it is a complete ;; rewrite of Cesar Quiroz's original cl.el package of December 1986. ;; ;; Bug reports, comments, and suggestions are welcome! ;; This file contains the portions of the Common Lisp extensions ;; package which should always be present. ;;; Future notes: ;; Once Emacs 19 becomes standard, many things in this package which are ;; messy for reasons of compatibility can be greatly simplified. For now, ;; I prefer to maintain one unified version. ;;; Change Log: ;; Version 2.02 (30 Jul 93): ;; * Added "cl-compat.el" file, extra compatibility with old package. ;; * Added `lexical-let' and `lexical-let*'. ;; * Added `define-modify-macro', `callf', and `callf2'. ;; * Added `ignore-errors'. ;; * Changed `(setf (nthcdr N PLACE) X)' to work when N is zero. ;; * Merged `*gentemp-counter*' into `*gensym-counter*'. ;; * Extended `subseq' to allow negative START and END like `substring'. ;; * Added `in-ref', `across-ref', `elements of-ref' loop clauses. ;; * Added `concat', `vconcat' loop clauses. ;; * Cleaned up a number of compiler warnings. ;; Version 2.01 (7 Jul 93): ;; * Added support for FSF version of Emacs 19. ;; * Added `add-hook' for Emacs 18 users. ;; * Added `defsubst*' and `symbol-macrolet'. ;; * Added `maplist', `mapc', `mapl', `mapcan', `mapcon'. ;; * Added `map', `concatenate', `reduce', `merge'. ;; * Added `revappend', `nreconc', `tailp', `tree-equal'. ;; * Added `assert', `check-type', `typecase', `typep', and `deftype'. ;; * Added destructuring and `&environment' support to `defmacro*'. ;; * Added destructuring to `loop', and added the following clauses: ;; `elements', `frames', `overlays', `intervals', `buffers', `key-seqs'. ;; * Renamed `delete' to `delete*' and `remove' to `remove*'. ;; * Completed support for all keywords in `remove*', `substitute', etc. ;; * Added `most-positive-float' and company. ;; * Fixed hash tables to work with latest Lucid Emacs. ;; * `proclaim' forms are no longer compile-time-evaluating; use `declaim'. ;; * Syntax for `warn' declarations has changed. ;; * Improved implementation of `random*'. ;; * Moved most sequence functions to a new file, cl-seq.el. ;; * Moved `eval-when' into cl-macs.el. ;; * Moved `pushnew' and `adjoin' to cl.el for most common cases. ;; * Moved `provide' forms down to ends of files. ;; * Changed expansion of `pop' to something that compiles to better code. ;; * Changed so that no patch is required for Emacs 19 byte compiler. ;; * Made more things dependent on `optimize' declarations. ;; * Added a partial implementation of struct print functions. ;; * Miscellaneous minor changes. ;; Version 2.00: ;; * First public release of this package. ;;; Code: (defvar cl-optimize-speed 1) (defvar cl-optimize-safety 1) ;;;###autoload (defvar custom-print-functions nil "This is a list of functions that format user objects for printing. Each function is called in turn with three arguments: the object, the stream, and the print level (currently ignored). If it is able to print the object it returns true; otherwise it returns nil and the printer proceeds to the next function on the list. This variable is not used at present, but it is defined in hopes that a future Emacs interpreter will be able to use it.") (defun cl-unload-function () "Stop unloading of the Common Lisp extensions." (message "Cannot unload the feature `cl'") ;; stop standard unloading! t) ;;; Generalized variables. ;; These macros are defined here so that they ;; can safely be used in .emacs files. (defmacro incf (place &optional x) "Increment PLACE by X (1 by default). PLACE may be a symbol, or any generalized variable allowed by `setf'. The return value is the incremented value of PLACE." (if (symbolp place) (list 'setq place (if x (list '+ place x) (list '1+ place))) (list 'callf '+ place (or x 1)))) (defmacro decf (place &optional x) "Decrement PLACE by X (1 by default). PLACE may be a symbol, or any generalized variable allowed by `setf'. The return value is the decremented value of PLACE." (if (symbolp place) (list 'setq place (if x (list '- place x) (list '1- place))) (list 'callf '- place (or x 1)))) (defmacro pop (place) "Remove and return the head of the list stored in PLACE. Analogous to (prog1 (car PLACE) (setf PLACE (cdr PLACE))), though more careful about evaluating each argument only once and in the right order. PLACE may be a symbol, or any generalized variable allowed by `setf'." (if (symbolp place) (list 'car (list 'prog1 place (list 'setq place (list 'cdr place)))) (cl-do-pop place))) (defmacro push (x place) "Insert X at the head of the list stored in PLACE. Analogous to (setf PLACE (cons X PLACE)), though more careful about evaluating each argument only once and in the right order. PLACE may be a symbol, or any generalized variable allowed by `setf'." (if (symbolp place) (list 'setq place (list 'cons x place)) (list 'callf2 'cons x place))) (defmacro pushnew (x place &rest keys) "(pushnew X PLACE): insert X at the head of the list if not already there. Like (push X PLACE), except that the list is unmodified if X is `eql' to an element already on the list. \nKeywords supported: :test :test-not :key \n(fn X PLACE [KEYWORD VALUE]...)" (if (symbolp place) (if (null keys) `(let ((x ,x)) (if (memql x ,place) ,place (setq ,place (cons x ,place)))) (list 'setq place (list* 'adjoin x place keys))) (list* 'callf2 'adjoin x place keys))) (defun cl-set-elt (seq n val) (if (listp seq) (setcar (nthcdr n seq) val) (aset seq n val))) (defun cl-set-nthcdr (n list x) (if (<= n 0) x (setcdr (nthcdr (1- n) list) x) list)) (defun cl-set-buffer-substring (start end val) (save-excursion (delete-region start end) (goto-char start) (insert val) val)) (defun cl-set-substring (str start end val) (if end (if (< end 0) (incf end (length str))) (setq end (length str))) (if (< start 0) (incf start (length str))) (concat (and (> start 0) (substring str 0 start)) val (and (< end (length str)) (substring str end)))) ;;; Control structures. ;; These macros are so simple and so often-used that it's better to have ;; them all the time than to load them from cl-macs.el. (defun cl-map-extents (&rest cl-args) (apply 'cl-map-overlays cl-args)) ;;; Blocks and exits. (defalias 'cl-block-wrapper 'identity) (defalias 'cl-block-throw 'throw) ;;; Multiple values. ;; True multiple values are not supported, or even ;; simulated. Instead, multiple-value-bind and friends simply expect ;; the target form to return the values as a list. (defsubst values (&rest values) "Return multiple values, Common Lisp style. The arguments of `values' are the values that the containing function should return." values) (defsubst values-list (list) "Return multiple values, Common Lisp style, taken from a list. LIST specifies the list of values that the containing function should return." list) (defsubst multiple-value-list (expression) "Return a list of the multiple values produced by EXPRESSION. This handles multiple values in Common Lisp style, but it does not work right when EXPRESSION calls an ordinary Emacs Lisp function that returns just one value." expression) (defsubst multiple-value-apply (function expression) "Evaluate EXPRESSION to get multiple values and apply FUNCTION to them. This handles multiple values in Common Lisp style, but it does not work right when EXPRESSION calls an ordinary Emacs Lisp function that returns just one value." (apply function expression)) (defalias 'multiple-value-call 'apply "Apply FUNCTION to ARGUMENTS, taking multiple values into account. This implementation only handles the case where there is only one argument.") (defsubst nth-value (n expression) "Evaluate EXPRESSION to get multiple values and return the Nth one. This handles multiple values in Common Lisp style, but it does not work right when EXPRESSION calls an ordinary Emacs Lisp function that returns just one value." (nth n expression)) ;;; Macros. (defvar cl-macro-environment nil) (defvar cl-old-macroexpand (prog1 (symbol-function 'macroexpand) (defalias 'macroexpand 'cl-macroexpand))) (defun cl-macroexpand (cl-macro &optional cl-env) "Return result of expanding macros at top level of FORM. If FORM is not a macro call, it is returned unchanged. Otherwise, the macro is expanded and the expansion is considered in place of FORM. When a non-macro-call results, it is returned. The second optional arg ENVIRONMENT specifies an environment of macro definitions to shadow the loaded ones for use in file byte-compilation. \n(fn FORM &optional ENVIRONMENT)" (let ((cl-macro-environment cl-env)) (while (progn (setq cl-macro (funcall cl-old-macroexpand cl-macro cl-env)) (and (symbolp cl-macro) (cdr (assq (symbol-name cl-macro) cl-env)))) (setq cl-macro (cadr (assq (symbol-name cl-macro) cl-env)))) cl-macro)) ;;; Declarations. (defvar cl-compiling-file nil) (defun cl-compiling-file () (or cl-compiling-file (and (boundp 'outbuffer) (bufferp (symbol-value 'outbuffer)) (equal (buffer-name (symbol-value 'outbuffer)) " *Compiler Output*")))) (defvar cl-proclaims-deferred nil) (defun proclaim (spec) (if (fboundp 'cl-do-proclaim) (cl-do-proclaim spec t) (push spec cl-proclaims-deferred)) nil) (defmacro declaim (&rest specs) (let ((body (mapcar (function (lambda (x) (list 'proclaim (list 'quote x)))) specs))) (if (cl-compiling-file) (list* 'eval-when '(compile load eval) body) (cons 'progn body)))) ; avoid loading cl-macs.el for eval-when ;;; Symbols. (defun cl-random-time () (let* ((time (copy-sequence (current-time-string))) (i (length time)) (v 0)) (while (>= (decf i) 0) (setq v (+ (* v 3) (aref time i)))) v)) (defvar *gensym-counter* (* (logand (cl-random-time) 1023) 100)) ;;; Numbers. (defun floatp-safe (object) "Return t if OBJECT is a floating point number. On Emacs versions that lack floating-point support, this function always returns nil." (and (numberp object) (not (integerp object)))) (defun plusp (number) "Return t if NUMBER is positive." (> number 0)) (defun minusp (number) "Return t if NUMBER is negative." (< number 0)) (defun oddp (integer) "Return t if INTEGER is odd." (eq (logand integer 1) 1)) (defun evenp (integer) "Return t if INTEGER is even." (eq (logand integer 1) 0)) (defvar *random-state* (vector 'cl-random-state-tag -1 30 (cl-random-time))) ;; The following are actually set by cl-float-limits. (defconst most-positive-float nil) (defconst most-negative-float nil) (defconst least-positive-float nil) (defconst least-negative-float nil) (defconst least-positive-normalized-float nil) (defconst least-negative-normalized-float nil) (defconst float-epsilon nil) (defconst float-negative-epsilon nil) ;;; Sequence functions. (defalias 'copy-seq 'copy-sequence) (defun mapcar* (cl-func cl-x &rest cl-rest) "Apply FUNCTION to each element of SEQ, and make a list of the results. If there are several SEQs, FUNCTION is called with that many arguments, and mapping stops as soon as the shortest list runs out. With just one SEQ, this is like `mapcar'. With several, it is like the Common Lisp `mapcar' function extended to arbitrary sequence types. \n(fn FUNCTION SEQ...)" (if cl-rest (if (or (cdr cl-rest) (nlistp cl-x) (nlistp (car cl-rest))) (cl-mapcar-many cl-func (cons cl-x cl-rest)) (let ((cl-res nil) (cl-y (car cl-rest))) (while (and cl-x cl-y) (push (funcall cl-func (pop cl-x) (pop cl-y)) cl-res)) (nreverse cl-res))) (mapcar cl-func cl-x))) (defalias 'svref 'aref) ;;; List functions. (defalias 'first 'car) (defalias 'second 'cadr) (defalias 'rest 'cdr) (defalias 'endp 'null) (defun third (x) "Return the third element of the list X." (car (cdr (cdr x)))) (defun fourth (x) "Return the fourth element of the list X." (nth 3 x)) (defun fifth (x) "Return the fifth element of the list X." (nth 4 x)) (defun sixth (x) "Return the sixth element of the list X." (nth 5 x)) (defun seventh (x) "Return the seventh element of the list X." (nth 6 x)) (defun eighth (x) "Return the eighth element of the list X." (nth 7 x)) (defun ninth (x) "Return the ninth element of the list X." (nth 8 x)) (defun tenth (x) "Return the tenth element of the list X." (nth 9 x)) (defun caaar (x) "Return the `car' of the `car' of the `car' of X." (car (car (car x)))) (defun caadr (x) "Return the `car' of the `car' of the `cdr' of X." (car (car (cdr x)))) (defun cadar (x) "Return the `car' of the `cdr' of the `car' of X." (car (cdr (car x)))) (defun caddr (x) "Return the `car' of the `cdr' of the `cdr' of X." (car (cdr (cdr x)))) (defun cdaar (x) "Return the `cdr' of the `car' of the `car' of X." (cdr (car (car x)))) (defun cdadr (x) "Return the `cdr' of the `car' of the `cdr' of X." (cdr (car (cdr x)))) (defun cddar (x) "Return the `cdr' of the `cdr' of the `car' of X." (cdr (cdr (car x)))) (defun cdddr (x) "Return the `cdr' of the `cdr' of the `cdr' of X." (cdr (cdr (cdr x)))) (defun caaaar (x) "Return the `car' of the `car' of the `car' of the `car' of X." (car (car (car (car x))))) (defun caaadr (x) "Return the `car' of the `car' of the `car' of the `cdr' of X." (car (car (car (cdr x))))) (defun caadar (x) "Return the `car' of the `car' of the `cdr' of the `car' of X." (car (car (cdr (car x))))) (defun caaddr (x) "Return the `car' of the `car' of the `cdr' of the `cdr' of X." (car (car (cdr (cdr x))))) (defun cadaar (x) "Return the `car' of the `cdr' of the `car' of the `car' of X." (car (cdr (car (car x))))) (defun cadadr (x) "Return the `car' of the `cdr' of the `car' of the `cdr' of X." (car (cdr (car (cdr x))))) (defun caddar (x) "Return the `car' of the `cdr' of the `cdr' of the `car' of X." (car (cdr (cdr (car x))))) (defun cadddr (x) "Return the `car' of the `cdr' of the `cdr' of the `cdr' of X." (car (cdr (cdr (cdr x))))) (defun cdaaar (x) "Return the `cdr' of the `car' of the `car' of the `car' of X." (cdr (car (car (car x))))) (defun cdaadr (x) "Return the `cdr' of the `car' of the `car' of the `cdr' of X." (cdr (car (car (cdr x))))) (defun cdadar (x) "Return the `cdr' of the `car' of the `cdr' of the `car' of X." (cdr (car (cdr (car x))))) (defun cdaddr (x) "Return the `cdr' of the `car' of the `cdr' of the `cdr' of X." (cdr (car (cdr (cdr x))))) (defun cddaar (x) "Return the `cdr' of the `cdr' of the `car' of the `car' of X." (cdr (cdr (car (car x))))) (defun cddadr (x) "Return the `cdr' of the `cdr' of the `car' of the `cdr' of X." (cdr (cdr (car (cdr x))))) (defun cdddar (x) "Return the `cdr' of the `cdr' of the `cdr' of the `car' of X." (cdr (cdr (cdr (car x))))) (defun cddddr (x) "Return the `cdr' of the `cdr' of the `cdr' of the `cdr' of X." (cdr (cdr (cdr (cdr x))))) ;;(defun last* (x &optional n) ;; "Returns the last link in the list LIST. ;;With optional argument N, returns Nth-to-last link (default 1)." ;; (if n ;; (let ((m 0) (p x)) ;; (while (consp p) (incf m) (pop p)) ;; (if (<= n 0) p ;; (if (< n m) (nthcdr (- m n) x) x))) ;; (while (consp (cdr x)) (pop x)) ;; x)) (defun list* (arg &rest rest) ; See compiler macro in cl-macs.el "Return a new list with specified ARGs as elements, consed to last ARG. Thus, `(list* A B C D)' is equivalent to `(nconc (list A B C) D)', or to `(cons A (cons B (cons C D)))'. \n(fn ARG...)" (cond ((not rest) arg) ((not (cdr rest)) (cons arg (car rest))) (t (let* ((n (length rest)) (copy (copy-sequence rest)) (last (nthcdr (- n 2) copy))) (setcdr last (car (cdr last))) (cons arg copy))))) (defun ldiff (list sublist) "Return a copy of LIST with the tail SUBLIST removed." (let ((res nil)) (while (and (consp list) (not (eq list sublist))) (push (pop list) res)) (nreverse res))) (defun copy-list (list) "Return a copy of LIST, which may be a dotted list. The elements of LIST are not copied, just the list structure itself." (if (consp list) (let ((res nil)) (while (consp list) (push (pop list) res)) (prog1 (nreverse res) (setcdr res list))) (car list))) (defun cl-maclisp-member (item list) (while (and list (not (equal item (car list)))) (setq list (cdr list))) list) (defalias 'cl-member 'memq) ; for compatibility with old CL package (defalias 'cl-floor 'floor*) (defalias 'cl-ceiling 'ceiling*) (defalias 'cl-truncate 'truncate*) (defalias 'cl-round 'round*) (defalias 'cl-mod 'mod*) (defun adjoin (cl-item cl-list &rest cl-keys) ; See compiler macro in cl-macs "Return ITEM consed onto the front of LIST only if it's not already there. Otherwise, return LIST unmodified. \nKeywords supported: :test :test-not :key \n(fn ITEM LIST [KEYWORD VALUE]...)" (cond ((or (equal cl-keys '(:test eq)) (and (null cl-keys) (not (numberp cl-item)))) (if (memq cl-item cl-list) cl-list (cons cl-item cl-list))) ((or (equal cl-keys '(:test equal)) (null cl-keys)) (if (member cl-item cl-list) cl-list (cons cl-item cl-list))) (t (apply 'cl-adjoin cl-item cl-list cl-keys)))) (defun subst (cl-new cl-old cl-tree &rest cl-keys) "Substitute NEW for OLD everywhere in TREE (non-destructively). Return a copy of TREE with all elements `eql' to OLD replaced by NEW. \nKeywords supported: :test :test-not :key \n(fn NEW OLD TREE [KEYWORD VALUE]...)" (if (or cl-keys (and (numberp cl-old) (not (integerp cl-old)))) (apply 'sublis (list (cons cl-old cl-new)) cl-tree cl-keys) (cl-do-subst cl-new cl-old cl-tree))) (defun cl-do-subst (cl-new cl-old cl-tree) (cond ((eq cl-tree cl-old) cl-new) ((consp cl-tree) (let ((a (cl-do-subst cl-new cl-old (car cl-tree))) (d (cl-do-subst cl-new cl-old (cdr cl-tree)))) (if (and (eq a (car cl-tree)) (eq d (cdr cl-tree))) cl-tree (cons a d)))) (t cl-tree))) (defun acons (key value alist) "Add KEY and VALUE to ALIST. Return a new list with (cons KEY VALUE) as car and ALIST as cdr." (cons (cons key value) alist)) (defun pairlis (keys values &optional alist) "Make an alist from KEYS and VALUES. Return a new alist composed by associating KEYS to corresponding VALUES; the process stops as soon as KEYS or VALUES run out. If ALIST is non-nil, the new pairs are prepended to it." (nconc (mapcar* 'cons keys values) alist)) ;;; Miscellaneous. ;; Define data for indentation and edebug. (dolist (entry '(((defun* defmacro*) 2) ((function*) nil (&or symbolp ([&optional 'macro] 'lambda (&rest sexp) &rest form))) ((eval-when) 1 (sexp &rest form)) ((declare) nil (&rest sexp)) ((the) 1 (sexp &rest form)) ((case ecase typecase etypecase) 1 (form &rest (sexp &rest form))) ((block return-from) 1 (sexp &rest form)) ((return) nil (&optional form)) ((do do*) 2 ((&rest &or symbolp (symbolp &optional form form)) (form &rest form) &rest form)) ((do-symbols) 1 ((symbolp form &optional form form) &rest form)) ((do-all-symbols) 1 ((symbolp form &optional form) &rest form)) ((psetq setf psetf) nil edebug-setq-form) ((progv) 2 (&rest form)) ((flet labels macrolet) 1 ((&rest (sexp sexp &rest form)) &rest form)) ((symbol-macrolet lexical-let lexical-let*) 1 ((&rest &or symbolp (symbolp form)) &rest form)) ((multiple-value-bind) 2 ((&rest symbolp) &rest form)) ((multiple-value-setq) 1 ((&rest symbolp) &rest form)) ((incf decf remf pushnew shiftf rotatef) nil (&rest form)) ((letf letf*) 1 ((&rest (&rest form)) &rest form)) ((callf destructuring-bind) 2 (sexp form &rest form)) ((callf2) 3 (sexp form form &rest form)) ((loop) nil (&rest &or symbolp form)) ((ignore-errors) 0 (&rest form)))) (dolist (func (car entry)) (put func 'lisp-indent-function (nth 1 entry)) (put func 'lisp-indent-hook (nth 1 entry)) (or (get func 'edebug-form-spec) (put func 'edebug-form-spec (nth 2 entry))))) ;; Autoload the other portions of the package. ;; We want to replace the basic versions of dolist, dotimes, declare below. (fmakunbound 'dolist) (fmakunbound 'dotimes) (fmakunbound 'declare) (load "cl-loaddefs" nil 'quiet) ;; This goes here so that cl-macs can find it if it loads right now. (provide 'cl-19) ; usage: (require 'cl-19 "cl") ;; Things to do after byte-compiler is loaded. ;; As a side effect, we cause cl-macs to be loaded when compiling, so ;; that the compiler-macros defined there will be present. (defvar cl-hacked-flag nil) (defun cl-hack-byte-compiler () (if (and (not cl-hacked-flag) (fboundp 'byte-compile-file-form)) (progn (setq cl-hacked-flag t) ; Do it first, to prevent recursion. (cl-compile-time-init)))) ; In cl-macs.el. ;; Try it now in case the compiler has already been loaded. (cl-hack-byte-compiler) ;; Also make a hook in case compiler is loaded after this file. (add-hook 'bytecomp-load-hook 'cl-hack-byte-compiler) ;; The following ensures that packages which expect the old-style cl.el ;; will be happy with this one. (provide 'cl) (run-hooks 'cl-load-hook) ;; Local variables: ;; byte-compile-dynamic: t ;; byte-compile-warnings: (not cl-functions) ;; End: ;; arch-tag: 5f07fa74-f153-4524-9303-21f5be125851 ;;; cl.el ends here