[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] scratch/raeburn-startup a0ac557 28/43: Clear out doc strin
From: |
Ken Raeburn |
Subject: |
[Emacs-diffs] scratch/raeburn-startup a0ac557 28/43: Clear out doc strings matching DOC file before dumping. |
Date: |
Mon, 31 Jul 2017 02:11:03 -0400 (EDT) |
branch: scratch/raeburn-startup
commit a0ac557f1b24aef4a47d238a540277a266f09e56
Author: Ken Raeburn <address@hidden>
Commit: Ken Raeburn <address@hidden>
Clear out doc strings matching DOC file before dumping.
Since we have to call Snarf-documentation when reloading the saved
Lisp environment to get the subr doc pointers correct, we should omit
from the saved environment any doc strings that will be re-acquired
via Snarf-documentation anyway.
* src/doc.c (store_function_docstring): Add a new argument which,
if true, causes documentation slots to be set to indicate a zero
offset, which will be replaced next time Snarf-documentation is
called.
(Fsnarf_documentation): Add an optional second argument that says to
clear out as much as possible any documentation that can be found
later with a normal call to Fsnarf_documentation.
(reread_doc_file): Supply nil as the new argument to
Fsnarf_documentation.
* lisp/loadup.el: When preparing to dump the environment, call
Snarf-documentation with the extra argument to clear out the doc
strings that we can reload at startup time.
---
lisp/loadup.el | 2 +-
src/doc.c | 66 +++++++++++++++++++++++++++++++++++++++++++++-------------
2 files changed, 52 insertions(+), 16 deletions(-)
diff --git a/lisp/loadup.el b/lisp/loadup.el
index 69691d1..aeba14a 100644
--- a/lisp/loadup.el
+++ b/lisp/loadup.el
@@ -381,7 +381,7 @@ lost after dumping")))
(message "Finding pointers to doc strings...")
(if (and (fboundp 'dump-emacs)
(equal (last command-line-args) '("dump")))
- (Snarf-documentation "DOC")
+ (Snarf-documentation "DOC" 'clear)
(condition-case nil
(Snarf-documentation "DOC")
(error nil)))
diff --git a/src/doc.c b/src/doc.c
index 345e18b..ae09a31 100644
--- a/src/doc.c
+++ b/src/doc.c
@@ -305,7 +305,7 @@ static bool
reread_doc_file (Lisp_Object file)
{
if (NILP (file))
- Fsnarf_documentation (Vdoc_file_name);
+ Fsnarf_documentation (Vdoc_file_name, Qnil);
else
Fload (file, Qt, Qt, Qt, Qnil);
@@ -466,7 +466,7 @@ aren't strings. */)
/* Scanning the DOC files and placing docstring offsets into functions. */
static void
-store_function_docstring (Lisp_Object obj, EMACS_INT offset)
+store_function_docstring (Lisp_Object obj, EMACS_INT offset, bool clear)
{
/* Don't use indirect_function here, or defaliases will apply their
docstrings to the base functions (Bug#2603). */
@@ -486,10 +486,16 @@ store_function_docstring (Lisp_Object obj, EMACS_INT
offset)
|| (EQ (tem, Qclosure) && (fun = XCDR (fun), 1)))
{
tem = Fcdr (Fcdr (fun));
- if (CONSP (tem) && INTEGERP (XCAR (tem)))
- /* FIXME: This modifies typically pure hash-cons'd data, so its
- correctness is quite delicate. */
- XSETCAR (tem, make_number (offset));
+ if (CONSP (tem))
+ {
+ if (clear && STRINGP (XCAR (tem)))
+ /* Discard any string we may have loaded.
+ Also, 0 is a shorter placeholder in the dumped
+ environment file than the actual offset. */
+ XSETCAR (tem, make_number (0));
+ else if (INTEGERP (XCAR (tem)))
+ XSETCAR (tem, make_number (offset));
+ }
}
}
@@ -503,7 +509,7 @@ store_function_docstring (Lisp_Object obj, EMACS_INT offset)
/* This bytecode object must have a slot for the
docstring, since we've found a docstring for it. */
if (PVSIZE (fun) > COMPILED_DOC_STRING)
- ASET (fun, COMPILED_DOC_STRING, make_number (offset));
+ ASET (fun, COMPILED_DOC_STRING, make_number (clear ? 0 : offset));
else
{
AUTO_STRING (format, "No docstring slot for %s");
@@ -517,15 +523,22 @@ store_function_docstring (Lisp_Object obj, EMACS_INT
offset)
DEFUN ("Snarf-documentation", Fsnarf_documentation, Ssnarf_documentation,
- 1, 1, 0,
+ 1, 2, 0,
doc: /* Used during Emacs initialization to scan the `etc/DOC...' file.
This searches the `etc/DOC...' file for doc strings and
records them in function and variable definitions.
-The function takes one argument, FILENAME, a string;
+The function takes one required argument, FILENAME, a string;
it specifies the file name (without a directory) of the DOC file.
That file is found in `../etc' now; later, when the dumped Emacs is run,
-the same file name is found in the `doc-directory'. */)
- (Lisp_Object filename)
+the same file name is found in the `doc-directory'.
+
+Optional second argument CLEAR, if set, causes the removal of
+variable-documentation properties and the replacement of function doc
+strings with dummy DOC file offsets when the documentation is found in
+the DOC file, to minimize storage use in preparation for dumping the
+Lisp environment state, with the expectation that Snarf-documentation
+will be called again after loading the dumped environment. */)
+ (Lisp_Object filename, Lisp_Object clear)
{
int fd;
char buf[1024 + 1];
@@ -644,16 +657,39 @@ the same file name is found in the `doc-directory'. */)
(doc starts with a `*'). */
if (!NILP (Fboundp (sym))
|| !NILP (Fmemq (sym, delayed_init)))
- Fput (sym, Qvariable_documentation,
- make_number ((pos + end + 1 - buf)
- * (end[1] == '*' ? -1 : 1)));
+ {
+ if (NILP (clear))
+ Fput (sym, Qvariable_documentation,
+ make_number ((pos + end + 1 - buf)
+ * (end[1] == '*' ? -1 : 1)));
+ else
+ /* Remove the variable-documentation property,
+ if present, even if it's nil (which makes
+ Fget unhelpful). */
+ {
+ Lisp_Object plist = Fsymbol_plist (sym);
+ Lisp_Object prev, prop;
+ if (EQ (Fcar (plist), Qvariable_documentation))
+ set_symbol_plist (sym, Fcdr (Fcdr (plist)));
+ else
+ for (prev = Fcdr (plist), prop = Fcdr (prev);
+ !NILP (prop);
+ prev = Fcdr (prop), prop = Fcdr (prev))
+ if (EQ (Fcar (prop), Qvariable_documentation))
+ {
+ Fsetcdr (prev, Fcdr (Fcdr (prop)));
+ break;
+ }
+ }
+ }
}
/* Attach a docstring to a function? */
else if (p[1] == 'F')
{
if (!NILP (Ffboundp (sym)))
- store_function_docstring (sym, pos + end + 1 - buf);
+ store_function_docstring (sym, pos + end + 1 - buf,
+ !NILP (clear));
}
else if (p[1] == 'S')
; /* Just a source file name boundary marker. Ignore it. */
- [Emacs-diffs] scratch/raeburn-startup 3da90ae 32/43: Make watchers dumpable., (continued)
- [Emacs-diffs] scratch/raeburn-startup 3da90ae 32/43: Make watchers dumpable., Ken Raeburn, 2017/07/31
- [Emacs-diffs] scratch/raeburn-startup 363abae 30/43: Support dumping variable aliases., Ken Raeburn, 2017/07/31
- [Emacs-diffs] scratch/raeburn-startup 291e585 24/43: Update load-path and purify-flag even if not bootstrapping., Ken Raeburn, 2017/07/31
- [Emacs-diffs] scratch/raeburn-startup 2c96099 27/43: Don't dump artifacts of the dump process., Ken Raeburn, 2017/07/31
- [Emacs-diffs] scratch/raeburn-startup bd8bcb3 29/43: Load uniquify after dump/reload., Ken Raeburn, 2017/07/31
- [Emacs-diffs] scratch/raeburn-startup d987a68 39/43: Don't show the build directory in load-history., Ken Raeburn, 2017/07/31
- [Emacs-diffs] scratch/raeburn-startup de45051 37/43: Fix use of "-l" on command line after installation., Ken Raeburn, 2017/07/31
- [Emacs-diffs] scratch/raeburn-startup 272c874 23/43: Fix startup on MS-Windows, Ken Raeburn, 2017/07/31
- [Emacs-diffs] scratch/raeburn-startup d95042a 35/43: ; Add comment regarding silent loading of dumped.elc., Ken Raeburn, 2017/07/31
- [Emacs-diffs] scratch/raeburn-startup 5d4b7f9 26/43: Dump and restore empty abbrev tables., Ken Raeburn, 2017/07/31
- [Emacs-diffs] scratch/raeburn-startup a0ac557 28/43: Clear out doc strings matching DOC file before dumping.,
Ken Raeburn <=
- [Emacs-diffs] scratch/raeburn-startup 7764bd73 36/43: * lisp/loadup.el: Load uniquify quietly. Put fewer newlines in dump file., Ken Raeburn, 2017/07/31
- [Emacs-diffs] scratch/raeburn-startup 6faa843 20/43: Load documentation at startup., Ken Raeburn, 2017/07/31
- [Emacs-diffs] scratch/raeburn-startup 43dcdd3 25/43: Load cl-macs, needed for cl-labels., Ken Raeburn, 2017/07/31
- [Emacs-diffs] scratch/raeburn-startup 761346d 34/43: Use CANNOT_DUMP mode., Ken Raeburn, 2017/07/31
- [Emacs-diffs] scratch/raeburn-startup dbdfea8 33/43: Don't check for dump-emacs being bound., Ken Raeburn, 2017/07/31
- [Emacs-diffs] scratch/raeburn-startup 6794f2e 40/43: Make more preloaded files visible to make-docfile., Ken Raeburn, 2017/07/31
- [Emacs-diffs] scratch/raeburn-startup cd0966b 42/43: ; admin/notes/big-elc: Notes on this experimental branch., Ken Raeburn, 2017/07/31
- [Emacs-diffs] scratch/raeburn-startup 13f3370 43/43: ; Merge from branch 'master', Ken Raeburn, 2017/07/31