Mercurial > emacs
comparison src/doc.c @ 1651:ef09501a0a9b
* doc.c (store_function_docstring): New function, made from part
of Fsnarf_documentation, which handles docstrings for macros
properly.
(Fsnarf_documentation): Call store_function_docstring.
author | Jim Blandy <jimb@redhat.com> |
---|---|
date | Sun, 06 Dec 1992 22:16:26 +0000 |
parents | ff88f962a982 |
children | b6c62e4abf59 |
comparison
equal
deleted
inserted
replaced
1650:60a49bc9673a | 1651:ef09501a0a9b |
---|---|
200 if (NILP (raw) && XTYPE (tem) == Lisp_String) | 200 if (NILP (raw) && XTYPE (tem) == Lisp_String) |
201 return Fsubstitute_command_keys (tem); | 201 return Fsubstitute_command_keys (tem); |
202 return tem; | 202 return tem; |
203 } | 203 } |
204 | 204 |
205 /* Scanning the DOC files and placing docstring offsets into functions. */ | |
206 | |
207 static void | |
208 store_function_docstring (fun, offset) | |
209 Lisp_Object fun; | |
210 int offset; | |
211 { | |
212 fun = indirect_function (fun); | |
213 | |
214 /* The type determines where the docstring is stored. */ | |
215 | |
216 /* Lisp_Subrs have a slot for it. */ | |
217 if (XTYPE (fun) == Lisp_Subr) | |
218 XSUBR (fun)->doc = (char *) - offset; | |
219 | |
220 /* If it's a lisp form, stick it in the form. */ | |
221 else if (CONSP (fun)) | |
222 { | |
223 Lisp_Object tem; | |
224 | |
225 tem = XCONS (fun)->car; | |
226 if (EQ (tem, Qlambda) || EQ (tem, Qautoload)) | |
227 { | |
228 tem = Fcdr (Fcdr (fun)); | |
229 if (CONSP (tem) && | |
230 XTYPE (XCONS (tem)->car) == Lisp_Int) | |
231 XFASTINT (XCONS (tem)->car) = offset; | |
232 } | |
233 else if (EQ (tem, Qmacro)) | |
234 store_function_docstring (XCONS (fun)->cdr, offset); | |
235 } | |
236 | |
237 /* Bytecode objects sometimes have slots for it. */ | |
238 else if (XTYPE (fun) == Lisp_Compiled) | |
239 { | |
240 /* This bytecode object must have a slot for the | |
241 docstring, since we've found a docstring for it. */ | |
242 if (XVECTOR (fun)->size <= COMPILED_DOC_STRING) | |
243 abort (); | |
244 | |
245 XFASTINT (XVECTOR (fun)->contents[COMPILED_DOC_STRING]) = offset; | |
246 } | |
247 } | |
248 | |
249 | |
205 DEFUN ("Snarf-documentation", Fsnarf_documentation, Ssnarf_documentation, | 250 DEFUN ("Snarf-documentation", Fsnarf_documentation, Ssnarf_documentation, |
206 1, 1, 0, | 251 1, 1, 0, |
207 "Used during Emacs initialization, before dumping runnable Emacs,\n\ | 252 "Used during Emacs initialization, before dumping runnable Emacs,\n\ |
208 to find pointers to doc strings stored in `etc/DOC...' and\n\ | 253 to find pointers to doc strings stored in `etc/DOC...' and\n\ |
209 record them in function definitions.\n\ | 254 record them in function definitions.\n\ |
290 Fput (sym, Qvariable_documentation, | 335 Fput (sym, Qvariable_documentation, |
291 make_number ((pos + end + 1 - buf) | 336 make_number ((pos + end + 1 - buf) |
292 * (end[1] == '*' ? -1 : 1))); | 337 * (end[1] == '*' ? -1 : 1))); |
293 } | 338 } |
294 | 339 |
295 /* Attach a docstring to a function? The type determines where | 340 /* Attach a docstring to a function? */ |
296 the docstring is stored. */ | |
297 else if (p[1] == 'F') | 341 else if (p[1] == 'F') |
298 { | 342 store_function_docstring (sym, pos + end + 1 - buf); |
299 fun = XSYMBOL (sym)->function; | 343 |
300 | 344 else |
301 /* Lisp_Subrs have a slot for it. */ | 345 error ("DOC file invalid at position %d", pos); |
302 if (XTYPE (fun) == Lisp_Subr) | |
303 XSUBR (fun)->doc = (char *) - (pos + end + 1 - buf); | |
304 | |
305 /* If it's a lisp form, stick it in the form. */ | |
306 else if (CONSP (fun)) | |
307 { | |
308 tem = XCONS (fun)->car; | |
309 if (EQ (tem, Qlambda) || EQ (tem, Qautoload)) | |
310 { | |
311 tem = Fcdr (Fcdr (fun)); | |
312 if (CONSP (tem) && | |
313 XTYPE (XCONS (tem)->car) == Lisp_Int) | |
314 XFASTINT (XCONS (tem)->car) = (pos + end + 1 - buf); | |
315 } | |
316 } | |
317 | |
318 /* Bytecode objects sometimes have slots for it. */ | |
319 else if (XTYPE (fun) == Lisp_Compiled) | |
320 { | |
321 /* This bytecode object must have a slot for the | |
322 docstring, since we've found a docstring for it. */ | |
323 if (XVECTOR (fun)->size <= COMPILED_DOC_STRING) | |
324 abort (); | |
325 | |
326 XFASTINT (XVECTOR (fun)->contents[COMPILED_DOC_STRING]) | |
327 = pos + end + 1 - buf; | |
328 } | |
329 } | |
330 else error ("DOC file invalid at position %d", pos); | |
331 } | 346 } |
332 } | 347 } |
333 pos += end - buf; | 348 pos += end - buf; |
334 filled -= end - buf; | 349 filled -= end - buf; |
335 bcopy (end, buf, filled); | 350 bcopy (end, buf, filled); |