Mercurial > emacs
annotate lisp/emacs-lisp/assoc.el @ 104444:2bf481006ba4
lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
lisp/emacs-lisp/autoload.el (generated-autoload-feature): New var.
(autoload-rubric): Use it.
lisp/cedet/semantic/adebug.el (data-debug-insert-find-results-button): Require
db-find.
lisp/cedet/semantic/analyze.el: Require semantic/tag. Don't declare
autoloaded functions.
lisp/cedet/semantic/chart.el: Don't declare autoloaded functions.
lisp/cedet/semantic/complete.el: eval-when-compile semantic/find for macro.
(semantic-collector-calculate-completions-raw): Require semantic/db-find.
lisp/cedet/semantic/ctxt.el (semantic-up-context): Require semantic/find.
Don't require it at top-level.
lisp/cedet/semantic/db-ebrowse.el (semanticdb-ebrowse-dump): Require
data-debug. Don't require it at top-level. Don't require semantic/sort.
lisp/cedet/semantic/db-find.el: Add local vars for autoloading.
Don't require semantic/tag-file and semantic/sort.
(semanticdb-find-default-throttle, semanticdb-find-result-length)
(semanticdb-find-result-nth, semanticdb-find-result-nth-in-buffer)
(semanticdb-find-tags-by-name, semanticdb-find-tags-for-completion)
(semanticdb-find-translate-path, semanticdb-find-table-for-include): Autoload.
lisp/cedet/semantic/db-ref.el: Require semantic and semantic/tag.
(semanticdb-ref-test): Require data-debug. Don't require it at
top-level.
lisp/cedet/semantic/db-typecache.el: Require semantic and semantic/tag.
Declare semantic-sort-tags-by-name-then-type-increasing and
semantic-scope-tag-clone-with-scope.
eval-when-compile semantic/find for semantic-find-tags-by-* macros.
Add local vars for autoloading.
(semanticdb-typecache-find): Autoload.
lisp/cedet/semantic/db.el: Add local vars for autoloading.
(semanticdb-current-database, semanticdb-current-table)
(semanticdb-file-table-object): Autoload.
lisp/cedet/semantic/decorate.el: Don't requirements for autoloaded functions.
lisp/cedet/semantic/doc.el: Add local vars for autoloading.
(semantic-documentation-for-tag): Autoload.
lisp/cedet/semantic/edit.el: Drop requirements for autoloaded functions.
lisp/cedet/semantic/find.el: Add local vars for autoloading.
(semantic-current-tag, semantic-find-tag-by-overlay)
(semantic-find-first-tag-by-name): Autoload.
lisp/cedet/semantic/format.el: Add local vars for autoloading.
(semantic-format-tag-name, semantic-format-tag-custom-list)
(semantic-format-tag-functions): Autoload.
lisp/cedet/semantic/fw.el: Require semantic/loaddefs.
lisp/cedet/semantic/html.el (semantic-html-recursive-combobulate-list):
Use assoc-string instead of assoc-case.
lisp/cedet/semantic/ia.el (semantic-ia-insert-tag): Move up to avoid
compiler error.
(semantic-ia-complete-symbol-menu): Require imenu.
(semantic-ia-fast-jump): Require semantic/decorate/include.
lisp/cedet/semantic/idle.el: Require semantic and semantic/tag.
Declare semanticdb-typecache-refresh-for-buffer and eldoc-message.
eval-when-compile semantic/find for semantic-find-tags-by-name macro.
lisp/cedet/semantic/sort.el: Add local vars for autoloading.
(semantic-flatten-tags-table, semantic-tag-external-member-parent):
Autoload.
lisp/cedet/semantic/tag-file.el: Add local vars for autoloading.
(semantic-go-to-tag, semantic-dependency-tag-file): Autoload.
lisp/cedet/semantic/tag-ls.el: Add local vars for autoloading.
(semantic-tag-prototype-p): Autoload.
lisp/cedet/semantic/tag.el: Don't declare autoloaded functions.
lisp/cedet/semantic/analyze/complete.el: Add local variables for autoloading.
(semantic-analyze-possible-completions): Autoload.
lisp/cedet/semantic/analyze/fcn.el: Require mode-local.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Wed, 02 Sep 2009 04:37:10 +0000 |
parents | a9dc0e7c3f2b |
children | 1d1d5d9bd884 |
rev | line source |
---|---|
2567 | 1 ;;; assoc.el --- insert/delete/sort functions on association lists |
2 | |
74466 | 3 ;; Copyright (C) 1996, 2001, 2002, 2003, 2004, 2005, |
100908 | 4 ;; 2006, 2007, 2008, 2009 Free Software Foundation, Inc. |
14169 | 5 |
2567 | 6 ;; Author: Barry A. Warsaw <bwarsaw@cen.com> |
7 ;; Keywords: extensions | |
8 | |
14169 | 9 ;; This file is part of GNU Emacs. |
10 | |
94655
90a2847062be
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
11 ;; GNU Emacs is free software: you can redistribute it and/or modify |
14169 | 12 ;; it under the terms of the GNU General Public License as published by |
94655
90a2847062be
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
13 ;; the Free Software Foundation, either version 3 of the License, or |
90a2847062be
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
14 ;; (at your option) any later version. |
2567 | 15 |
14169 | 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 | |
94655
90a2847062be
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
2567 | 23 |
24 ;;; Commentary: | |
25 | |
26 ;; Association list utilities providing insertion, deletion, sorting | |
27 ;; fetching off key-value pairs in association lists. | |
28 | |
29 ;;; Code: | |
30 | |
4098
0a02227f8417
* assoc.el (asort): First argument should be named alist-symbol,
Jim Blandy <jimb@redhat.com>
parents:
3768
diff
changeset
|
31 (defun asort (alist-symbol key) |
2567 | 32 "Move a specified key-value pair to the head of an alist. |
99298
225286546090
Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
94655
diff
changeset
|
33 The alist is referenced by ALIST-SYMBOL. Key-value pair to move to |
2567 | 34 head is one matching KEY. Returns the sorted list and doesn't affect |
35 the order of any other key-value pair. Side effect sets alist to new | |
36 sorted list." | |
37 (set alist-symbol | |
38 (sort (copy-alist (eval alist-symbol)) | |
39 (function (lambda (a b) (equal (car a) key)))))) | |
40 | |
41 | |
42 (defun aelement (key value) | |
99298
225286546090
Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
94655
diff
changeset
|
43 "Make a list of a cons cell containing car of KEY and cdr of VALUE. |
2567 | 44 The returned list is suitable as an element of an alist." |
45 (list (cons key value))) | |
46 | |
47 | |
48 (defun aheadsym (alist) | |
49 "Return the key symbol at the head of ALIST." | |
50 (car (car alist))) | |
51 | |
52 | |
53 (defun anot-head-p (alist key) | |
54 "Find out if a specified key-value pair is not at the head of an alist. | |
55 The alist to check is specified by ALIST and the key-value pair is the | |
56 one matching the supplied KEY. Returns nil if ALIST is nil, or if | |
57 key-value pair is at the head of the alist. Returns t if key-value | |
58 pair is not at the head of alist. ALIST is not altered." | |
59 (not (equal (aheadsym alist) key))) | |
60 | |
61 | |
62 (defun aput (alist-symbol key &optional value) | |
63 "Inserts a key-value pair into an alist. | |
99298
225286546090
Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
94655
diff
changeset
|
64 The alist is referenced by ALIST-SYMBOL. The key-value pair is made |
225286546090
Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
94655
diff
changeset
|
65 from KEY and optionally, VALUE. Returns the altered alist or nil if |
2567 | 66 ALIST is nil. |
67 | |
68 If the key-value pair referenced by KEY can be found in the alist, and | |
69 VALUE is supplied non-nil, then the value of KEY will be set to VALUE. | |
70 If VALUE is not supplied, or is nil, the key-value pair will not be | |
99298
225286546090
Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
94655
diff
changeset
|
71 modified, but will be moved to the head of the alist. If the key-value |
2567 | 72 pair cannot be found in the alist, it will be inserted into the head |
73 of the alist (with value nil if VALUE is nil or not supplied)." | |
74 (let ((elem (aelement key value)) | |
75 alist) | |
76 (asort alist-symbol key) | |
77 (setq alist (eval alist-symbol)) | |
78 (cond ((null alist) (set alist-symbol elem)) | |
79 ((anot-head-p alist key) (set alist-symbol (nconc elem alist))) | |
80 (value (setcar alist (car elem))) | |
81 (t alist)))) | |
82 | |
83 | |
84 (defun adelete (alist-symbol key) | |
85 "Delete a key-value pair from the alist. | |
86 Alist is referenced by ALIST-SYMBOL and the key-value pair to remove | |
87 is pair matching KEY. Returns the altered alist." | |
88 (asort alist-symbol key) | |
89 (let ((alist (eval alist-symbol))) | |
90 (cond ((null alist) nil) | |
91 ((anot-head-p alist key) alist) | |
92 (t (set alist-symbol (cdr alist)))))) | |
93 | |
94 | |
95 (defun aget (alist key &optional keynil-p) | |
99298
225286546090
Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
94655
diff
changeset
|
96 "Return the value in ALIST that is associated with KEY. |
2567 | 97 Optional KEYNIL-P describes what to do if the value associated with |
98 KEY is nil. If KEYNIL-P is not supplied or is nil, and the value is | |
99 nil, then KEY is returned. If KEYNIL-P is non-nil, then nil would be | |
100 returned. | |
101 | |
102 If no key-value pair matching KEY could be found in ALIST, or ALIST is | |
99298
225286546090
Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
94655
diff
changeset
|
103 nil then nil is returned. ALIST is not altered." |
2567 | 104 (let ((copy (copy-alist alist))) |
105 (cond ((null alist) nil) | |
106 ((progn (asort 'copy key) | |
107 (anot-head-p copy key)) nil) | |
108 ((cdr (car copy))) | |
109 (keynil-p nil) | |
110 ((car (car copy))) | |
111 (t nil)))) | |
112 | |
113 | |
114 (defun amake (alist-symbol keylist &optional valuelist) | |
115 "Make an association list. | |
116 The association list is attached to the alist referenced by | |
99298
225286546090
Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
94655
diff
changeset
|
117 ALIST-SYMBOL. Each element in the KEYLIST becomes a key and is |
225286546090
Fix typos in docstrings.
Juanma Barranquero <lekktu@gmail.com>
parents:
94655
diff
changeset
|
118 associated with the value in VALUELIST with the same index. If |
2567 | 119 VALUELIST is not supplied or is nil, then each key in KEYLIST is |
120 associated with nil. | |
121 | |
122 KEYLIST and VALUELIST should have the same number of elements, but | |
123 this isn't enforced. If VALUELIST is smaller than KEYLIST, remaining | |
124 keys are associated with nil. If VALUELIST is larger than KEYLIST, | |
125 extra values are ignored. Returns the created alist." | |
126 (let ((keycar (car keylist)) | |
127 (keycdr (cdr keylist)) | |
128 (valcar (car valuelist)) | |
129 (valcdr (cdr valuelist))) | |
130 (cond ((null keycdr) | |
131 (aput alist-symbol keycar valcar)) | |
132 (t | |
133 (amake alist-symbol keycdr valcdr) | |
134 (aput alist-symbol keycar valcar)))) | |
135 (eval alist-symbol)) | |
136 | |
137 (provide 'assoc) | |
138 | |
93975
1e3a407766b9
Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79704
diff
changeset
|
139 ;; arch-tag: 3e58bd89-d912-4b74-a0dc-6ed9735922bc |
2567 | 140 ;;; assoc.el ends here |