Mercurial > emacs
annotate lisp/emacs-lisp/assoc.el @ 19445:94a54fbffb3e
A lot of comment and doc fixes.
Replace: 'nil by nil, '() by nil, 't by t.
(ps-print-version): New version number (3.05).
(ps-zebra-stripe, ps-number-of-zebra, ps-line-number)
(ps-print-background-image, ps-print-background-text): New variables
to customize zebra stripes, line number, image background and text
background features, respectively.
(ps-adobe-tag): Tagged to PostScript level 3.
(ps-print-buffer, ps-print-buffer-with-faces)
(ps-print-region, ps-print-region-with-faces)
(ps-spool-buffer, ps-spool-buffer-with-faces)
(ps-spool-region, ps-spool-region-with-faces): Call more primitive
functions for PostScript printing (functions below).
(ps-print-with-faces, ps-print-without-faces)
(ps-spool-with-faces, ps-spool-without-faces): More primitive
functions for PostScript printing.
(ps-line-lengths, ps-nb-pages-buffer, ps-nb-pages-region)
(ps-line-lengths-internal, ps-nb-pages): Doc fixes.
(ps-print-prologue-1): a lot of PostScript programming:
/dobackgroundstring, /dounderline, /UL: Postscript functions deleted.
/reencodeFontISO, /F, /BG, /HL, /W, /S, /BeginDSCPage, /BeginPage,
/EndPage: adjusted for new effects (outline, shadow, etc).
/PLN, /EF, /Hline, /doBox, /doRect, /doShadow, /doOutline,
/FillBgColor, /doLineNumber, /printZebra, /doColumnZebra,
/doZebra, /BeginBackImage, /EndBackImage, /ShowBackText: New procedures.
(ps-current-underline-p, ps-set-underline): Var and fn deleted.
(ps-showline-count, ps-background-pages, ps-background-all-pages)
(ps-background-text-count, ps-background-image-count): New variables.
(ps-header-font, ps-header-title-font)
(ps-header-line-height, ps-header-title-line-height)
(ps-landscape-page-height): Set initial value to nil.
(ps-print-face-extension-alist, ps-print-face-map-alist):
New variables for face remapping.
(ps-new-faces, ps-extend-face-list, ps-extend-face):
New functions for face remapping.
(ps-override-list, ps-extension-to-bit-face)
(ps-extension-to-screen-face, ps-extension-bit)
(ps-initialize-faces, ps-map-font-lock, ps-screen-to-bit-face):
New internal functions for face remapping.
(ps-get-page-dimensions): Fix error message.
(ps-insert-file): Doc fix and programming enhancement.
(ps-begin-file, ps-end-file, ps-get-buffer-name, ps-begin-page)
(ps-next-line, ps-plot-region, ps-face-attributes)
(ps-face-attribute-list, ps-plot-with-face)
(ps-generate-postscript-with-faces): Handle new output features.
(ps-generate): save-excursion inserted to return back point at
position before calling ps-print.
(ps-do-spool): Access dos-ps-printer variable through symbol-value.
(ps-prsc, ps-c-prsc, ps-s-prsc): Use backquote.
(ps-basic-plot-whitespace, ps-emacs-face-kind-p): Internal blank
line eliminated.
(ps-float-format, ps-current-effect): New internal variables.
(ps-output-list, ps-count-lines, ps-background-pages)
(ps-get-boundingbox, ps-float-format, ps-background-text)
(ps-background-image, ps-background, ps-header-height)
(ps-get-face): New internal functions.
(ps-control-character): Handle control characters.
(ps-gnus-print-article-from-summary): Updated for Gnus 5.
(ps-jack-setup): Replace 'nil by nil, 't by t.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Wed, 20 Aug 1997 23:11:35 +0000 |
parents | 83f275dcd93a |
children | 695cf19ef79e d7ddb3e565de |
rev | line source |
---|---|
2567 | 1 ;;; assoc.el --- insert/delete/sort functions on association lists |
2 | |
14169 | 3 ;; Copyright (C) 1996 Free Software Foundation, Inc. |
4 | |
2567 | 5 ;; Author: Barry A. Warsaw <bwarsaw@cen.com> |
6 ;; Keywords: extensions | |
7 | |
14169 | 8 ;; This file is part of GNU Emacs. |
9 | |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 ;; it under the terms of the GNU General Public License as published by | |
12 ;; the Free Software Foundation; either version 2, or (at your option) | |
13 ;; any later version. | |
2567 | 14 |
14169 | 15 ;; GNU Emacs is distributed in the hope that it will be useful, |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
23 ;; Boston, MA 02111-1307, USA. | |
2567 | 24 |
25 ;;; Commentary: | |
26 | |
27 ;; Association list utilities providing insertion, deletion, sorting | |
28 ;; fetching off key-value pairs in association lists. | |
29 | |
30 ;;; Code: | |
31 | |
4098
0a02227f8417
* assoc.el (asort): First argument should be named alist-symbol,
Jim Blandy <jimb@redhat.com>
parents:
3768
diff
changeset
|
32 (defun asort (alist-symbol key) |
2567 | 33 "Move a specified key-value pair to the head of an alist. |
34 The alist is referenced by ALIST-SYMBOL. Key-value pair to move to | |
35 head is one matching KEY. Returns the sorted list and doesn't affect | |
36 the order of any other key-value pair. Side effect sets alist to new | |
37 sorted list." | |
38 (set alist-symbol | |
39 (sort (copy-alist (eval alist-symbol)) | |
40 (function (lambda (a b) (equal (car a) key)))))) | |
41 | |
42 | |
43 (defun aelement (key value) | |
44 "Makes a list of a cons cell containing car of KEY and cdr of VALUE. | |
45 The returned list is suitable as an element of an alist." | |
46 (list (cons key value))) | |
47 | |
48 | |
49 (defun aheadsym (alist) | |
50 "Return the key symbol at the head of ALIST." | |
51 (car (car alist))) | |
52 | |
53 | |
54 (defun anot-head-p (alist key) | |
55 "Find out if a specified key-value pair is not at the head of an alist. | |
56 The alist to check is specified by ALIST and the key-value pair is the | |
57 one matching the supplied KEY. Returns nil if ALIST is nil, or if | |
58 key-value pair is at the head of the alist. Returns t if key-value | |
59 pair is not at the head of alist. ALIST is not altered." | |
60 (not (equal (aheadsym alist) key))) | |
61 | |
62 | |
63 (defun aput (alist-symbol key &optional value) | |
64 "Inserts a key-value pair into an alist. | |
65 The alist is referenced by ALIST-SYMBOL. The key-value pair is made | |
3768 | 66 from KEY and optionally, VALUE. Returns the altered alist or nil if |
2567 | 67 ALIST is nil. |
68 | |
69 If the key-value pair referenced by KEY can be found in the alist, and | |
70 VALUE is supplied non-nil, then the value of KEY will be set to VALUE. | |
71 If VALUE is not supplied, or is nil, the key-value pair will not be | |
72 modified, but will be moved to the head of the alist. If the key-value | |
73 pair cannot be found in the alist, it will be inserted into the head | |
74 of the alist (with value nil if VALUE is nil or not supplied)." | |
75 (let ((elem (aelement key value)) | |
76 alist) | |
77 (asort alist-symbol key) | |
78 (setq alist (eval alist-symbol)) | |
79 (cond ((null alist) (set alist-symbol elem)) | |
80 ((anot-head-p alist key) (set alist-symbol (nconc elem alist))) | |
81 (value (setcar alist (car elem))) | |
82 (t alist)))) | |
83 | |
84 | |
85 (defun adelete (alist-symbol key) | |
86 "Delete a key-value pair from the alist. | |
87 Alist is referenced by ALIST-SYMBOL and the key-value pair to remove | |
88 is pair matching KEY. Returns the altered alist." | |
89 (asort alist-symbol key) | |
90 (let ((alist (eval alist-symbol))) | |
91 (cond ((null alist) nil) | |
92 ((anot-head-p alist key) alist) | |
93 (t (set alist-symbol (cdr alist)))))) | |
94 | |
95 | |
96 (defun aget (alist key &optional keynil-p) | |
97 "Returns the value in ALIST that is associated with KEY. | |
98 Optional KEYNIL-P describes what to do if the value associated with | |
99 KEY is nil. If KEYNIL-P is not supplied or is nil, and the value is | |
100 nil, then KEY is returned. If KEYNIL-P is non-nil, then nil would be | |
101 returned. | |
102 | |
103 If no key-value pair matching KEY could be found in ALIST, or ALIST is | |
104 nil then nil is returned. ALIST is not altered." | |
105 (let ((copy (copy-alist alist))) | |
106 (cond ((null alist) nil) | |
107 ((progn (asort 'copy key) | |
108 (anot-head-p copy key)) nil) | |
109 ((cdr (car copy))) | |
110 (keynil-p nil) | |
111 ((car (car copy))) | |
112 (t nil)))) | |
113 | |
114 | |
115 (defun amake (alist-symbol keylist &optional valuelist) | |
116 "Make an association list. | |
117 The association list is attached to the alist referenced by | |
118 ALIST-SYMBOL. Each element in the KEYLIST becomes a key and is | |
119 associated with the value in VALUELIST with the same index. If | |
120 VALUELIST is not supplied or is nil, then each key in KEYLIST is | |
121 associated with nil. | |
122 | |
123 KEYLIST and VALUELIST should have the same number of elements, but | |
124 this isn't enforced. If VALUELIST is smaller than KEYLIST, remaining | |
125 keys are associated with nil. If VALUELIST is larger than KEYLIST, | |
126 extra values are ignored. Returns the created alist." | |
127 (let ((keycar (car keylist)) | |
128 (keycdr (cdr keylist)) | |
129 (valcar (car valuelist)) | |
130 (valcdr (cdr valuelist))) | |
131 (cond ((null keycdr) | |
132 (aput alist-symbol keycar valcar)) | |
133 (t | |
134 (amake alist-symbol keycdr valcdr) | |
135 (aput alist-symbol keycar valcar)))) | |
136 (eval alist-symbol)) | |
137 | |
138 (provide 'assoc) | |
139 | |
140 ;;; assoc.el ends here |