Browse code
Update README
Ed Langley authored on 10/03/2019 21:09:03
Showing 1 changed files
Showing 1 changed files
... | ... |
@@ -4,7 +4,9 @@ fiddlerwoaroof's note: I took this code from |
4 | 4 |
http://lemonodor.com/archives/001232.html and cleaned it up to work |
5 | 5 |
with modern OS X/macOS: I removed AGRegex and just use |
6 | 6 |
NSRegularExpression and made other minor tweaks to get it to build and |
7 |
-run on High Sierrra |
|
7 |
+run on High Sierrra. |
|
8 |
+ |
|
9 |
+* Lemonodor's README (extracted from README.pdf, typos mine :) ): |
|
8 | 10 |
|
9 | 11 |
This importer plugin indexes files with .lisp, .lsp and .cl extensions |
10 | 12 |
using the Spotlight search engine that was introduced by Apple in OS X |
... | ... |
@@ -19,159 +21,159 @@ system already thinks they’re text files. The Lisp importer also does |
19 | 21 |
some Lisp-specific indexing that you might find more useful than the |
20 | 22 |
default text indexing. |
21 | 23 |
|
22 |
-* How do I install it? |
|
23 |
- |
|
24 |
-Copy the Lisp Metadata Importer.mdimporter file into the |
|
25 |
-/Library/Spotlight folder. |
|
26 |
- |
|
27 |
-* How do I uninstall it? |
|
28 |
- |
|
29 |
-Remove the Lisp Metadata Importer.mdimporter file from the |
|
30 |
-/Library/Spotlight folder. |
|
31 |
- |
|
32 |
-* How do I test it once it is installed? |
|
33 |
- |
|
34 |
-Try indexing a single Lisp file using the mdimport command. When you |
|
35 |
-run mdimport with the –d1 flag it will tell you which plugin it’s |
|
36 |
-using, if any, to index the file. You should see a reference to the |
|
37 |
-Lisp Metadata Importer.mdimporter file. Once you’ve run mdimport, use |
|
38 |
-the mdls command to look at the metadata associated with the file. The |
|
39 |
-important things to look for are that the kMDItemContentType is |
|
40 |
-“com.lemonodor.lisp-source”, and that there are some attributes with |
|
41 |
-names that begin with “org_lisp”, like “org_lisp_defmacros” or |
|
42 |
-“org_lisp_defuns”. |
|
43 |
- |
|
44 |
-#+BEGIN_SRC sh |
|
45 |
- lem:~ $ mdimport -d1 variables.lisp |
|
46 |
- 2005-09-15 12:05:55.493 mdimport[6962] Import '/Users/wiseman/variables.lisp' type |
|
47 |
- 'com.lemonodor.lisp-source' using |
|
48 |
- 'file://localhost/Library/Spotlight/Lisp%20Metadata%20Importer.mdimporter/' |
|
49 |
- lem:~ $ mdls variables.lisp |
|
50 |
- variables.lisp ------------- |
|
51 |
- kMDItemAttributeChangeDate = 2005-09-08 11:30:18 -0700 |
|
52 |
- kMDItemContentCreationDate = 2005-09-02 17:41:07 -0700 |
|
53 |
- kMDItemContentModificationDate = 2005-09-02 17:41:08 -0700 |
|
54 |
- kMDItemContentType = "com.lemonodor.lisp-source" |
|
55 |
- kMDItemContentTypeTree = ( |
|
56 |
- "com.lemonodor.lisp-source", |
|
57 |
- "public.source-code", |
|
58 |
- "public.plain-text", |
|
59 |
- "public.text", |
|
60 |
- "public.data", |
|
61 |
- "public.item", |
|
62 |
- "public.content" |
|
63 |
- ) |
|
64 |
- kMDItemDisplayName = "variables.lisp" |
|
65 |
- # and on and on, until finally... |
|
66 |
- org_lisp_defclasses |
|
67 |
- org_lisp_defgenerics |
|
68 |
- org_lisp_definitions |
|
69 |
- foo, |
|
70 |
- "(setf foo)", |
|
71 |
- "oh-noe", |
|
72 |
- "*oh-no*", |
|
73 |
- "*hee-ho*", |
|
74 |
- "+thing+", |
|
75 |
- "i-dont-think-so", |
|
76 |
- "BRAIN-CELL", |
|
77 |
- "(RAT-BRAIN-CELL", |
|
78 |
- attack, |
|
79 |
- attack, |
|
80 |
- "(setf mood)", |
|
81 |
- "(setf mood)" |
|
82 |
- ) |
|
83 |
- org_lisp_defmacros |
|
84 |
- org_lisp_defmethods |
|
85 |
- org_lisp_defstructs |
|
86 |
- org_lisp_defuns |
|
87 |
- org_lisp_defvars |
|
88 |
- = ("i-dont-think-so") |
|
89 |
- = (attack, "(setf mood)", "(setf mood)") |
|
90 |
- = ( |
|
91 |
- = ("oh-noe") |
|
92 |
- = (attack, "(setf mood)") |
|
93 |
- = ("BRAIN-CELL", "RAT-BRAIN-CELL") |
|
94 |
- = (foo, "(setf foo)") |
|
95 |
- = ("*oh-no*", "*hee-ho*", "+thing+") |
|
96 |
-#+END_SRC |
|
97 |
- |
|
98 |
-If you see those attributes then the importer is working correctly. |
|
99 |
-If the importer doesn’t seem to be working and you’ve double checked |
|
100 |
-to make sure you copied it to the correct folder, try the mdimport –r |
|
101 |
-trick in the next question & answer; it’s the equivalent of kicking a |
|
102 |
-malfunctioning jukebox. |
|
103 |
- |
|
104 |
-* How do I index all my Lisp files? |
|
105 |
- |
|
106 |
-Use mdimport again, this time with the –r flag, and passing it the |
|
107 |
-path to the Lisp plugin. |
|
108 |
- |
|
109 |
-#+BEGIN_SRC sh |
|
110 |
- lem:~ $ mdimport -r /Library/Spotlight/Lisp\ Metadata\ Importer.mdimporter/ |
|
111 |
- 2005-09-15 12:41:38.650 mdimport[7169] Asking server to reimport files with UTIs: ( |
|
112 |
- "dyn.ah62d4rv4ge8024pxsa", |
|
113 |
- "com.lemonodor.lisp-source", |
|
114 |
- "dyn.ah62d4rv4gq81k3p2su11uppqrf31appxr741e25f", |
|
115 |
- "dyn.ah62d4rv4ge80265u", |
|
116 |
- "dyn.ah62d4rv4ge80g5a" |
|
117 |
- ) |
|
118 |
-#+END_SRC |
|
119 |
- |
|
120 |
-* What exactly is being indexed? |
|
121 |
-The Lisp metadata importer indexes the definitions contained in a |
|
122 |
-file. This includes functions, macros, classes, methods, generic |
|
123 |
-functions, structures, defvars, defparameters and defconstants. It |
|
124 |
-also includes any object FOO defined by a form that looks like |
|
125 |
-(“defsomething FOO ...)”. In addition to definitions, the entire |
|
126 |
-contents of the file are indexed for full text queries. |
|
127 |
- |
|
128 |
-* How do I search for something? |
|
129 |
-The GUI way is to hit Command-F in the finder to bring up a Find |
|
130 |
-window. Click on one one of the attributes and select “Other...”. to |
|
131 |
-see a list of other attributes: Choose one of the Lisp importer’s |
|
132 |
-attributes from the list that comes up (you can type “lisp” into the |
|
133 |
-search field on the upper right to filter out the non-Lisp |
|
134 |
-attributes): |
|
135 |
-Now enter the text you’d like to search for and watch the matching |
|
136 |
-files appear: |
|
137 |
-Some people have reported that the Lisp-specific attributes weren’t |
|
138 |
-available in the Find dialog until they re-launched the Finder (to |
|
139 |
-re-launch the finder, hit Command-Option-Esc and then select the |
|
140 |
-Finder in the “Force Quit Applications” dialog that pops up). The |
|
141 |
-non-GUI way to do Spotlight searches is to use the mdfind command. I |
|
142 |
-did this the other day when someone on IRC asked how to do |
|
143 |
-search-and-replace on a string. I knew I had written a function to do |
|
144 |
-that, but I couldn’t remember which project the code was in. (It |
|
145 |
-turned out I had a couple implementations lying around.) |
|
146 |
-The Spotlight query language used by mdfind is documented online by |
|
147 |
-Apple. |
|
148 |
- |
|
149 |
-* What are the attributes I can search on and where do they come from in the Lisp file? |
|
150 |
- |
|
151 |
-The following metadata attributes are defined by the Lisp Metadata Importer: |
|
152 |
- |
|
153 |
- | Metadata Attribute | Defining Forms | |
|
154 |
- |----------------------+-----------------------------------------| |
|
155 |
- | org_lisp_defuns | defun | |
|
156 |
- | org_lisp_defmacros | defmacro | |
|
157 |
- | org_lisp_defclasses | defclass | |
|
158 |
- | org_lisp_defgeneric | defgeneric | |
|
159 |
- | org_lisp_defmethod | defmethod | |
|
160 |
- | org_lisp_defstructs | defstruct | |
|
161 |
- | org_lisp_defvars | defvar, defparameter, defconstant | |
|
162 |
- | org_lisp_definitions | Anything defined with a “(def...” form. | |
|
163 |
- |----------------------+-----------------------------------------| |
|
164 |
- |
|
165 |
-In addition, the importer sets the kMDItemTextContent attribute to be |
|
166 |
-the entire contents of the file, so you can do full text searches. |
|
167 |
- |
|
168 |
-* What shortcuts did you take? |
|
169 |
- |
|
170 |
-Here are a few I can think of: |
|
171 |
-- The importer only indexes definition forms that are at the beginning of a line. |
|
172 |
-- It has a very simple, limited concept of symbol names and Lisp reader syntax, so it can easily become confused. |
|
173 |
-- I shouldn’t really use the org_lisp prefix for attribute names. |
|
174 |
-- I should try to coordinate with the people writing plugins for Ruby, Python and other languages so we can come up with a common set of source code metadata attributes. |
|
175 |
- |
|
176 |
-* Who should you thank? |
|
177 |
-Justin Wight, Pierre Mai, Ralph Richard Cook and Bryan O’Connor all helped me to some extent. Thanks, guys! |
|
24 |
+** How do I install it? |
|
25 |
+ |
|
26 |
+ Copy the Lisp Metadata Importer.mdimporter file into the |
|
27 |
+ /Library/Spotlight folder. |
|
28 |
+ |
|
29 |
+** How do I uninstall it? |
|
30 |
+ |
|
31 |
+ Remove the Lisp Metadata Importer.mdimporter file from the |
|
32 |
+ /Library/Spotlight folder. |
|
33 |
+ |
|
34 |
+** How do I test it once it is installed? |
|
35 |
+ |
|
36 |
+ Try indexing a single Lisp file using the mdimport command. When you |
|
37 |
+ run mdimport with the –d1 flag it will tell you which plugin it’s |
|
38 |
+ using, if any, to index the file. You should see a reference to the |
|
39 |
+ Lisp Metadata Importer.mdimporter file. Once you’ve run mdimport, use |
|
40 |
+ the mdls command to look at the metadata associated with the file. The |
|
41 |
+ important things to look for are that the kMDItemContentType is |
|
42 |
+ “com.lemonodor.lisp-source”, and that there are some attributes with |
|
43 |
+ names that begin with “org_lisp”, like “org_lisp_defmacros” or |
|
44 |
+ “org_lisp_defuns”. |
|
45 |
+ |
|
46 |
+ #+BEGIN_SRC sh |
|
47 |
+ lem:~ $ mdimport -d1 variables.lisp |
|
48 |
+ 2005-09-15 12:05:55.493 mdimport[6962] Import '/Users/wiseman/variables.lisp' type |
|
49 |
+ 'com.lemonodor.lisp-source' using |
|
50 |
+ 'file://localhost/Library/Spotlight/Lisp%20Metadata%20Importer.mdimporter/' |
|
51 |
+ lem:~ $ mdls variables.lisp |
|
52 |
+ variables.lisp ------------- |
|
53 |
+ kMDItemAttributeChangeDate = 2005-09-08 11:30:18 -0700 |
|
54 |
+ kMDItemContentCreationDate = 2005-09-02 17:41:07 -0700 |
|
55 |
+ kMDItemContentModificationDate = 2005-09-02 17:41:08 -0700 |
|
56 |
+ kMDItemContentType = "com.lemonodor.lisp-source" |
|
57 |
+ kMDItemContentTypeTree = ( |
|
58 |
+ "com.lemonodor.lisp-source", |
|
59 |
+ "public.source-code", |
|
60 |
+ "public.plain-text", |
|
61 |
+ "public.text", |
|
62 |
+ "public.data", |
|
63 |
+ "public.item", |
|
64 |
+ "public.content" |
|
65 |
+ ) |
|
66 |
+ kMDItemDisplayName = "variables.lisp" |
|
67 |
+ # and on and on, until finally... |
|
68 |
+ org_lisp_defclasses |
|
69 |
+ org_lisp_defgenerics |
|
70 |
+ org_lisp_definitions |
|
71 |
+ foo, |
|
72 |
+ "(setf foo)", |
|
73 |
+ "oh-noe", |
|
74 |
+ "*oh-no*", |
|
75 |
+ "*hee-ho*", |
|
76 |
+ "+thing+", |
|
77 |
+ "i-dont-think-so", |
|
78 |
+ "BRAIN-CELL", |
|
79 |
+ "(RAT-BRAIN-CELL", |
|
80 |
+ attack, |
|
81 |
+ attack, |
|
82 |
+ "(setf mood)", |
|
83 |
+ "(setf mood)" |
|
84 |
+ ) |
|
85 |
+ org_lisp_defmacros |
|
86 |
+ org_lisp_defmethods |
|
87 |
+ org_lisp_defstructs |
|
88 |
+ org_lisp_defuns |
|
89 |
+ org_lisp_defvars |
|
90 |
+ = ("i-dont-think-so") |
|
91 |
+ = (attack, "(setf mood)", "(setf mood)") |
|
92 |
+ = ( |
|
93 |
+ = ("oh-noe") |
|
94 |
+ = (attack, "(setf mood)") |
|
95 |
+ = ("BRAIN-CELL", "RAT-BRAIN-CELL") |
|
96 |
+ = (foo, "(setf foo)") |
|
97 |
+ = ("*oh-no*", "*hee-ho*", "+thing+") |
|
98 |
+ #+END_SRC |
|
99 |
+ |
|
100 |
+ If you see those attributes then the importer is working correctly. |
|
101 |
+ If the importer doesn’t seem to be working and you’ve double checked |
|
102 |
+ to make sure you copied it to the correct folder, try the mdimport –r |
|
103 |
+ trick in the next question & answer; it’s the equivalent of kicking a |
|
104 |
+ malfunctioning jukebox. |
|
105 |
+ |
|
106 |
+** How do I index all my Lisp files? |
|
107 |
+ |
|
108 |
+ Use mdimport again, this time with the –r flag, and passing it the |
|
109 |
+ path to the Lisp plugin. |
|
110 |
+ |
|
111 |
+ #+BEGIN_SRC sh |
|
112 |
+ lem:~ $ mdimport -r /Library/Spotlight/Lisp\ Metadata\ Importer.mdimporter/ |
|
113 |
+ 2005-09-15 12:41:38.650 mdimport[7169] Asking server to reimport files with UTIs: ( |
|
114 |
+ "dyn.ah62d4rv4ge8024pxsa", |
|
115 |
+ "com.lemonodor.lisp-source", |
|
116 |
+ "dyn.ah62d4rv4gq81k3p2su11uppqrf31appxr741e25f", |
|
117 |
+ "dyn.ah62d4rv4ge80265u", |
|
118 |
+ "dyn.ah62d4rv4ge80g5a" |
|
119 |
+ ) |
|
120 |
+ #+END_SRC |
|
121 |
+ |
|
122 |
+** What exactly is being indexed? |
|
123 |
+ The Lisp metadata importer indexes the definitions contained in a |
|
124 |
+ file. This includes functions, macros, classes, methods, generic |
|
125 |
+ functions, structures, defvars, defparameters and defconstants. It |
|
126 |
+ also includes any object FOO defined by a form that looks like |
|
127 |
+ (“defsomething FOO ...)”. In addition to definitions, the entire |
|
128 |
+ contents of the file are indexed for full text queries. |
|
129 |
+ |
|
130 |
+** How do I search for something? |
|
131 |
+ The GUI way is to hit Command-F in the finder to bring up a Find |
|
132 |
+ window. Click on one one of the attributes and select “Other...”. to |
|
133 |
+ see a list of other attributes: Choose one of the Lisp importer’s |
|
134 |
+ attributes from the list that comes up (you can type “lisp” into the |
|
135 |
+ search field on the upper right to filter out the non-Lisp |
|
136 |
+ attributes): |
|
137 |
+ Now enter the text you’d like to search for and watch the matching |
|
138 |
+ files appear: |
|
139 |
+ Some people have reported that the Lisp-specific attributes weren’t |
|
140 |
+ available in the Find dialog until they re-launched the Finder (to |
|
141 |
+ re-launch the finder, hit Command-Option-Esc and then select the |
|
142 |
+ Finder in the “Force Quit Applications” dialog that pops up). The |
|
143 |
+ non-GUI way to do Spotlight searches is to use the mdfind command. I |
|
144 |
+ did this the other day when someone on IRC asked how to do |
|
145 |
+ search-and-replace on a string. I knew I had written a function to do |
|
146 |
+ that, but I couldn’t remember which project the code was in. (It |
|
147 |
+ turned out I had a couple implementations lying around.) |
|
148 |
+ The Spotlight query language used by mdfind is documented online by |
|
149 |
+ Apple. |
|
150 |
+ |
|
151 |
+** What are the attributes I can search on and where do they come from in the Lisp file? |
|
152 |
+ |
|
153 |
+ The following metadata attributes are defined by the Lisp Metadata Importer: |
|
154 |
+ |
|
155 |
+ | Metadata Attribute | Defining Forms | |
|
156 |
+ |----------------------+-----------------------------------------| |
|
157 |
+ | org_lisp_defuns | defun | |
|
158 |
+ | org_lisp_defmacros | defmacro | |
|
159 |
+ | org_lisp_defclasses | defclass | |
|
160 |
+ | org_lisp_defgeneric | defgeneric | |
|
161 |
+ | org_lisp_defmethod | defmethod | |
|
162 |
+ | org_lisp_defstructs | defstruct | |
|
163 |
+ | org_lisp_defvars | defvar, defparameter, defconstant | |
|
164 |
+ | org_lisp_definitions | Anything defined with a “(def...” form. | |
|
165 |
+ |----------------------+-----------------------------------------| |
|
166 |
+ |
|
167 |
+ In addition, the importer sets the kMDItemTextContent attribute to be |
|
168 |
+ the entire contents of the file, so you can do full text searches. |
|
169 |
+ |
|
170 |
+** What shortcuts did you take? |
|
171 |
+ |
|
172 |
+ Here are a few I can think of: |
|
173 |
+ - The importer only indexes definition forms that are at the beginning of a line. |
|
174 |
+ - It has a very simple, limited concept of symbol names and Lisp reader syntax, so it can easily become confused. |
|
175 |
+ - I shouldn’t really use the org_lisp prefix for attribute names. |
|
176 |
+ - I should try to coordinate with the people writing plugins for Ruby, Python and other languages so we can come up with a common set of source code metadata attributes. |
|
177 |
+ |
|
178 |
+** Who should you thank? |
|
179 |
+ Justin Wight, Pierre Mai, Ralph Richard Cook and Bryan O’Connor all helped me to some extent. Thanks, guys! |