adjust README
[arxana.git] / latex / sbdm4cbpp.tex
blob5e59302ce52a205b49732e237de5a5c77b49615e
1 %%% sbdm4cbpp.tex -- An advanced hypertext system for Emacs
3 %% Copyright (C) 2005 Joe Corneli <jcorneli@planetmath.org>
5 %% Time-stamp: <2006-06-08 14:29:13 jcorneli>
7 %% This program is free software: you can redistribute it and/or modify
8 %% it under the terms of the GNU Affero General Public License as published by
9 %% the Free Software Foundation, either version 3 of the License, or
10 %% (at your option) any later version.
12 %% This program is distributed in the hope that it will be useful,
13 %% but WITHOUT ANY WARRANTY; without even the implied warranty of
14 %% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 %% GNU Affero General Public License for more details.
17 %% You should have received a copy of the GNU Affero General Public License
18 %% along with this program. If not, see <http://www.gnu.org/licenses/>.
20 %%% Commentary:
22 %%% Code:
24 \documentclass[12pt]{article}
26 \usepackage{beton}
27 \usepackage{concmath}
28 \usepackage{graphicx}
29 %\usepackage{hyperref}
30 \usepackage{makeidx}
31 \makeindex
33 %% Reformatting the index to be single column
35 \makeatletter
36 \renewcommand{\theindex}{
37 \@restonecoltrue\if@twocolumn\@restonecolfalse\fi
38 \clearpage
39 \section*{Index of Functions}
40 \parindent\z@
41 \parskip\z@ plus .3pt\relax\let\item\@idxitem
42 \addcontentsline{toc}{section}{\numberline {}Index of Functions}
44 \makeatother
46 %% Run this code to put all of the function definitions into the
47 %% index. (I'm not sure yet how to build an index of terms as well as
48 %% an index of functions.)
50 %% (while (re-search-forward "\\\\begin{lisp}\n(defun \\([^ ]+\\)")
51 %% (goto-char (match-beginning 0))
52 %% (insert (concat "\\index{" (match-string 1) "}\n"))
53 %% (search-forward "end{lisp}"))
55 % Use ``makeindex sbdm4cbpp'' to build the index & run latex multiple
56 % times to get everything settled.
58 \usepackage{url}
59 \usepackage{graphicx}
60 \usepackage[round,authoryear,sort&compress]{natbib}
61 \bibliographystyle{plainnat}
63 %% Does this mess up the ``works on a wholly free software system''
64 %% property?
65 %%% \usepackage{simplemargins}
66 %% copying the below from simplemargins.sty, hopefully under fair use:
67 %% (this will save users from a dependency, whether free or non-free)
68 \newlength{\smpagewidth}
69 \newlength{\smpageheight}
71 \setlength{\smpagewidth}{8.5in}
72 \setlength{\smpageheight}{11in}
74 \addtolength{\textwidth}{\oddsidemargin}
75 \addtolength{\textwidth}{1in}
76 \addtolength{\textwidth}{-1in}
77 \setlength{\oddsidemargin}{-1in}
78 \addtolength{\oddsidemargin}{1in}
79 \setlength{\evensidemargin}{\oddsidemargin}
81 \setlength{\textwidth}{\smpagewidth}
82 \addtolength{\textwidth}{-\oddsidemargin}
83 \addtolength{\textwidth}{-1in}
84 \addtolength{\textwidth}{-1in}
86 \addtolength{\textheight}{\topmargin}
87 \addtolength{\textheight}{1in}
88 \addtolength{\textheight}{\headheight}
89 \addtolength{\textheight}{\headsep}
90 \addtolength{\textheight}{-1.5in}
91 \setlength{\topmargin}{-1in}
92 \addtolength{\topmargin}{-\headheight}
93 \addtolength{\topmargin}{-\headsep}
94 \addtolength{\topmargin}{1.5in}
96 \setlength{\textheight}{\smpageheight}
97 \addtolength{\textheight}{-\topmargin}
98 \addtolength{\textheight}{-1in}
99 \addtolength{\textheight}{-\footskip}
100 \addtolength{\textheight}{-.5in}
101 %% end copied portion.
103 %% (And this is what it replaces.)
104 % \setleftmargin{1in}
105 % \setrightmargin{1in}
106 % \settopmargin{1.5in}
107 % \setbottommargin{.5in}
109 \usepackage[normalem]{ulem}
110 \usepackage{amssymb}
111 \usepackage[mathscr]{euscript}
112 \usepackage[T1]{fontenc}
113 \usepackage{amsmath}
114 \usepackage{amsopn}
115 \usepackage{amstext}
116 \usepackage{amsthm}
118 \parindent = 1.2em
120 \theoremstyle{definition}
121 \newtheorem{prop}{Proposition}
122 \newtheorem{nota}{Note}[section]
123 \newtheorem{rem}{Editorial Remark}[section]
124 \newtheorem{lem}{Lemma}
125 \newtheorem{thm}{Theorem}
126 \newtheorem{cor}{Corollary}
127 \newtheorem{con}{Conjecture}
129 \usepackage{verbatim}
130 \makeatletter
131 \newenvironment{lisp}
132 {\let\ORGverbatim@font\verbatim@font
133 \def\verbatim@font{\ttfamily\scshape}%
134 \verbatim}
135 {\endverbatim
136 \let\verbatim@font\ORGverbatim@font}
137 \makeatother
139 \makeatletter
140 \newenvironment{idea}
141 {\let\ORGverbatim@font\verbatim@font
143 \def\verbatim@font{\ttfamily\slshape}%
144 \verbatim}
145 {\endverbatim
146 \let\verbatim@font\ORGverbatim@font}
147 \makeatother
149 \newenvironment{notate}[1]
150 {\begin{nota}[{\bf {\em #1}}]}%
151 {\end{nota}}
153 \newenvironment{note}[1]
154 {\begin{nota}[{\bf {\em #1}}]}%
155 {\end{nota}}
157 \newenvironment{edit}[1]
158 {\begin{rem}[{\bf {\em #1}}]\sl}%
159 {\normalfont\end{rem}}
161 \newcommand{\comm}[1]{
162 \sf \fbox{\begin{minipage}{.75\textwidth}#1\end{minipage}} \normalfont}
164 \newcommand{\inp}[1]{\sl#1\normalfont}
166 \newcommand{\xref}[1]{\ref{#1}}
168 %% Geh! $\chi$ with a subscript is typeset badly if you
169 %% don't put in a fake superscript, what's up with that?
170 %% Of course, if you use a function with a fake superscript,
171 %% you can't very well add another superscipt to it, can you!
172 %% Grr.
174 %% But, maybe I could make one required argument and
175 %% a second optional argument and solve the problem that
176 %% way? -- Well, LaTeX lets you have one optional argument
177 %% alright, but it wants the optional argument to be the first
178 %% argument, and I don't see any easy way around that. I
179 %% guess I could ask an expert sometime, but it doesn't quite
180 %% seem worth it. OTOH, this issue of typesetting chi's is
181 %% a bit of a bug, I think, so maybe it should be reported.
182 \newcommand{\indicator}[1]{\chi_{#1}^{}}
184 \begin{document}
186 \title{\emph{Arxana}}
188 \author{Joseph Corneli\thanks{The content of this file is available
189 under your choice of the GNU Free Documentation License (FDL) and
190 the GNU General Public License (GPL). If the FDL is selected, be
191 advised that this document has no Invariant Sections, no
192 Front-Cover Texts, and and no Back-Cover Texts.}}
194 \date{\today\ (draft)}
196 \maketitle
198 %% The system's design draws on ideas from Ted Nelson's ``Project
199 %% Xanadu'', combining them with the ``semantic network'' strategy
200 %% from artificial intelligence.
202 \abstract{A scholia-based document model for commons-based peer
203 production informs an advanced Emacs-based hypertext system.}
205 %% 1. Revise links and backlinks.
207 %% 2. Put together an appendix with simple specs. (Done for the
208 %% basic objects; not necessarily with all of the operations that
209 %% effect these objects.)
211 %% 3. After that, there are many user-friendly features that one could
212 %% tackle. Additional history lists for multi-dimensional browsing,
213 %% various useful consistency-maintaining features (not unlike
214 %% mascons!), versioning support, and so on. Presumably many of these
215 %% items can be left for other people to work on after the release.
217 %% 4. I still haven't completely worked out the theory of
218 %% "transclusion" (live-updating quotes) to my satisfaction, and this
219 %% (and its bi-directional variant, "identification") is the "killer
220 %% ap" I'd like to get into the software before I release it.
222 \tableofcontents
224 \newpage
226 \section*{Preface}
228 This document may look like a paper, but it is also runable code.
229 The code implements a hypertext system. You can use this
230 hypertext system to browse and edit the code and documentation
231 that describes the system itself.
233 To do that, when viewing the document's source code with Emacs,
234 evaluate this form (in place):
235 \begin{idea}
236 (save-excursion
237 (let ((beg (search-forward "\\begin{verbatim}"))
238 (end (progn (search-forward "\\end{verbatim}")
239 (match-beginning 0))))
240 (eval-region beg end)
241 (lit-eval)
242 (browse-scholium-system)))
243 \end{idea}
245 \section{Prelude} \label{prelude}
247 \begin{notate}{The philosophy} \label{the-philosophy}
248 The main concern here is to model systems for collaborative
249 authorship. What freedoms and limitations are embodied in such
250 systems? Working to understand how to empower users will hopefully
251 enable us to build a powerful and agile system; indeed, our goals here
252 extend beyond ``authorship'', to ``readership'' and query-answering;
253 that is, from hypertext to artificial intelligence.
254 \end{notate}
256 \begin{notate}{SBDM and CBPP}
257 The idea of a \emph{scholia-based document model} (\emph{SBDM}) for
258 \emph{commons-based peer production} (\emph{CBPP}) is thematic for the
259 work. Definitions for these terms suitable to the usage made within
260 this document are approximately as follows:
261 \begin{itemize}
262 \item \emph{CBPP}: the processes by which shared information resources
263 are produced by multiple co-authors.
264 \item \emph{SBDM}: a framework for understanding the ways in which
265 documents are put together out of smaller inter-referential
266 components.
267 \end{itemize}
268 \end{notate}
270 \begin{notate}{Bits and pieces} \label{bits-and-pieces}
271 Scholia-based documents tend to be comprised of small pieces whose
272 semantic content has been illuminated through an ongoing process of
273 annotation. This helps with refactoring, and with the process of
274 producing new, meaningful, derivative works. Rich annotation also
275 opens the way to increasingly powerful computer-based inference about
276 the content of the document. This document should be a good example.
278 \begin{figure}
279 \begin{center}
280 \includegraphics[width=5in]{bw}
281 \end{center}
282 \caption{Author and summarizing example (\emph{apr\`es} L. Weiner). \label{author-as-scholium}}
283 \end{figure}
284 \end{notate}
286 \section{Introduction} \label{introduction}
288 \begin{notate}{A scholia-based document model for commons-based peer production} \label{sbdm4cbpp}
289 The fundamental data structure used in this report is a simple
290 database made up of \emph{articles}, each of which has several
291 freeform components. An article's \inp{name} is an arbitrary LISP
292 object, typically a string (two articles with the same name are
293 considered to be the same). The articles can contain \inp{text} from
294 a string, buffer, or file (as well as from other sources). An article
295 is supplied with \inp{about} and \inp{type} metadata which say,
296 respectively, what other pieces of the document the articles are
297 about, and generally how they are to be treated by the system. A
298 collection of articles can be viewed as a semantic network, with links
299 from which \inp{about} data is constituted comprising the edges
300 between nodes (Note \ref{links}). (There are other sorts of links in
301 the system as well, cf. Note \ref{clusions}.) Linking is how scholia
302 are attached to other articles; the collection of all articles is
303 ``the commons''; and the rules for interacting with this collection
304 defines the commons's regulatory system.
305 \end{notate}
307 \begin{notate}{Inspirations} \label{inspirations}
308 One of the first things that got me thinking about this stuff was the
309 question of how to combine the contents of two digital libraries in a
310 useful and non-disruptive way\footnote{{\tt
311 http://planetx.cc.vt.edu/AsteroidMeta/one\_week\_in\_october}}.
312 From here, the more technical question of how to do bidirectional
313 updating between two digital libraries which share content and are
314 changing in real time arose (see Section \ref{bidi}). But probably
315 the most basic motivation comes from thinking about knowledge
316 representation and human interface for the Hyperreal Dictionary of
317 Mathematics project. The aim of this project is to get the wolrd's
318 mathematical knowledge into a coherent machine-readable and
319 humanly-useful form. I anticipate that the first major applications
320 of Arxana will be those directed towards building the HDM (see Section
321 \ref{HDM-things}).
323 After thinking about these things for a while, I wrote up a few pages
324 that expressed some ideas I later learned to be the central notions in
325 Ted Nelson's Project Xanadu (see Note \ref{relationship-to-xanadu}).
326 My interest in AI explains some of the differences between the two
327 designs; but the fact that I've chosen to use Emacs for development
328 probably explains even more.
330 Certainly the powerful text processing tools available in Emacs
331 (ranging from text properties and overlays to self-modifying code)
332 make it a great place to develop a next-generation hypertext system.
333 Existing Emacs-based hypertext systems, including the emacs-wiki
334 family of projects, and of course the built-in info and help
335 subsystems, give some sense of how useful Emacs-based hypertext can
338 Much of the attitude towards AI developed here inherits from Minsky's
339 ``Society of Mind''. In addition, a certain amount of experience
340 working with contemporary AI systems (Cyc and KM) both got me to think
341 about what an AI system is and what I would like to see ``AI work''
342 become.
344 The style of writing is inspired by Knuth's ``\TeX: the program''.
345 Here, instead of a typesetting program that can be used to typeset a
346 description of itself, we have a hypertext system that can be used to
347 browse and edit a description of itself. (Emacs had in fact pulled
348 that one off previously, and to great effect, but in a rather
349 different way.)
351 User freedom is probably the premier philosophical concern underlying
352 this endeavor. My ideas about online freedom have something to do
353 with what I know about MUDs (which isn't a whole lot; mainly that they
354 are sometimes user-hackable and that they resemble the text-based
355 single-user games with which I am more familiar) and with my
356 experience as a participant in various CBPP environments.
358 Section \ref{philosophy} delves further into these matters.
359 \end{notate}
361 \begin{notate}{Straightforward applications} \label{straightforward-applications}
362 Although I am envisioning the system being used to work on projects of
363 grand scope and vision, it can also be used in some down-to-earth ways
364 that are relevant to many people: for instance, the system can be used
365 by document co-authors to annotate and comment on successive drafts of
366 an evolving paper. Features to aid in this process have been present
367 in MS Word for some time, to the best of my knowledge. (And in ASCII
368 you can do it with brackets [ins: like this :ins], OR WITH CAPS.)
370 (Getting things set up to make quick and easy side-comments on a
371 given text would be nice.)
372 \end{notate}
374 \begin{notate}{Acknowledgements} \label{acknowledgements}
375 Aaron Krowne both helped inspire the initial design (through a series
376 of discussions about PlanetMath, the HDM project, and bi-directional
377 updating between digital libraries) and helped to give it a coherent
378 initial expression\footnote{\label{corneli-krowne}Joseph A. Corneli
379 and Aaron P. Krowne, A scholia-based document model for commons-based
380 peer production. \emph{Proceedings of the Emory University Symposium
381 on Free Culture and the Digital Library}, 2005.}.
383 Ray Puzio helped to put the project on a sound theoretical and
384 philosophical foundation as it developed.
385 \end{notate}
387 \subsection{Overview of the system} \label{overview}
389 \begin{notate}{Scholia} \label{scholia}
390 A ``scholium'' (plural ``scholia'') is a comment on something else.
391 We speak of a \emph{scholia-based document model} (or SBDM for short)
392 because speech is typically \emph{about} something. We also refer to
393 elements of the larger document as ``articles''. If an article isn't
394 \inp{about} anything (in the technical sense described in Note
395 \ref{definition-of-scholium}) then then it is considered to be
396 degenerate as a scholium. We will also talk about ``an article and
397 its attached scholia'' (regardless of whether or not the article is
398 itself a scholium attached to some other article). Scholia need not
399 be pieces of text: they can also be code or markup telling the reader
400 (or the computer) how to process the article(s) they are written
401 about.
402 \end{notate}
404 \begin{notate}{Generalized links} \label{generalized-links}
405 The \inp{about} features described in Note \ref{scholia} naturally
406 associate documents or parts of documents with one another. This
407 generalizes the notion of \emph{link} familiar from the web (and other
408 places). These familiar links are pieces of text with special markup
409 which say that are about some other piece of text:
410 \begin{idea}
411 <a href="document this link is about">text</a>
412 \end{idea}
413 In the scholium system, links can overlap and can point at more
414 different kinds of targets than in typical hypertext systems. Links
415 can also be given rich semantic properties by pairing them with
416 additional \inp{type} data and appropriately responsive procedures.
418 It is important to understand the fact that, in our system, markup and
419 metadata are typically stored as scholia linked to appropriate
420 targets.
421 \end{notate}
423 \begin{notate}{Modeling the commons} \label{modeling-the-commons}
424 In addition to being capable of modeling many different kinds of
425 documents, the system developed here should be capable of modeling
426 and/or supporting the relevant features of the CBPP processes that
427 create these documents. The SBDM is actually intended as a sort of
428 meta-model: a model for modeling models, including models of
429 documents, commonses, social contracts, culture building, and culture
430 change. Cf. Section \ref{experiments} and Note \ref{the-system}.
431 \end{notate}
433 \begin{notate}{Relationship to Xanadu} \label{relationship-to-xanadu}
434 The system presented here isn't meant to be an implementation of the
435 Xanadu idea, per se, although it provides some of the features one
436 would expect from a ``Xanadu implementation.''
438 I should probably mention that I haven't read all of Nelson's stuff
439 extra-closely, although I've looked through his books and enjoyed what
440 I saw there. As the system here moves towards greater usability, I
441 assume I'll find the time to review the details from Nelson's writing
442 more closely and flesh out this comparison. And I hope to have a
443 chance to review other systems that follow in the Xanadu lineage, e.g.
444 {\tt token\_word}\footnote{{\tt
445 http://hypertext.sourceforge.net/token\_word/}} (which supposedly
446 implements ``almost every core feature of Xanadu''). I guess it's the
447 hacker in me that makes me want to write the code first; and
448 certainly, the nature of the code I've produced thus far lends itself
449 to being helpful with literature review tasks
450 (cf. Note \ref{literature-review}). I'm pretty sure that this work
451 represents an advance, or at least steps in a new direction, for
452 Emacs-based hypertext.
454 One clear difference between this system and the Xanadu system is that
455 here articles are not supposed to be presented in a pay-to-access
456 fashion. The idea of working on complicated systems for royalties or
457 license maintenance doesn't strike me as particularly compelling.
458 Also, in this system, articles can be deleted (see Note
459 \ref{deleting-articles}), which as I understand it, is discouraged in
460 Xanadu (more investigation is warranted and the system for deletion
461 here needs finishing!).
463 To sum up, my overall sense is that Arxana, combined with simple
464 internet protocols could, very nicely, facilitate something
465 Xanadu-like, suitable for the current age.
466 \end{notate}
468 \begin{notate}{When implementing something new}
469 It is good to have an illustration of why the system is special and
470 different, and why it is also compatible with existing ways of
471 working. This is true whether the system is based on code or mores
472 (e.g. why are principles of freedom important online?). I'll be
473 devoting more time to making these illustrations in the future. I
474 expect that such illustrations will do a lot to underscore the value
475 of the framework developed in this document (and, indeed, value is
476 often most obvious in the more concrete manifestations and examples of
477 a more general system). Cf. Note \ref{principle-of-orthogonality}.
478 \end{notate}
480 \begin{notate}{What doesn't work or needs debugging} \label{doesn't}
481 Here are some more details on things that we're planning to provide
482 at some point but haven't finished yet.
483 \begin{itemize}
484 \item We should support threaded followups and make other improvements
485 to the display (see Note \ref{threading}).
486 \item ``Labels'' work but ``namespaces'' haven't been implemented yet
487 (see Note \ref{labels-and-namespaces}).
488 \item We don't yet have support for ``actionable'' articles (see
489 Note \ref{interactive-and-actionable-scholia}).
490 \item Various browsing features could be improved and extended
491 (e.g. to enable deletion or editing of some subset of articles en
492 masse), and probably debugged (especially the code from Section
493 \ref{temporal}). The history mechanism could probably be debugged
494 by displaying it.
495 \item We haven't fully finished the code for deleting (Section
496 \ref{deletion}).
497 \item Committing could stand to be beefed up with versioning (see Note
498 \ref{we-adopt-a-versioned-model}).
499 \item We don't yet have support for saving articles selectively. In
500 particular, we hope to add support for saving only new or modified
501 articles soon (but of course also for other predicates).
502 \item Support for derivative articles is somewhat lacking (Section
503 \ref{derivative}); in particular, I've done some work and sketching
504 for transclusion and identification (Sections \ref{transclusion} and
505 \ref{identification}) but I'm not yet happy with the results and
506 have instead had to seek a temporary work-around . These are some
507 of the trickest technical problems tackled in this document (see
508 Note \ref{difficulties-with-text-properties}). However, they should
509 also be some of the ``killer aps'' when they are finished.
510 \item Support for working in a distributed environment is lacking.
511 I plan to add ``native'' support for CVS and/or GNU Arch
512 soon\footnote{{\tt http://www.gnuarch.org/arch/how-arch-works.html}}.
513 \item Several of the experiments we describe haven't been attempted
514 yet.
515 \item Increased standardization and various other improvements should
516 be effected throughout.
517 \item We need to check and expand support for buffers and files within
518 the scholium system; see \ref{principle-of-orthogonality}. The
519 question of scholia attached to the Scholia Display buffer may prove
520 to be an especially annoying case; where will these be displayed?
521 More generally and less confusingly, what should be done with
522 scholia attached to buffers that have frequently-changing content?
523 Perhaps these scholia can somehow be associated with those changes,
524 and swapped in and out programmatically whenever the changes occur.
525 We should debug the `display-scholia-about-current-buffer' function.
526 See Note \ref{killed-buffers} for an example of the sort of problem
527 we have to deal with here. (By keeping articles and buffers
528 separate, we've made the first step towards insuring orthogonality,
529 but we want to be sure of usefulness, too, e.g. by improving default
530 loading of scholia for buffers.)
531 \item We need to check how this loads against a plain-vanilla Emacs,
532 and probably provide some easier means of getting started.
533 \item Make it so that `sch-plain-text' (Note \ref{sch-plain-text}) can
534 display links. In fact, we might want to always have it take in
535 links, or the unlistified contents of links. See Note
536 \ref{datatypes}.
537 \item We should finish the functions for browsing parents; cf. Note
538 \ref{forward-in-parent}.
539 \item Has the problem with committing a document that has a links at
540 the start of its display been resolved?
541 \item The system should be documented with use cases for all of its
542 features; at least the basic ones.
543 \end{itemize}
544 Given that the basic system does work and hopefully provides an
545 exciting glimpse of what is possible here, now seems to be a
546 reasonable time to invite other people to help with some of these
547 issues.
548 \end{notate}
550 \begin{notate}{Streamlined versions of this document}
551 As mentioned in Note \ref{bits-and-pieces}, the system makes it easy
552 to produce certain kinds of derivative versions of a document. Two
553 examples that may be helpful particularly helpful to readers are a
554 version that focuses on code (see Note \ref{with-code}), and a version
555 that steers clear of code (see Note \ref{without-code}). Compare
556 ``weave'' and ``tangle''. (Of course, I do suggest reading everything
557 at some point; see Note \ref{motto}.)
558 \end{notate}
560 \begin{notate}{A motto} \label{motto}
561 Certain issues cannot be resolved without writing code.
562 \end{notate}
564 \subsection{Design issues} \label{design}
566 \begin{notate}{Introduction to design issues}
567 Some of the key \emph{development issues} have been sketched in the
568 previous section. Here we discuss the issues that come in at the
569 level of \emph{design}.
570 \end{notate}
572 \subsubsection{Design principles}
574 \begin{notate}{Principle of minimality} \label{principle-of-minimality}
575 This system could be infinitely complex. At each turn, we try to
576 stick to minimal implementations first and then work out from there.
577 \end{notate}
579 \begin{notate}{Principle of order} \label{principle-of-order}
580 Functions and variables should not be used before they are defined.
581 (There is a related principle of context that is harder to express:
582 the idea there is that things should be defined in places that make
583 sense.) Any exceptions to this rule should be carefully considered.
584 \end{notate}
586 \begin{notate}{Principle of transparency} \label{principle-of-transparency}
587 It would be nice not to have features that disrupt the easy and
588 completely general flow of the code, but this seems very hard
589 to accomplish. We can at least try to be aware of the places where such
590 losses of generality appear, and make some assessment of the
591 consequences (and possible future remedies), and certainly try
592 to avoid losses of generality whenever possible.
593 \end{notate}
595 \begin{notate}{Principle of orthogonality} \label{principle-of-orthogonality}
596 In order to make this system work well with the rest of Emacs, it
597 should be roughly orthogonal to the rest of Emacs. It should not
598 require you to go off into your own little world, nor should it
599 require redefining basic functions, or otherwise change what people
600 are used to in terribly significant ways.
601 \end{notate}
603 \subsubsection{System architecture}
605 \begin{notate}{The principles of the architecture}
606 The system is built on the principle of a \emph{semantic network}.
607 Articles correspond roughly to the \emph{nodes} of a graph, and
608 link-backlink pairs to the \emph{edges}. Both of these types of
609 objects can bear labels with certain structured information on them.
610 (Actually, labels on links are sub-frames of the labels on articles;
611 and labels on backlinks are derived from data about the linking
612 article (I guess you could call that an ``induced subframe'' or
613 ``derivative subframe'' -- the issues having to do with where the
614 knowledge is stored, e.g., where you might store the query that tells
615 you which thing is a derivative, or one particular sort of derivative,
616 are in my opinion a philosophical issue beyond the scope of what we
617 wish to get involved with in this paragraph) and anyway, all
618 information \emph{in} the system is stored on articles. But we don't
619 really need to go there now either.) We could just say ``frame'' and
620 ``subframe'' and keep it simple. But note that these are the
621 \emph{internal} frameworks of the system, not the content frameworks
622 or whatever you want to call that. That really just about sums up the
623 architecture of the system itself.
624 \end{notate}
626 \begin{notate}{Metaprinciples of the architecture}
627 Eventually we want to get things like code that defines the system to
628 be ``understood'' by the system in some way. These are semantic
629 networks, so saying that they can understand something is moderately
630 appropriate. Right now, the code is just imported into the system in
631 a bulk fashion. But eventually the functions could go into the
632 article table. Really, the fact of the matter is that later we want
633 to put the fundamental object arrays for Emacs into the article table
634 too, so that the whole computation that is Emacs becomes a massive and
635 somewhat complicated scholium based document evolving in time. So,
636 now we get a sense of what it means to be self-documenting to the
637 extreme. (Now, per usual, we just modeling something that is already
638 there, and is already documented to a certain extent by itself, maybe
639 to a richer extent then you might think.) Getting Emacs embedded in
640 the scholium system is the next step after getting the system somewhat
641 roughly embedded in itself. (So, this might be an interesting thing
642 for the LISP crowd to think about; and indeed, it provides a sort of
643 metaphor for the structure of the HDM itself.)
645 To sum that up, and to conclude! We want to make the system
646 increasingly cognisant of itself. If it doesn't make sense to look at
647 all of the processes going on inside of Emacs, for example, then we
648 don't look at all of these processes. But to the extent that it is
649 useful to look at the details of a given process, it would be helpful
650 to track that process in the scholium system. (One question we might
651 ask ourselves is when exactly is it useful to track a given process,
652 noting that we are often tracking the process through time, if it is a
653 computation, and then most likely examining the trace later. However,
654 you could also set things up so that you could look at the trace from
655 different parts of it that are evolving. Of course, you can't look
656 into the future, you can only look at nodes that have already been
657 computed. But you could get a look-ahead effect going within your
658 computation that would know where to look ahead of time, so that its
659 journey to retrieve the answer begins before the answer has actually
660 been recieved, and the query process meets up with the answer just in
661 time. And that would be fairly tricky!
662 \end{notate}
664 \begin{notate}{Architectural implementation}
665 The system is currently implemented as a hash table of articles; the
666 format for these is explained later on in this document, mainly in
667 Section \ref{definition-of-scholium}.
668 \end{notate}
670 \subsubsection{Stylistic considerations} \label{stylistic-considerations}
672 \begin{notate}{Backend and frontend}
673 To the extent that it is possible, we should distinguish between the
674 backend and the frontend of the system. We could rewrite the backend
675 in scheme, for example, and rewrite the frontend in various
676 web-programming languages to make a system that is easy to use over
677 the internet.
678 \end{notate}
680 \begin{notate}{Abstracting access} \label{abstract-access}
681 Since we may eventually support both lists and hash tables (and
682 perhaps other things), we presumably should have an abstract means of
683 accessing articles. (Unless we were to decide to just do things with
684 hash tables; however, it seems likely to me that even if we use a hash
685 table as the main library, people may want to use lists for
686 sublibraries; if the same functions for access are supposed to be used
687 in both full and sub library scenarios, we'll want the abstract access
688 regardless of how the full library is set up.) A theoretical
689 discussion of the benefits of hash tables can be found on
690 PlanetMath\footnote{{\tt http://planetmath.org/encyclopedia/Hashing.html}}.
691 \end{notate}
693 \begin{notate}{The Emacs Way} \label{the-emacs-way}
694 Scholia about files and about buffers are probably most of what would
695 make this system useful to people who are collaborating on papers or
696 coding projects. See Note \ref{bias-towards-buffers}, Note,
697 \ref{back-to-base}.
698 \end{notate}
700 \begin{notate}{Intuitive interface}
701 The bread and butter of the system's user interface is a set-up with
702 side by side buffers (see Note \ref{side-by-side-buffers}). Other
703 display styles (e.g. as described in Note \ref{references}, or
704 threading, as in Note \ref{threading}, or a display spread across
705 several frames, etc.) should be straightforward to add.
706 \end{notate}
708 \begin{notate}{Text properties and overlays} \label{text-properties-and-overlays}
709 We essentially need to have scholia encoded locally as text
710 properties, because we need to be able to cut and paste the elements
711 and have the metadata transfered along. However, at least one aspect
712 of text properties is already ``owned'' by fontlock, namely faces. To
713 use faces in the scholium system, we have to hack an override in --
714 namely, we mark the buffer up using text properties and then mark them
715 up again with overlays. In general, text properties are used to track
716 text, and overlays are just used as a visual aide. See section
717 \ref{marking-things-up}, also Note \ref{reparsing-after-editing}.
718 \end{notate}
720 \begin{notate}{Managing text properties in buffers} \label{managing-properties-in-buffers}
721 We store information about \emph{all} attached scholia on text
722 property lists. We should also be storing the name of the article on
723 all of the text throughout the buffer, so that if the contents of that
724 buffer are cut and pasted, the text can be tracked. This requires a
725 somewhat complex data structure, and makes markup with overlays (as
726 well as some other details, e.g. text marked up with references which
727 is subsequently cut in half) tricky either in practice or
728 conceptually. See Note \ref{reparsing-after-editing}.
729 %% (These issues are rather different from the topic of managing
730 %% properties associated with articles \emph{themselves}, which is
731 %% discussed in Section \ref{managing-properties}.)
732 \end{notate}
734 \begin{notate}{Selection methods} \label{selection-methods}
735 Various selection facilities need to be implemented. A little
736 predicate matching thing would make things extensible! (See also Note
737 \ref{selective-displays} and Note
738 \ref{predicate-support-for-listing}.)
739 \end{notate}
741 \begin{notate}{Local navigation}
742 It is important to have convenient ways to move around from scholium
743 to marked region and back, from marked region to marked region, and so
744 on. See Section \ref{local}.
745 \end{notate}
747 \begin{notate}{Color and style of display} \label{color-and-style}
748 We could offer the user a choice between \inp{type}-based coloration
749 (indicating what sort of scholium is being marked up),
750 owner-coloration (who created the scholium) and connected-coloration
751 (which what I've initially coded up). We could use some combination
752 of color and other visual indicators (see Note \ref{monochrome}) to
753 provide more information.
755 Similarly, text written by a given author in a shared file could have
756 a special color. Another type of display would indicate how many
757 scholia had been created about a given region (like a rainfall chart).
758 Different styles can be generated essentially indefinitely. Another
759 user-friendly feature would be to be able to easily change the color
760 associated with some particular set of data (rather than changing the
761 overall scheme whereby colors are associated with data).
762 \end{notate}
764 \begin{notate}{The monochrome lifestyle} \label{monochrome}
765 For the benefit of people working with and without fontlock, three
766 display modes to point to attached scholia from Window $A$ will be
767 available: one that uses font lock; one that uses intangible tokens
768 {\tt [N:]} and {\tt [:N]} where {\tt N} is a number to demarcate the
769 beginning and end of the $N$th scholium (or some other customizable
770 pattern, e.g. based on the bookkeeping information); and a third
771 ``relaxed'' mode uses no markup at all. A number of intuitive ideas
772 for inserting indicators (e.g. in the fringe) could be tried. See
773 \ref{blinking} for another monochrome-friendly approach. Another
774 simple idea, similar to the one described above, would be to use
775 % Thanks /sw/share/texmf-dist/source/plain/impatient/
776 symbols (e.g. $*$, $\#$, \S) to associate scholia with the
777 beginning(s) of the passage(s) they are attached to, and use narrowing
778 to screen out other material.
779 \end{notate}
781 \begin{notate}{User-crafted semantics} \label{user-crafted-semantics}
782 As a generalization of Note \ref{color-and-style}, we will eventually
783 want some essentially completely different styles of rendering. In
784 every case we should also move to support \emph{user-crafted
785 semantics}. See also Note \ref{types-of-text}.
786 \end{notate}
788 \begin{notate}{Contextual display} \label{contextual-display}
789 An interesting feature would be to restrict to showing only the
790 scholia that are attached to the current portion of the main article
791 that is currently displayed, or only those associated with the
792 character position of point. In order to pull this off, we will need
793 to look some into page and cursor motion in Emacs\footnote{Thanks to Stephen Monnier and Eli Zaretskii for
794 telling me what to look for, on the emacs-devel list, 2006-04-04. The relevant tips were to look at:
795 `window-scroll-functions' (when a window's starting pos changes);
796 `fontification-functions' (when a piece of text needs to be displayed);
797 `before-' and `after-change-functions' (when a piece of text is modified);
798 `window-start' and `window-end';
799 `pre-' and `post-command-hook' (to run before/after each command, so you can
800 detect cursor motion).}.
802 Alternatively, we could write a new motion function, something like
803 `move-to-next-region-with-scholium' (cf. Note
804 \ref{move-to-next-or-previous-region-with-scholium}), and combine this
805 with a selective scholia display that will show whatever scholia are
806 found at the new point. The closest thing I could find in Emacs is
807 `calendar-move-hook'.
809 Yet another thought along these lines would be to have scholia appear
810 in the same buffer as the rendered main article, but, for example, in
811 columns beyond column 72 (or whatever the rightmost character in the
812 display of the main article is).
814 Compare Note \ref{displaying-nearby-scholia} for thoughts on automatic
815 \emph{contextualization} of an article at display time.
816 \end{notate}
818 \begin{notate}{References} \label{references}
819 Traditional hypertext links are a useful specialization of the general
820 sort of links we're developing here (Note \ref{generalized-links}).
821 In an effort to reduce confusion, when we wish to be precise, we will
822 refer to the scholia that are used to make a piece of text point at
823 other piece of text as \emph{references}. This usage is consonant
824 with use in other hypertext systems, in which ``links'' are pieces of
825 text that are marked up with references to other texts.
827 Despite the time it may take to get used to the name, the familiar
828 \emph{feel} of references should make it easy for people familiar with
829 other hypertext systems to transition to this system.
831 References are an example of a type of scholium that appears as markup
832 instead of appearing ``alongside'' the article they are attached to
833 (which is what will typically happen with other scholia). References
834 may have special semantics associated with them, see Note
835 \ref{special-reference-types} and Note \ref{fancy-references}.
837 It may be convenient to offer allow switching between our overlayed
838 references and the more familiar inline, wiki-like, references, or at
839 the very least, some other way to easily edit reference targets (and
840 similarly for other sorts of links). See Section \ref{wiki} for
841 various information on simulating a wiki with the scholium system.
842 \end{notate}
844 \begin{notate}{Threading} \label{threading}
845 We can also provide facilities for showing all attached scholia
846 together with \emph{their} attachments, and so on, within some fixed
847 graph distance, beyond which we just include links to lower levels (as
848 yet \emph{unimplemented} - but a good idea). This is essentially
849 what's done on Slashdot, and we would want to use a similar indenting
850 (and, ergo, threading) mechanism. (We could be even more
851 Slashdot-like and do scoring and the whole bit.) The thing to bear in
852 mind is that we dont' have to be constrained to follow threads along
853 one ``follow-up-to'' axis; we can choose arbitrary conditions to
854 constrain the way we view a local hierarchy (cf. Note
855 \ref{hierarchy}). The simplest one to state is the one already
856 mentioned, namely, viewing all attached scholia to some depth.
857 \end{notate}
859 \begin{notate}{Ancestors} \label{ancestors}
860 We typically think about showing a article together with articles that
861 are about it (its scholia) but we can just as well show it together
862 with articles that it is about (its referents). Indeed, views that
863 take into consideration the article's parents and grandparents have
864 obvious applications, e.g., when attempting to follow a conversation.
865 Particularly if an article has no children itself, it may be handiest
866 to display it together with its parent (multiple parents could
867 potentially complicate the matter). These issues have been taken up
868 to some degree in various places in this document, including
869 Note \ref{more-than-one-parent} and Note
870 \ref{add-visible-parent-and-sibling-links}.
871 \end{notate}
873 \begin{notate}{Expand and collapse backlink context}
874 We typically show an article together with the text of its scholia,
875 but we could optionally simply say that such-and-such an article links
876 here. Compare Note \ref{contextual-display} and Note \ref{ancestors}.
878 We may also want to provide a hierarchy of additional scholia, mapping
879 along the links-to and the linked-to directions, see Note
880 \ref{threading}.
881 \end{notate}
883 \begin{notate}{Labels and namespaces} \label{labels-and-namespaces}
884 A \emph{label} is a predicate extent that has (typically) been
885 maintained on the fly (or otherwise made concrete). A
886 \emph{namespace} is a place to put articles; articles in different
887 namespaces can have the same names but not be the same. An object can
888 have many labels but can only live in one namespace. (See Section
889 \ref{subcollections}, and Note \ref{cost-of-maintaining-labels} in
890 particular.)
891 \end{notate}
893 \begin{notate}{Filtering} \label{filtering}
894 Filtering is closely related to the topic of subcollections mentioned
895 in Note \ref{labels-and-namespaces} (and it also relates to the issue
896 of predicate mapping; see Note \ref{mapping-across-a-subcollection}
897 and Note \ref{search-engine-interface}). The point to keep in mind
898 is that different people are going to want to see different things
899 when looking at a document.
900 \end{notate}
902 \begin{notate}{Transcluding and outline views} \label{transcluding-and-outlines}
903 Note that instead of text stating where the URL is, we could have an
904 ``transclude'' scholium; this would cause the latest, current, version
905 of the target document to appear in the current document when the
906 latter is rendered. One should be able to look at the current
907 document as an outline (hierarchy) showing these ``transclusion''
908 relationships explicitly. Similarly, one should be able to collapse
909 and expand different parts of the document (i.e., in the collapsed
910 view, only the title of the transcluded document would appear, but in
911 the expanded view all of the content would appear). These sorts of
912 ideas are handy whenever thinking about container documents (Note
913 \ref{container}; oppose Note \ref{thread}). When examining an
914 outline, one should be able to jump to the article in its place inside
915 of the document that is being outlined, or as a stand-alone item.
916 \end{notate}
918 \begin{notate}{Rendered and source views} \label{rendered-and-source-views}
919 A more mainstream example than the expanded and collapsed views from
920 Note \ref{transcluding-and-outlines} are rendered and source views.
921 These could be relevant when working with \LaTeX\ or HTML (e.g., when
922 browsing this document, it would be nice to have things detexed).
923 Presumably edits would take place in the source view (though not
924 necessarily; compare the Emacs Muse\footnote{{\tt
925 http://www.mwolson.org/projects/MuseMode.html}}). Switching in
926 and out of rendered views would be an extra step when initiating edits
927 (see Section \ref{initiating-edits}).
929 One simple feature that would be a nice part of a reasonable rendering
930 would be to keep the text within a certain width by filling at render
931 time (this would be both for articles and for the scholia display).
932 Presumably exported text would also have to be filled if it is to
933 look good.
935 Much more generally, it would be nice to have a full-fledged
936 \LaTeX\ renderer (along the lines of \LaTeX-to-HTML). A renderer is
937 in many ways similar to a parser, so a simple parser is a reasonable
938 first step. Some of the work related to
939 Emacspeak\footnote{{\tt http://emacspeak.sourceforge.net/}} is,
940 I think, relevant to this problem.
941 \end{notate}
943 \begin{notate}{Page numbers}
944 If we could figure out how to do some \emph{truly} device-independent
945 rendering of \LaTeX\ documents, one particular thing we'd presumably
946 have come up with be a correspondence between \emph{page numbers} in
947 the printed version of a document and in the electronic version. In
948 the mean time, maybe we can come up with some easy way to solve this
949 using some specially logging when \LaTeX\ processes ``notate''
950 environments? (E.g., it wouldn't be hard to use special commands to
951 make an index of the notate environments in the document; and
952 presumably Emacs could read the source of that index.)
953 \end{notate}
955 \begin{notate}{Alternate names for buffers}
956 Should buffers have special names stored in buffer-local variables, or
957 should we search the library for buffers and check to see if they are
958 the same (regardless of what name they go by)? Or some other approach
959 to deal with named buffers? See section \ref{display-interface}.
960 \end{notate}
962 \begin{notate}{Saving and reading}
963 The user can save and read back a given collection of scholia. As an
964 example, arbitrary files can be opened in `scholia-mode' so that all
965 scholia stored in the same directory as the file will appear
966 automatically as annotations.
967 \end{notate}
969 \begin{notate}{Versioning} \label{versioning}
970 In order to edit and stay kosher, we should provide support for
971 versioning. This version information will be stored on the
972 \inp{bookkeeping} slot (or, alternatively, we should store sufficient
973 information to recover the versions; if such information isn't already
974 available elsewhere in the system). Note that we could just go ahead
975 and make functions for editing the text and then add functions for
976 saving the previous version later, in a hook. (This relates to the
977 slightly more general problem of making editing work in general, see
978 Section \ref{editing}.)
980 In order to deal with \inp{about} data that terminates on a given
981 article version instead of on the latest version, we will want to have
982 an additional optional column available in links that is reserved for
983 the version number.
985 (Note that some objects may not need to have versions stored about
986 them.)
987 \end{notate}
989 \begin{notate}{CVS/Arch/filesytem support} \label{vc-and-filesystem-support}
990 We need to figure out how to integrate external information resources
991 into the system. One issue with CVS and Arch is that we (sometimes)
992 will want to only look at files that are new or have changed upon
993 reloading. This means that the version management software will
994 probably have to be integrated fairly closely into the system.
995 Another option would be to keep a record of the files in any directory
996 that is being used, and check this record against that file's listing
997 whenever the user wants to reload the content from that file. This
998 may be the only option we really have for using the filesystem
999 directly, but for the case of CVS, proper integration would probably
1000 be better.
1002 Note that Arch has its own way of doing version management (as do
1003 all version control systems, of course). It might be best if
1004 we could swap different methods for version control in and out.
1005 Fundamentally, we need to know where to look for articles --
1006 they don't necessarily have to be in the filesystem (perhaps
1007 they could be assembled in real time in some buffer, for example;
1008 similarly, I think Arch builds various patched versions in real
1009 time).
1010 \end{notate}
1012 \begin{notate}{Responsiveness to editing} \label{responsiveness-to-editing}
1013 As editing takes place, the information in the system needs to be kept
1014 up-to-date and coherent with itself. The main developments in this
1015 section are presented in Section \ref{committing}.
1016 \end{notate}
1018 \begin{notate}{Unique identifiers for individual pieces of markup}
1019 When committing edits, we reparse the buffer to find the places where
1020 the scholia are attached (Section \ref{parsing}). For things to
1021 work properly, each piece of markup should have a unique identifier
1022 (the article name and link number should suffice, see Note
1023 \ref{format-of-about-field}). This will make it possible tell whether
1024 a piece of markup has been completely deleted, or swapped with another
1025 piece, or split into several pieces, or whatever (in theory, a region
1026 can even be moved between buffers, which would require an additional
1027 level of reparsing, we won't worry about that here for now; see Note
1028 \ref{aggressive-dop}).
1029 \end{notate}
1031 \begin{notate}{Manipulation of windows}
1032 The somewhat aggressive manipulation of windows used in this program
1033 could get annoying, especially in the case of editing multiple
1034 articles at once. (Which is one possible reason for editing things
1035 inside one buffer, see Note \ref{identification-use-case}.)
1036 \end{notate}
1038 \begin{notate}{Sorting scholia}
1039 We want scholia to appear in some reasonable order relative to the
1040 order of marked regions. Section \ref{sorting} is supposed to do
1041 this. Note also that sorting should not be destructive; see Note
1042 \ref{order-of-about}.
1043 \end{notate}
1045 \begin{notate}{Complexity issues}
1046 Some features simply would take too long to run when there are lots of
1047 scholia or articles involved. We need to be aware of these sorts of
1048 complexity issues. (It usually doesn't take much more than a simple
1049 test to make one fully aware of the problem, when dealing with
1050 terrible complexity scenarios!) Section \ref{subcollections} contains
1051 a few thoughts on how to limit complexity.
1052 \end{notate}
1054 \begin{notate}{Ease of use}
1055 In addition to being more featureful than the wiki medium, I hope that
1056 this system will be easier to use -- wikis as I know them are fairly
1057 laborious; lots of steps are needed to edit and save. The system
1058 should be designed in a way that requires few if any ``extra'' steps
1059 from authors.
1060 \end{notate}
1062 \begin{notate}{Return to base representation} \label{back-to-base}
1063 It might be nice to have a way to return from a scholium to its
1064 ``actual'' base representation, i.e., if it is associated with a
1065 buffer, we should find that buffer, or if it is associated with a file
1066 we switch to a buffer visiting that file. Indeed, I think we have
1067 thing set up now so that an article stored in a buffer will always be
1068 attached to that buffer. We might want to be more flexible, allowing
1069 various different ways to attach and reattach (compare Note
1070 \ref{movable-scholia}).
1071 \end{notate}
1073 \begin{notate}{Code transparency}
1074 It is good to have easy-to-understand names for functions that will
1075 appear over and over again; for example, we provide functions to
1076 access the bits and pieces of scholia (see Note
1077 \ref{access-functions}). But we should try to do this all the time,
1078 for all of the data structures we build.
1080 See also Note \ref{assimilating-data} for further thoughts on why it
1081 is a good idea to do things this way.
1082 \end{notate}
1084 \begin{notate}{Creating a scholium about several articles}
1085 I'm not sure we have sufficiently strong mechanism for making scholia
1086 that apply to several other articles. That would be one potential use
1087 of the list browser from the previous section; we could mark articles
1088 and make a scholium about marked articles quickly, or mark articles
1089 and then make scholia about sections from other articles. Also, it
1090 would be good to have a way to break out of the region selection
1091 routine and start selecting regions from some article fluidly when
1092 working on making scholia \emph{that} way.
1094 This is useful as long as we are able to gather all of the articles we
1095 want to make a scholium about into one listing, or if we can find a
1096 way to use several listings together intelligently.
1097 \end{notate}
1099 \begin{notate}{Space versus time tradeoffs}
1100 We value time over space tradeoffs. If the data set becomes very
1101 large, this judgement may have to change (e.g. if the system gets
1102 popular, we won't be able to hold all of the available articles
1103 in memory, or on disk, and we'll have to get clever about
1104 swapping things around).
1105 \end{notate}
1107 \begin{notate}{Support for systems in which passages have special meanings} \label{systems-with-special-passages}
1108 RMAIL, info, and EDB are just a few examples of Emacs subsystems whose
1109 most ``meaningful'' objects are smaller than the files in which these
1110 objects live. Support for these objects would be good to add to the
1111 scholium system, so that we can e.g. record mail messages or info
1112 pages that match some particular property.
1113 \end{notate}
1115 \begin{notate}{Undoable editing}
1116 It would be nice to be able to undo the editing actions that
1117 we support.
1118 \end{notate}
1120 \begin{notate}{Support for narrowing}
1121 Frequently the function `point' is used here; I'm assuming that
1122 documents will be widened properly. But it would be good to be able
1123 to support narrowing (see Note \ref{systems-with-special-passages}).
1124 \end{notate}
1126 \begin{notate}{Hooks and `cond' forms} \label{transforming-cond}
1127 At some earlier point, it seemed useful to think about transforming a
1128 `cond' form with an unquoted variable that contains extra cases (that
1129 are to be defined as needed). This seemed like a good opportunity to
1130 use LISP self-modifiability, and furthemore, it seemed like a good way
1131 write things in order (see Note \ref{principle-of-order}). However,
1132 typically the same thing can be achieved with hooks. The function
1133 `sch-plain-text' is a good example of this (Note
1134 \ref{sch-plain-text}).
1135 \end{notate}
1137 \begin{notate}{Multidimensional visual browsing} \label{multidimensional-visual-browsing}
1138 It might be handy to have a small control pannel at the bottom of the
1139 main article display that could be used to go backwards and forwards
1140 according to the layout of the document \emph{and also} according to
1141 the order in which things had been browsed so far (and anything else
1142 that the user might dream up to put there).
1143 \end{notate}
1145 \begin{notate}{Using datatypes} \label{datatypes}
1146 In order to be able to pass different kinds of objects around and have
1147 them interpreted correctly, it might be advantageous to have our data
1148 structures typed; I'm not quite sure how types work in Emacs -- but I
1149 can say that datatypes are obviously scholia. For example, we might
1150 want there to be an article datatype (right now, there are only types
1151 \emph{of} articles, like ``references'' for example). Another entity
1152 that could have a special datatype is the link.
1154 The question of datatypes for \emph{forms} seems interesting; it
1155 basically boils down to the question as to whether we add scholia to
1156 arbitrary lisp structures (see Note \ref{functional}).
1157 \end{notate}
1159 \begin{notate}{Hooks as scholia}
1160 Hooks are an easy-to-see example of scholia in the Lisp paradigm
1161 (compare Note \ref{functional},
1162 \ref{including-transcluding-and-lisp}).
1163 \end{notate}
1165 \subsection{Elisp requirements}
1167 \begin{notate}{Packages}
1168 I'm not sure we actually need align any more, but cl is
1169 of course very helpful.
1170 \end{notate}
1172 \begin{lisp}
1173 (require 'align)
1174 (require 'cl)
1175 (load "cl-seq")
1176 (load "cl-extra")
1177 \end{lisp}
1179 \subsection{Lisp preliminaries}
1181 \begin{notate}{On `add-or-replace'}
1182 It seems that this function is no longer used.
1183 \end{notate}
1185 \begin{lisp}
1186 (defun add-or-replace (lis elt pred)
1187 (let ((found nil)
1188 (n 0)
1189 (len (length lis)))
1190 (while (and (not found)
1191 (< n len))
1192 (when (funcall pred (nth n lis))
1193 (setcar (nthcdr n lis) elt)
1194 (setq found t))
1195 (setq n (1+ n)))
1196 (if found
1197 (1- n)
1198 (nconc lis (list elt))
1199 n)))
1200 \end{lisp}
1202 \begin{notate}{On `add-to-or-start-list'} \label{add-to-or-start-list}
1203 This is is used to start store an \inp{element} on a
1204 ``\inp{possible-list}''; unlike `add-to-list', it works even when list
1205 is nil, or even (for now) when \inp{possible-list} is not a list at
1206 all. (Unlike with `add-to-list', \inp{possible-list} should not be
1207 the name of a list.)
1209 This function is used by `put-type-labels', `put-backlinks' and
1210 `label-article'. Note that you have to \emph{save} the result if you
1211 want to this function to have a lasting effect.
1213 Like `add-to-list', this function will only store \emph{one} copy of
1214 \inp{element}.
1215 \end{notate}
1217 \begin{lisp}
1218 (defun add-to-or-start-list (possible-list element)
1219 (cond ((null possible-list)
1220 (list element))
1221 ((listp possible-list)
1222 (if (member element possible-list)
1223 possible-list
1224 (append possible-list (list element))))
1225 (t (list possible-list element))))
1226 \end{lisp}
1228 \begin{notate}{On `next-single-property-change+predicate'}
1229 Like `next-single-property-change' except instead of automatically
1230 judging changes in the text property by the `eq' predicate, it allows
1231 the user to supply a \inp{test}.
1232 \end{notate}
1234 \begin{lisp}
1235 (defun next-single-property-change+predicate (pos prop &optional test)
1236 (let ((starting (get-text-property pos prop))
1237 (index pos)
1238 (cmpfct (or test
1239 'eq)))
1240 (save-excursion
1241 (while (and (setq index (1+ index))
1242 (< index (point-max))
1243 (funcall cmpfct
1244 starting
1245 (get-text-property index prop)))))
1246 (when (< index (point-max))
1247 index)))
1248 \end{lisp}
1250 \begin{notate}{On `delete-all-dups'}
1251 This function differs from `delete-dups' in being
1252 non-destructive and in keeping none of several `equal'
1253 occurrences of an element in \inp{list} as opposed to one;
1254 otherwise, it manifests a similar idea.
1255 \end{notate}
1257 \begin{lisp}
1258 (defun delete-all-dups (list)
1259 (let ((tail list)
1260 ret)
1261 (while tail
1262 (cond ((member (car tail) (cdr tail))
1263 (setq tail (delete (car tail) tail)))
1265 (setq ret (cons (car tail) ret)
1266 tail (cdr tail)))))
1267 ret))
1269 (defun set-difference (A B)
1270 (delete-all-dups (append A B)))
1272 (defun zip (A B)
1273 (let ((ret (make-hash-table)))
1274 (while A
1275 (puthash (car A)
1276 (car B)
1277 ret)
1278 (setq A (cdr A)
1279 B (cdr B)))
1280 ret))
1282 (defun flatten (list-structure)
1283 (apply 'concatenate 'list (list list-structure)))
1284 \end{lisp}
1286 \section{Scholia-based documents} \label{sbdm}
1288 \subsection{The digital library} \label{digital-library}
1290 \begin{notate}{On `article-table'} \label{article-table}
1291 We begin with an empty library.
1292 \end{notate}
1294 \begin{lisp}
1295 (defvar article-table
1296 (make-hash-table :test 'equal))
1297 \end{lisp}
1299 \begin{notate}{Structure of articles} \label{structure-of-articles}
1300 Every article has a \inp{name}, which can be any LISP object (but is
1301 most frequently a string). They also have various other standard
1302 sorts of data associated with them; see Note
1303 \ref{definition-of-scholium} for the particulars. This data is
1304 referred to by `put-article' collectively as the article's \inp{value}
1305 (but this name is somewhat misleading, because the \inp{name} too is
1306 an important part of the article). One special sort of article is a
1307 ``library subcollection'' -- see Section \ref{subcollections} for more
1308 information on these things.
1309 \end{notate}
1311 \begin{notate}{On `put-article'} \label{put-article}
1312 This destructively adjusts the values on the hash table (see
1313 documentation for `puthash'). To \emph{intelligently manage} the
1314 values in the table takes more work, so we typically `get-article'
1315 before to make various comparions and adjustments to existing values
1316 before making changes.
1317 \end{notate}
1319 \begin{lisp}
1320 (defun put-article (name value)
1321 (puthash name value article-table))
1322 \end{lisp}
1324 \begin{notate}{On `get-article'}
1325 Basically just `gethash', but since the article table is indexed by
1326 \inp{name} and we don't want to pass \inp{name} around all the time,
1327 we add it to the recalled value.
1328 \end{notate}
1330 \begin{lisp}
1331 (defun get-article (name)
1332 (let ((content (gethash name article-table)))
1333 (when content
1334 (cons name content))))
1335 \end{lisp}
1337 \begin{notate}{On `name-of-current-article'} \label{name-of-current-article}
1338 The ``current article'' is of special importance for display (an
1339 article is made ``current'' when `display-article' displays it). The
1340 name of this article is stored in this variable.
1341 \end{notate}
1343 \begin{lisp}
1344 (defvar name-of-current-article nil)
1346 (defun current-article ()
1347 (get-article name-of-current-article))
1348 \end{lisp}
1350 \begin{notate}{What about using the file system?}
1351 If the library is being updated by many people at different times, it
1352 may also make sense to read documents from a file system on the fly.
1353 Indeed, the program does support files and buffers. But the article
1354 table is still a decent \emph{model} -- similar in nature to a
1355 library's \emph{catalog}.
1356 \end{notate}
1358 \subsection{Creating scholia} \label{scholium-function}
1360 \begin{notate}{Component pieces of scholia} \label{definition-of-scholium}
1361 The `scholium' function maintains a catalog of articles, indexed by
1362 name (Section \ref{digital-library}). Each article contains
1363 \inp{text}, an indication of what the article is \inp{about}, its
1364 \inp{type}, and \inp{bookkeeping} information which gives the
1365 article's edit history and ownership information. Articles must
1366 always follow this pattern.
1367 \end{notate}
1369 \begin{notate}{Format of `name' field}
1370 Any LISP object can be the \inp{name} of a scholium. Scholia are
1371 indexed by name: names are unique within namespaces (see section
1372 \ref{subcollections}), and the combination of name and namespace is
1373 how an article is looked up. (At present, names are typically
1374 rendered as strings without any newlines, but this is a front-end
1375 matter and essentially arbitrary from the point of view of internal
1376 format.)
1377 \end{notate}
1379 \begin{notate}{Format of `text' field}
1380 Just about anything can go into the \inp{text} field, but anything
1381 ``weird'' needs to be backed up by appropriate \inp{type} metadata
1382 and appropriate handlers (see Section \ref{rendering}).
1383 \end{notate}
1385 \begin{notate}{Format of `about' field} \label{format-of-about-field}
1386 The \inp{about} field is a list of \emph{links} (in the sense of Note
1387 \ref{generalized-links}). See Note \ref{links} for details.
1389 We could at some point investigate making \inp{about} data (and
1390 perhaps other sorts of data) \emph{typed} so that we can more easily
1391 the genesis of a given datum.
1392 \end{notate}
1394 \begin{notate}{Links} \label{links}
1395 Each link is associated with precisely one article. Links can have
1396 additional link-type information stored about them. The general
1397 format of a link is:
1398 \begin{idea}
1399 (<target article's name> &rest <link-types>)
1400 \end{idea}
1401 The design here maintains partial symmetry between the treatment of
1402 article types and link types; the cdr of a link can be processed
1403 by the same typedata processing functions as the \inp{type}
1404 data from articles.
1406 For example, the link
1407 \begin{idea}
1408 '(foo (passage 10 15) mistaken)
1409 \end{idea}
1410 indicates that the region from character position 10 to 15 in the
1411 article named ``foo'' is ``mistaken'', whereas the link
1412 \begin{idea}
1413 '(foo mistaken)
1414 \end{idea}
1415 indicates simply that the article \emph{foo} is mistaken.
1416 \end{notate}
1418 \begin{notate}{Links indicate at most one passage} \label{links-indicating-passages}
1419 It seems reasonable to me to assert that each link will indicate at
1420 most \emph{one} passage. This is indeed an assumption made in the
1421 code, see the function `typedata-includes-passage' (Note
1422 \ref{typedata-includes-passage})).
1423 \end{notate}
1425 \begin{notate}{Format of `type' field}
1426 The \inp{type} field is supposed to be a symbol or list of symbols.
1427 If it is nil, the article is assumed to be normal text.
1428 \end{notate}
1430 \begin{notate}{Format of `bookkeeping' field}
1431 The \inp{bookkeeping} field has a special format, very similar
1432 to the format of metadata articles (see Section
1433 \ref{metadata-articles}); one might expect to see something like
1434 \begin{idea}
1435 ((owner <owner>)
1436 (ACL <ACL>)
1437 ...)
1438 \end{idea}
1439 Remember that the \inp{bookkeeping} is \emph{owned}, so we probably
1440 shouldn't put anything there that can't be edited by the user, and so
1441 in particular, things that are needed for system consistency should go
1442 into metadata articles instead.
1444 Do notice that various schemes for access and ownership can be
1445 considered. (E.g. maybe anyone on the \emph{access control list}
1446 (ACL) can edit the text of the article, but only the owner is allowed
1447 to edit the ACL itself.)
1449 It would be worth looking at existing strategies (e.g. as found on
1450 PlanetMath) for handling complicated ownership and access
1451 arrangements. Actual implementation of useful bookkeeping features
1452 will have to come later (for a sort of silly placeholder for the
1453 meantime, see Note \ref{sch-book}).
1454 \end{notate}
1456 \begin{notate}{Relationship of bookkeeping data and metadata article}
1457 Bookkeeping data is \emph{user editable}, but metadata article
1458 generally isn't, or, when it is, it is typically treated as common
1459 property. This is important! See Note
1460 \ref{metadata-article-overview}.
1461 \end{notate}
1463 \begin{notate}{Access functions} \label{access-functions}
1464 A few simple functions to get pieces of (just aliases to help with
1465 coding; see Note \ref{principle-of-transparency}). Note
1466 \ref{link-accessors} talks about something similar for links.
1467 \end{notate}
1469 \begin{lisp}
1470 (defalias 'scholium-name 'first)
1471 (defalias 'scholium-text 'second)
1472 (defalias 'scholium-about 'third)
1473 (defalias 'scholium-type 'fourth)
1474 (defalias 'scholium-bookkeeping 'fifth)
1475 \end{lisp}
1477 \begin{notate}{Order and interpretation of `about' field} \label{order-of-about}
1478 The order of links in the \inp{about} field is not arbitrary.
1480 The order of links determines link-ids, which are used for
1481 both backlinks (Section \ref{backlinks-section}) and markup
1482 (Section \ref{marking-things-up}).
1483 \end{notate}
1485 \begin{notate}{Link accessors} \label{link-accessors}
1486 Links have exactly one linked-to-article together with any number of
1487 different link-types.
1488 \end{notate}
1490 \begin{lisp}
1491 (defalias 'linked-to-article 'first)
1492 (defalias 'link-type 'cdr)
1493 \end{lisp}
1495 \begin{notate}{Special link accessors}
1496 First we need a function that will give us the type-element associated
1497 with a given type. Then, we have some important examples.
1499 The function `link-type-accessor' will produce the (first) specific
1500 type-element from \inp{link} that matches the given \inp{type}, if one
1501 exists.
1503 Note that the format of \emph{version} access should follow the
1504 `link-version' function given here. (Passages don't have versions, so
1505 it doesn't make sense to put a version number as an additional element
1506 of a ``passage'' element.)
1507 \end{notate}
1509 \begin{lisp}
1510 (defun link-type-accessor (link type)
1511 (car (member-if (lambda (type-elt)
1512 (or (eq type-elt type)
1513 (and (listp type-elt)
1514 (eq (car type-elt) type))))
1515 (cdr link))))
1517 (defun link-beginning (link)
1518 (second (link-type-accessor link 'passage)))
1520 (defun link-end (link)
1521 (third (link-type-accessor link 'passage)))
1523 (defun link-version (link)
1524 (second (link-type-accessor link 'version)))
1525 \end{lisp}
1527 \begin{notate}{Link creators} \label{link-creators}
1528 It might be nice to have a function that is in charge
1529 of link creation, so we can quickly identify the places
1530 where links are being created.
1531 \end{notate}
1533 \begin{notate}{Link clusters} \label{link-clusters}
1534 In previous versions of this work, I grouped links into ``segments''
1535 by default. I subsequently realized that adding this extra default
1536 layer was ugly, and that it would limit the attractiveness of the
1537 system. Nevertheless, the initial intention was, I think, good. The
1538 idea with segments was to group certain links together semantically.
1539 For example, if the region that a reference was attached to got split
1540 in two after editing, one might want to maintain that one reference as
1541 being \inp{about} two regions ``in the first place'' while continuing
1542 to be about only the one target article ``in the second place''.
1543 (On references, see Note \ref{references}.)
1545 In the case of references, we can get away with making making the
1546 ``link text'' correspond to all of the links besides the \emph{last}
1547 one. And in many other cases, similarly, we will be able to specify
1548 semantics for \inp{about} data in the \inp{type} data. However, in
1549 some cases, we may need to put together link clusters that are
1550 separate from the article entirely -- in other words, we need to be
1551 able to attach scholia to \inp{about} data (as well as, e.g., to
1552 \inp{text} data).
1554 This flexibility assures us that there can be as many different kinds
1555 of clusters as we can come up with. By contrast, if we were using
1556 segments, the actual semantics would either have to be more limited,
1557 or would end up building extremely complex \inp{about} fields.
1559 More work on the subject of link clusters will follow in due course.
1560 Right now, I think they are just conceptually useful. (Which is
1561 another reason for getting rid of segments... thank goodness
1562 \emph{they} never had a chance to become useful!)
1563 \end{notate}
1565 \begin{notate}{Uses for `type' field}
1566 One use of types is to maintain subcollections; see Note
1567 \ref{on-modified-type-labeler-etc}. Articles of different types can
1568 be rendered or otherwise interpreted differently.
1569 \end{notate}
1571 \begin{notate}{Hooks for new and modified scholia} \label{hooks-for-new-and-modified-scholia}
1572 If the scholium is new, run `new-scholium-hook', otherwise, run
1573 individual hooks depending on which pieces of the scholium were
1574 modified (if any). We use separate hooks in part because we need to
1575 be careful about what sorts of changes we make. If we adjusted the
1576 value of some scholium every time the value of a scholium was
1577 adjusted, we would expect to encounter infinite loops pretty quickly!
1579 The standard settings for these hooks will be given in the section
1580 \ref{subcollections}; these settings facilitate e.g. the automatic
1581 creation of backlinks (Note \ref{backlinks}).
1582 \end{notate}
1584 \begin{lisp}
1585 (defvar new-scholium-hook nil)
1586 (defvar scholium-modified-text-hook nil)
1587 (defvar scholium-modified-about-hook nil)
1588 (defvar scholium-modified-type-hook nil)
1589 (defvar scholium-modified-book-hook nil)
1590 \end{lisp}
1592 \begin{notate}{The `scholium' function} \label{the-scholium-function}
1593 This function is foundational for the system. Lots of other functions
1594 will use it, but because it is destructive, users should typically not
1595 access it directly. Several interactive interfaces to this function
1596 appear in Section \ref{creation}. Note that the conditional structure
1597 here shouldn't be a `cond'; we really mean to run several hooks if
1598 several parts of the scholium have been modified.
1599 \end{notate}
1601 \begin{lisp}
1602 (defun scholium (name text &optional about type book)
1603 (let ((old-version (get-article name)))
1604 (put-article name (list text about type book))
1605 (when (not (metadata-override))
1606 (if (not old-version)
1607 (run-hooks 'new-scholium-hook)
1608 (when (not (equal (scholium-text old-version) text))
1609 (run-hooks 'scholium-modified-text-hook))
1610 (when (not (equal (scholium-about old-version) about))
1611 (run-hooks 'scholium-modified-about-hook))
1612 (when (not (equal (scholium-type old-version) type))
1613 (run-hooks 'scholium-modified-type-hook))
1614 (when (not (equal (scholium-bookkeeping old-version) book))
1615 (run-hooks 'scholium-modified-book-hook))))))
1616 \end{lisp}
1618 \begin{notate}{On `metadata-override'} \label{metadata-override}
1619 We don't want to run the usual hooks when the article being processed
1620 is a metadata article or a ``fake'' article. Fake articles appear
1621 when we create fake references that they don't show up in the scholia
1622 display and that aren't permanently attached to anything. See Note
1623 \ref{add-visible-back-temporal-link}.
1625 (At least at one point I had some misgivings about this override, but
1626 it seems to get the job done. I don't see why we would want to have
1627 weird automatic thing happen after creating a metadata article or a
1628 ``fake'' article, so it may be that the design here is perfectly
1629 fine.)
1630 \end{notate}
1632 \begin{lisp}
1633 (defun metadata-override ()
1634 (when (or (typedata-includes type 'meta)
1635 (typedata-includes type 'fake))
1637 \end{lisp}
1639 \subsubsection{Simple scholium derivatives}
1641 \begin{notate}{On `article-names-from-about-data'}
1642 The idea here is to build a list with just the names of the articles
1643 that the \inp{about} data features. Names are uniquified.
1644 \end{notate}
1646 \begin{lisp}
1647 (defun article-names-from-about-data (about)
1648 (delete-dups (mapcar (lambda (elt) (car elt)) about)))
1649 \end{lisp}
1651 \begin{notate}{On `typedata-includes'} \label{typedata-includes}
1652 Read \inp{typedata} in the format used in scholia,
1653 and say whether it matches a \inp{specific-type}.
1654 Notice that when \inp{typedata} and \inp{specific-type} are
1655 both is `nil', we return a positive match.
1656 \end{notate}
1658 \begin{lisp}
1659 (defun typedata-includes (typedata specific-type)
1660 (cond ((eq typedata specific-type) t)
1661 ((and (listp typedata)
1662 (member specific-type typedata)) t)
1663 (t nil)))
1664 \end{lisp}
1666 \begin{notate}{On `typedata-includes-element-of-list'}
1667 Like
1668 `typedata-includes' (Note \ref{typedata-includes}), but only
1669 requires one type out of those listed to match in order to return
1670 `t'.
1671 \end{notate}
1673 \begin{lisp}
1674 (defun typedata-includes-element-of-list (typedata list-of-types)
1675 (let (ret)
1676 (while (and list-of-types
1677 (not ret))
1678 (when (typedata-includes typedata (car list-of-types))
1679 (setq ret t))
1680 (setq list-of-types (cdr list-of-types)))
1681 ret))
1682 \end{lisp}
1684 \begin{notate}{On `typedata-includes-passage'} \label{typedata-includes-passage}
1685 A specific test to see if typedata includes type ``passage'' (noting
1686 that the list element that indicates this type should come together
1687 with some suffix that tells you which passage is being indicated).
1689 As far as I can tell, this function will always apply to typedata
1690 coming from links (but who knows).
1691 \end{notate}
1693 \begin{lisp}
1694 (defun typedata-includes-passage (typedata)
1695 (let (ret)
1696 (when (listp typedata)
1697 (while (and typedata
1698 (not ret))
1699 (when (eq (car (car typedata)) 'passage)
1700 (setq ret (car typedata)))))
1701 ret))
1702 \end{lisp}
1704 \subsubsection{Examples} \label{examples}
1706 \begin{notate}{Examples of the `scholium' function in use}
1707 As an example of how the `scholium' function might be applied, here is
1708 a scholium about the article I'm writing now.
1709 \begin{idea}
1710 (scholium "Remark On Scholium Definition"
1711 "This is an Emacs Lisp function."
1712 '(((passage "sbdm4cbpp.tex" 49078 49738))))
1713 \end{idea}
1714 Actually, the article that I'm writing right now won't be in the
1715 article list unless we explicitly put it there. So the scholium
1716 that we added here is actually attached to a \emph{fictitious}
1717 article with the name ``sbdm4cbpp.tex''. That's OK, but for
1718 completeness, I'll add the current buffer as a scholium with the
1719 appropriate name:
1720 \begin{idea}
1721 (scholium "sbdm4cbpp.tex"
1722 (current-buffer))
1723 \end{idea}
1724 Notice that we've supplied a buffer instead of a string for the
1725 \inp{text} field. We now add another scholium, attached to the
1726 previous two, communicating to the user a fact that the system already
1727 knows:
1728 \begin{idea}
1729 (scholium "This is a scholium about part of the SBDM document"
1730 "This scholium is attached to this region."
1731 '(((article "Remark On Scholium Definition"))
1732 ((passage "sbdm4cbpp.tex" 31091 31744))))
1733 \end{idea}
1734 By setting the \inp{type} data appropriately, we might make this last
1735 example display when ``Remark On Scholium Definition'' is displayed,
1736 but not when ``sbdm4cbpp.tex'' is displayed. It might make sense to
1737 mark up the words ``this region'' with a reference to
1738 ``sbdm4cbpp.tex''. Tricky things like this will be coming in later
1739 sections.
1740 \end{notate}
1742 \begin{notate}{Mixed scholia} \label{mixed-scholia}
1743 Designing functions to build increasingly complicated \inp{about}
1744 structures easily seems to become increasingly challenging.
1745 \end{notate}
1747 \begin{notate}{Types of text} \label{types-of-text}
1748 There could be other kinds of ``text'' that one might want to be able
1749 to use -- symbols, processes, web pages, etc.; basically, any sort of
1750 information-containing thing could be something that one would wish to
1751 add to the scholium system. In addition, plain-text scholia can be
1752 miniature database entries (in some label) if they are given a
1753 specific \inp{type}. For example, a function object might have a
1754 \emph{descriptive note}, a \emph{doc string}, and a \emph{definition}.
1755 Lists are another example of a special plain-text article
1756 (see Note \ref{semantics-of-lists}).
1757 \end{notate}
1759 \subsubsection{Further notes on creating scholia}
1761 \begin{notate}{The division of scholia into pieces}
1762 The division is somewhat arbitrary. Ownership could certainly be
1763 maintained separately from edit history; however, it makes some sense
1764 to set access controls when the article is first saved. Things can
1765 get complicated if different persons or groups have different
1766 permissions; e.g. some may be able to change the access control list
1767 and some may not.
1768 \end{notate}
1770 \begin{notate}{Completeness of the scholium function's arguments}
1771 I think I've basically covered everything I'd be interested in with
1772 these freeform types. The idea is that you can put whatever you want
1773 into these fields, and then write whatever sort of accessor functions
1774 you like to use that information! However, if someone wanted to add
1775 some new fields, this would be easy; they would only have to change
1776 the scholium function and the add-props function.
1777 \end{notate}
1779 \begin{notate}{How to assert that a relationship exists}
1780 The \emph{relationship between} different articles presumably has to
1781 be added with scholia that point to both articles and say something
1782 special about them in the ``type'' field. On the other hand, it would
1783 be useful to have that particular \inp{type} be read both ways, so
1784 that scholia about both the high-level document and lower-level
1785 document explain the relationship of the two documents to one another.
1786 (I think backlink registries would help with this.) We'll talk more
1787 about how to actually assert relationships between articles in Section
1788 \ref{editing}.
1789 \end{notate}
1791 \begin{notate}{Freedom to create derivative versions}
1792 In general, this can be specified in the bookkeeping information -
1793 i.e., the licensing terms (or royalty terms or whatever). For just
1794 about any article, it is important to be able to track derivatives!
1795 The insistance on tracking makes our system not so different from
1796 ``regular'' version management.
1797 \end{notate}
1799 \begin{notate}{Types and modes}
1800 Oftentimes, articles are not so different from buffers. Type data is
1801 a way of specifying things like filetype or editing mode. (Maybe a
1802 bit more general, because articles need not be very buffer-like.)
1803 \end{notate}
1805 \begin{notate}{Extended access}
1806 It might be a good idea to let \inp{about} be filled by a
1807 \emph{function} that will select a sequence of character positions?
1808 Well, I suppose that even if the capability isn't explicitly coded
1809 into the system, people can write their own code that does the job
1810 (expands such functions before calling `scholium')?
1812 Alternatively, if we had sub-libraries in this library, such
1813 a function might be more complicated. It would be worth thinking
1814 about examples of how this sort of thing might be used, exactly.
1816 Of course, if the library contains heterogeneous materials, like the
1817 case that is being discussed in the ``superimposed information''
1818 articles; there, selecting a region may mean different things for
1819 different articles. It seems like the case of Word docs and PDFs is
1820 simpler than the case of whole libraries (e.g. filesets?) but I'd need
1821 to think more about the issues here to come up with good examples. In
1822 which case would one rather add a library than all of the documents?
1823 (Probably there are some cases.) Well, I guess the GCIDE example that
1824 I talked about could be relevant here, although the idea of this GCIDE
1825 thing isn't quite the same as the usual web-like ``scholium thing''
1826 we're considering elsewhere in this work. Also, one might think of
1827 Google or whatever as being a ``library'' that you have to interact
1828 with in a special way to get at the documents -- the reasons for not
1829 adding them are that they aren't free (for one thing) and there are
1830 just too many of them (for another!).
1832 Of course, scholia for really ``weirdly'' formatted documents --
1833 including very rich things, like pictures or videos -- may have very
1834 different sorts of semantics. Its nice of the people who are working
1835 on this ``superimposed information'' stuff to invest time and energy
1836 into this sort of thing, but my own feeling is that its important to
1837 get some good, working, deployments for text-based document
1838 collections going asap!
1839 \end{notate}
1841 \begin{notate}{Type creation} \label{type-creation}
1842 The AI issue relates to the issue of type creation. We should be
1843 talking about the relationship of semantic net ideas (an up-to-date
1844 reference on semantic nets would be helpful; maybe SNePs).
1845 \end{notate}
1847 \begin{notate}{Formulaic scholia} \label{formulaic}
1848 One obvious sort of type is the \emph{form}, i.e., an object with
1849 certain fields to be filled in. Compare
1850 HyperCard\footnote{{\tt http://en.wikipedia.org/wiki/Hypercard}}; more
1851 interesting ideas can be gotten there too, I think.
1852 \end{notate}
1854 \begin{notate}{Transformative scholia} \label{transformative}
1855 It is interesting to think of transformative scholia; attachments that
1856 change the way a given source looks. This is a topic that has
1857 recently been getting some play in the web browser community. Simply
1858 being able to annotate web pages would be swell, because then you
1859 could search through them as if they were part of your own local web,
1860 which, in fact, they probably would be.
1861 \end{notate}
1863 \begin{notate}{Functional scholia} \label{functional}
1864 Functional scholia are similar to (and generalize) the transformative
1865 scholia of Note \ref{transformative}. Reimplementing LISP inside the
1866 scholium system would be an example of this sort of thing; functions
1867 and variables as nodes in a web, programs as clusters of nodes that
1868 have been linked together in certain ways. One way this might be done
1869 would be to use the ordered \inp{about} list as an argument list for a
1870 function and put the function itself on either the \inp{type} field
1871 or, more likely, the \inp{text} field (a specification of the expected
1872 arguments would go on the \inp{type} field). Perhaps something like
1873 this could be used to build documentation for LISP functions
1874 automatically; needless to say, anything we can do scholia-wise can be
1875 done LISP-wise (reasoning by set-inclusion, if nothing else), however
1876 there may be some advantages to thinking about code scholiumifically.
1877 (Functions and their subroutines can easily be regarded as forming a
1878 network, and so, code can easily be thought of as a scholium-based
1879 document under this arrangement.)
1880 \end{notate}
1882 \begin{notate}{Interactive and actionable scholia} \label{interactive-and-actionable-scholia}
1883 One of the big goals for the system is to be able to write MUD-like
1884 programs and text-based games; to do this we need, \emph{interactive}
1885 scholia. More generally, scholia that do something e.g. when browsed
1886 or when encountered by a given process; we call elements of this
1887 broader category \emph{actionable} scholia.
1888 \end{notate}
1890 \begin{notate}{Simulating features from single-buffer editing}
1891 In Note \ref{functional}, we mentioned a certain feature that should be
1892 replicated in the scholium system to make it more useful
1893 (`get-function'); however, some systematic study of the features that
1894 are useful from single-buffer editing should be made, and those
1895 features re-implemented for the scholium system.
1896 \end{notate}
1898 \begin{notate}{Handling functions}
1899 A simple feature request somewhat related Note \ref{functional} is
1900 that we should be able to jump to the scholium associated with a
1901 certain function's name; the analogue of my `get-function' command.
1902 The text that documents a certain function should also show up as a
1903 docstring when one runs `describe-function' in Emacs.
1904 \end{notate}
1906 \subsection{Metadata} \label{metadata}
1908 \subsubsection{Metadata articles} \label{metadata-articles}
1910 \begin{notate}{Metadata article overview} \label{metadata-article-overview}
1911 Metadata articles constitute a merger between ``local'' and
1912 ``holographic'' data storage (Note \ref{holographic-data-storage}).
1913 Metadata articles are essentially local, but they are used to maintain
1914 information about data drawn from all over (in particular, backlinks
1915 are recorded on metadata articles). A metadata article is always
1916 attached to some other article, and is used to record \emph{common}
1917 information about this article. They are updated automatically when
1918 certain editing events take place. When an article is rendered,
1919 certain fields in the metadata article can take precedence over
1920 corresponding information in the article itself (see Note
1921 \ref{updating-link-extent}).
1922 \end{notate}
1924 \begin{notate}{Metadata article design} \label{metadata-article-design}
1925 We exploit the facts that articles (a) have unique names, (b) any LISP
1926 object can be the name of an article, to produce the rule that any
1927 \emph{non}-metadata article with \inp{name} \emph{name} to which we
1928 need to associate a metadata article will have a metadata article
1929 named ``(meta \emph{name})''. The \inp{text} of this article is the
1930 metadata associated with the base article; its format is that of a
1931 list of lists, with each sub-list headed by a tag describing the
1932 contents of that sub-list (e.g. \emph{backlinks}). Metadata articles
1933 are not considered to be \inp{about} anything; we get the picture by
1934 looking at the article's \inp{name}. (They may however contain
1935 updated \inp{about} information for the article they are ``meta'' to;
1936 see Note \ref{updating-link-extent}.) Also, for now at least, we give
1937 them only very minimal \inp{bookkeeping} information.
1939 A ``metadata'' label is maintained that allows us to easily keep track
1940 of the collection of metadata articles (see Note
1941 \ref{on-modified-type-labeler-etc}, \emph{et seq.}).
1943 This design makes it easy to set metadata ``fields'' with `assoc' and
1944 `setcdr'; see Note \ref{put-metadata-field}.
1946 (It would be good to say a bit more about the different fields that
1947 are stored in metadata articles here.)
1948 \end{notate}
1950 \begin{notate}{Maybe phasing out use of pseudo-namespace}
1951 So far we've been able to ``afford'' the use of a pseudo-namespace for
1952 metadata articles. However, we may need to use a more legitimate
1953 approach at some point. We'll look at this issue again if it ever
1954 seems important.
1955 \end{notate}
1957 \begin{notate}{On `metadata-article-name-p'}
1958 So, like I said, we're losing some generality in the
1959 set of available names by doing things the way we've been doing it.
1960 \end{notate}
1962 \begin{lisp}
1963 (defun metadata-article-name-p (name)
1964 (when (and (listp name)
1965 (eq (car name) 'meta))
1968 (defun base-name-from-metadata-name (name)
1969 (second name))
1970 \end{lisp}
1972 \begin{notate}{On `metadata-article'}
1973 This function retrieves the metadata article associated with the
1974 article named \inp{name}.
1975 \end{notate}
1977 \begin{lisp}
1978 (defun metadata-article (name)
1979 (get-article (list 'meta name)))
1980 \end{lisp}
1982 \begin{notate}{On `put-metadata-field'} \label{put-metadata-field}
1983 This can be can be used to fill a metadata \inp{field} with the given
1984 \inp{value}, in the metadata article pertaining to the article named
1985 \inp{name}. If the field has not yet been set, it is created anew
1986 with the appropriate \inp{value}.
1987 \end{notate}
1989 \begin{lisp}
1990 (defun put-metadata-field (field value name)
1991 (let* ((metadata (metadata-article name))
1992 (old-value (assoc field (scholium-text metadata)))
1993 new-text)
1994 (if old-value
1995 (setq new-text (progn (setcdr old-value value)
1996 (scholium-text metadata)))
1997 (setq new-text `((,field . ,value))))
1998 (scholium (list 'meta name)
1999 new-text
2001 'meta
2002 'system)))
2003 \end{lisp}
2005 \begin{notate}{On `get-metadata-field'}
2006 This can be used to retrieve any particular metadata \inp{field}
2007 pertaining to the article named \inp{name}.
2008 \end{notate}
2010 \begin{lisp}
2011 (defun get-metadata-field (field name)
2012 (cdr (assoc field (scholium-text (metadata-article name)))))
2013 \end{lisp}
2015 \begin{notate}{Similarity between metadata and text properties}
2016 It makes some sense that metadata about articles and metadata
2017 about characters would be treated somewhat similarly. Anyway,
2018 the similar idioms seem to arise.
2019 \end{notate}
2021 \begin{notate}{Updating link extent} \label{updating-link-extent}
2022 If an article $A$ is a scholium attached to some other article $B$,
2023 and $B$'s \inp{text} is edited, then $A$'s \inp{about} data, if taken
2024 literally, may be quite inaccurate. The solution to this problem is
2025 to examine the text properties indicating which regions of $B$ $A$ is
2026 \emph{supposed to be} \inp{about}, and store the updated information
2027 where it will be useful: $A$'s metadata article ``(meta $A$)''. The
2028 information stored in (meta $A$) ``masks'' individual links; see Note
2029 \ref{masks} for more information.
2030 \end{notate}
2032 \begin{notate}{Updated `about' fields in the distributed case} \label{updating-link-extent--distributed-case}
2033 In the distributed case, it would probably be best to use the metadata
2034 pertinent to the current checked-out instance. To facilitate this,
2035 contributed \inp{about} data should probably be stored together with
2036 the id of its source. We're not quite there yet, but hopefully soon
2037 will be! (See also Note \ref{conflicts-in-a-distributed-environment}
2038 \end{notate}
2040 \subsubsection{Backlinks (who links here?)} \label{backlinks-section}
2042 \begin{notate}{Theory of backlinks} \label{backlinks}
2043 One particularly interesting sort of object is the ``backlink''.
2044 These complement the generalized links discussed in Note
2045 \ref{generalized-links}, and they play a fundamental role in the
2046 system. Backlinks make some operations faster (compare Note
2047 \ref{name-or-access-buffered-articles}).
2049 Unlike regular links, which live in articles, an article's backlinks
2050 live in its ``public'' metadata article. See
2051 \ref{overview-of-linking-process} for further information on the
2052 lifecycle of a backlink.
2054 See Note \ref{backlink-tricks} for a description of tricks that can be
2055 done with backlinks. Its worth mentioning that backlinks not seen in
2056 the typical display, but they could be used in special displays (see
2057 Note \ref{ancestors}). Backlinks are going to be important for AI
2058 applications; they provide the information a given node needs to
2059 ``know'' its context within the broader semantic network.
2061 Note that Howm is an already existing Emacs package for both forward
2062 (``goto'') and backward (``come-from'') linking\footnote{{\tt
2063 http://howm.sourceforge.jp/}}. The behavior of Howm's come-from
2064 links is somewhat different from the backlinking features implemented
2065 in the scholium system, but it shouldn't be too hard to add Howm-like
2066 features (see Section \ref{otf} for some words on how we might
2067 approach this).
2069 (This note should probably just state the definition of backlinks;
2070 anyway, as it is it seems to vague and too long.)
2071 \end{notate}
2073 \begin{notate}{Implementation of backlinks} \label{implementation-of-backlinks}
2074 Whereas links are typed (Note \ref{links}), backlinks are not.
2075 Insteady, backlinks indicate an article and a certain link in that
2076 article. The backlink data is useful because it allows us to easily
2077 figure out which articles link to a given article (without doing any
2078 mapping). The basic use of backlink data is to display an article
2079 together with its scholia.
2081 We had considered using typed backlinks (mirroring the type of the
2082 link that each backlink corresponds to), but this seemed excessive,
2083 since the corresponding information can easily be found by examining
2084 the link corresponding to a given backlink.
2085 \end{notate}
2087 \begin{notate}{Overview of linking process} \label{overview-of-linking-process}
2088 When \inp{about} data is created or modified, `put-backlinks' is
2089 called to update the backlinks in the metadata articles associated
2090 with the \emph{linked-to} articles. A backlink points at the specific
2091 link that it corresponds to, by way of the \emph{linking} article and
2092 the unique \emph{link number} that identifies the corresponding link.
2093 \end{notate}
2095 \begin{notate}{On `delete-backlink'} \label{delete-backlink}
2096 This function is called by `put-backlinks' to prune away an old
2097 backlink.
2099 Also notice that in this function, we know that some
2100 metadata and backlinks already exist, so in particular the
2101 `metafield' exists. Hence we don't need the complicated
2102 conditions found in the `add-backlink' function.
2104 (I don't suppose we actually need to delete the ``backlink'' field
2105 in the case in which we delete the last backlink.)
2106 \end{notate}
2108 \begin{lisp}
2109 (defun delete-backlink (linked-to-article link-number)
2110 (let* ((metaarticle (metadata-article linked-to-article))
2111 (metatext (scholium-text metaarticle))
2112 (metafield (assoc 'backlinks metatext))
2113 (backlinks (remove (list name link-number)
2114 (cdr metafield))))
2115 (setcdr metafield backlinks)
2116 (scholium (list 'meta linked-to-article)
2117 metatext
2119 'meta
2120 'system)))
2121 \end{lisp}
2123 \begin{notate}{On `add-backlink'} \label{add-backlink}
2124 This function is called by `put-backlinks' to add a new backlink.
2126 Note that the relevant metadata article may not exist prior to the
2127 time this function runs and even if it exists, it may not contain any
2128 backlink data. So we have to run the relevant tests to deal with
2129 these cases. This accounts for differences between the implementation
2130 of `add-backlink' and `delete-backlink' (Note \ref{delete-backlink}).
2131 \end{notate}
2133 \begin{lisp}
2134 (defun add-backlink (linked-to-article link-number)
2135 (let* ((metaarticle (metadata-article linked-to-article))
2136 (metatext (scholium-text metaarticle))
2137 (metafield (assoc 'backlinks metatext))
2138 (backlinks (add-to-or-start-list
2139 (cdr metafield)
2140 (list name link-number))))
2141 (cond
2142 (metafield
2143 (setcdr metafield backlinks))
2144 (metatext
2145 (setcdr metatext
2146 `(((backlinks . ,backlinks)))))
2148 (setq metatext
2149 `((backlinks . ,backlinks)))))
2150 (scholium (list 'meta linked-to-article)
2151 metatext
2153 'meta
2154 'system)))
2155 \end{lisp}
2157 \begin{notate}{On `put-backlinks'} \label{put-backlinks}
2158 The basic use for this function is to run it within the scope of the
2159 `scholium' function, to build and store new (or updated) backlink
2160 data. Backlinks are added to each of the metadata articles
2161 corresponding to articles that this article is \inp{about}.
2163 The algorithm used here (zap \emph{all} existing backlinks, then place
2164 \emph{all} new backlinks) seems likely to be woefully inefficient! If
2165 so, this can be improved later.
2167 Notice that we don't take into account \inp{name} changes with this
2168 function (there is no relevant ``old-name'' variable, at least, not at
2169 present).
2170 \end{notate}
2172 \begin{lisp}
2173 (defun put-backlinks ()
2174 (let ((old-about (scholium-about old-version))
2175 (link-number 0))
2176 (dolist (link old-about)
2177 (setq link-number (1+ link-number))
2178 (delete-backlink (car link) link-number)))
2179 (let ((link-number 0))
2180 (dolist (link about)
2181 (setq link-number (1+ link-number))
2182 (add-backlink (car link) link-number))))
2184 (add-hook 'new-scholium-hook 'put-backlinks)
2185 (add-hook 'scholium-modified-about-hook 'put-backlinks)
2186 \end{lisp}
2188 \begin{notate}{Generality of `put-backlinks'} \label{generality-of-put-backlinks}
2189 The function used to be written in a general way so that it can store
2190 backlinks in different fields. For example, I had set things up to
2191 add to a `derives-to' metadata field when the function
2192 `include-article' ran (see Note \ref{include-article}). However, it
2193 wasn't clear to me that this approach was really useful or necessary.
2195 Nevertheless, storing new or updated mask data has to be done at some
2196 point; and it may be that we'll want a generalized version of
2197 `put-backlinks' after all (perhaps with a better name, speaking to its
2198 new general purpose).
2199 \end{notate}
2201 \begin{notate}{Turning backlinking off on demand sometimes?}
2202 It might be nice to turn backlinking off in certain situations. A
2203 rather silly example is the situation in which you don't want the
2204 owner of a certain object to know that you are talking about it.
2205 There may be some more relevant situations. (Compare the use of fake
2206 links, as documented in Note \ref{metadata-override}).
2207 \end{notate}
2209 \subsection{Consistency conditions} \label{consistency}
2211 \begin{notate}{Why we maintain consistency} \label{consistency-why}
2212 This discussion might go into Section \ref{philosophy} or Section
2213 \ref{mathematics}, but given that it is fairly foundational for the
2214 system, it is worthwhile to at least include an overview early on.
2216 When something changes in the system -- whether it is the addition of
2217 an article, or the deletion of an article, or edits to an article --
2218 very often the effects are not purely local; or at least, they
2219 shouldn't be. Someone may want to know when a certain kind of article
2220 is created. Articles that referred to an article that gets deleted
2221 may want to refer to something else. If an article changes,
2222 references to specific regions of that article may have to be
2223 re-directed or, in some cases, eliminated.
2225 Many of these operations can be taken care of automatically by a
2226 sufficiently powerful hypertext system. Indeed, particularly in the
2227 case of multi-user editing, the consistency conditions (considered as
2228 a very general category) essentially constitute the \emph{social
2229 contract} associated with the work.
2230 \end{notate}
2232 \begin{notate}{When we maintain consistency} \label{consistency-when}
2233 As we mentioned in Note \ref{consistency-why}, in the broadest sense,
2234 we're always maintaining some sort of consistency. But the three
2235 major categories, \emph{adding}, \emph{deleting}, and \emph{editing},
2236 give a nice first-run division of the cases. (There may be some other
2237 situations that will come up, and will not fit immediately into any of
2238 these three groups, e.g. maintaining some state that isn't officially
2239 part of an article per se, but at least ideally, we can decompose the
2240 space this way.)
2242 Sometimes users won't want certain ``weird'' things to happen to their
2243 articles automatically. For example, maybe someone really means to
2244 point at the region between character position 5 and character
2245 position 31 in some particular article, and not to the string that
2246 currently appears in this region at the time when the link is created.
2247 In this case, the person creating the link should say so -- and the
2248 system should be set up to adhere to the reasonable wishes of its
2249 users. In particular, it should be entirely possible for two users to
2250 have vastly different views of the document's contents!
2252 (Notice that in the distributed case, it we may have to adopt somewhat
2253 different notions of consistency; see Section \ref{distributed}.)
2254 \end{notate}
2256 \begin{notate}{Consistency conditions for adding} \label{consistency-adding}
2257 This is a fairly simple case, relatively speaking.
2258 It includes such things as automatic labeling
2259 (cf. Section \ref{labels}) as well as the automatic addition
2260 of backlinks to appropriate articles (Note \ref{put-backlinks}).
2261 \end{notate}
2263 \begin{notate}{Consistency conditions for deleting} \label{consistency-deleting}
2264 The most important feature associated with deletion is to delete or
2265 redirect backlinks. See Section \ref{deletion} for details.
2266 \end{notate}
2268 \begin{notate}{Consistency conditions for editing} \label{consistency-editing}
2269 This is by far the most complicated of the three cases. When an
2270 article is edited, links that point to its various components may have
2271 to be updated. In particular, when an article's \inp{about} data is
2272 edited, anything that pointed at this data must change -- this
2273 includes everything that uses link-id's (Note \ref{link-ids}), i.e.,
2274 backlinks in other articles, masks in the linking article, and markup.
2276 Changes to an article's \inp{text} can have repercussions of similar
2277 complexity, especially when derivative works are taken into account;
2278 see Section \ref{derivative} for details.
2279 \end{notate}
2281 \subsection{Subcollections} \label{subcollections}
2283 \subsubsection{Labels} \label{labels}
2285 \begin{notate}{Cost of maintaining labels} \label{cost-of-maintaining-labels}
2286 To maintain a label, we have to do predicate testing as we go along.
2287 This is a way of amortizing the cost of lookup. (An example would be
2288 nice, I'm sure.) The thought is that some overall savings can be
2289 obtained this way -- but in general they don't come automatically; we
2290 have to be intelligent about limiting the tests we run (at least, I
2291 don't think we get savings for free by doing things this way). For
2292 example, we don't add backlinks to metadata articles -- but there
2293 should be other intelligent things to do too. Another idea in a
2294 similar theme is to have several functions for creating different
2295 kinds of articles; these functions can instructions for applying
2296 certain labels hard-coded into them.
2297 \end{notate}
2299 \begin{notate}{Labels as made up of trivial clusions}
2300 Given that the design of labels stores a list of link-like elements in
2301 the \inp{text} field of a article, and the fact that we would like to
2302 have backlinks from the labeled articles to the label itself (Note
2303 \ref{autobacklink-to-label}), it would appear to me that labels are
2304 somewhat like trivial clusions (Note \ref{clusions}). Assuming that
2305 we are going to go ahead with the backlinking from labeled articles
2306 (which seems to be useful when we think about exploring or exporting a
2307 hierarchy), then we may want to treat labels in the same way we treat
2308 clusions, or alternatively, switch to putting their contents onto the
2309 \inp{about} field instead.
2310 \end{notate}
2312 \begin{notate}{Comparison with labels in other systems} \label{comparison-with-other-label-systems}
2313 Various folksonomy-oriented environments allow people to use labels.
2314 The usage in these systems is certainly similar to usage in Arxana,
2315 however, I'm not completely sure that the ideas are the same. This
2316 would bear further investigation.
2317 \end{notate}
2319 \begin{notate}{Label terminology}
2320 Following on Note \ref{comparison-with-other-label-systems}, it seems
2321 possible that the term ``label'' would be somewhat confusing if the
2322 label was thought of as a set, and not a list. So to be clear, what
2323 we really are doing is keeping track of various things on separate
2324 lists. (This is relevant e.g. for `label-article-insert-before', Note
2325 \ref{label-article-insert-before}).
2326 \end{notate}
2328 \begin{notate}{On `modified-type-labels'} \label{on-modified-type-labeler-etc}
2329 An alist of types to look for paired with the corresponding label to
2330 apply. Each new or modified article is tested to see if it matches
2331 any of the given types; if so, then the corresponding label(s) will be
2332 applied. (Note that the ``label'' label is not treated specially.)
2333 \end{notate}
2335 \begin{lisp}
2336 (defvar modified-type-labels '((nil . plain)
2337 (label . label)
2338 (meta . metadata)
2339 (list . list)
2340 (reference . reference)
2341 (section . section)))
2342 \end{lisp}
2344 \begin{notate}{On `label-article'} \label{label-article}
2345 This function is responsible for the mechanics of editing labels, and
2346 creates them as needed.
2347 \end{notate}
2349 \begin{lisp}
2350 (defun label-article (name article-label)
2351 (scholium article-label
2352 (add-to-or-start-list (scholium-text
2353 (get-article article-label))
2354 name)
2356 'label))
2357 \end{lisp}
2359 \begin{notate}{On `label-article-insert-before'} \label{label-article-insert-before}
2360 Like `label-article' (Note \ref{label-article}), but takes an
2361 additional argument \inp{before-this} to say which entry the new name
2362 should be inserted just before.
2363 \end{notate}
2365 \begin{lisp}
2366 (defun label-article-insert-before (name before-this article-label)
2367 (let* ((contents (scholium-text (get-article article-label)))
2368 (before-this-headed (member before-this contents)))
2369 (when before-this-headed
2370 (let ((len (- (length contents)
2371 (length before-this-headed)
2372 1)))
2373 (if (> len -1)
2374 (setcdr (nthcdr len contents)
2375 (cons name before-this-headed))
2376 (setq contents (cons name before-this-headed))))
2377 (scholium article-label
2378 contents
2380 'label))))
2381 \end{lisp}
2383 \begin{notate}{On `put-type-labels'}
2384 This function runs within the scope of `scholium'. It might make more
2385 sense to be able to add lots of different labels for a new article;
2386 the `cond' function doesn't work that way however.
2387 \end{notate}
2389 \begin{lisp}
2390 (defun put-type-labels ()
2391 (dolist (type-label modified-type-labels)
2392 (when (typedata-includes type (car type-label))
2393 (label-article name (cdr type-label)))))
2395 (add-hook 'new-scholium-hook 'put-type-labels)
2396 (add-hook 'scholium-modified-type-hook 'put-type-labels)
2397 \end{lisp}
2399 \begin{notate}{Generalizations of the autolabeler}
2400 At the basic level, what we want is a way to maintain a list of
2401 predicates, such that any scholium that satisfies a given predicate
2402 gets the corresponding label. We could maintain several such lists,
2403 but it is (theoretically) important to be general, and the design
2404 should be evaluated to determine how easy it is to add new predicates
2405 and labels.
2406 \end{notate}
2408 \begin{notate}{Could take subcollection as optional argument}
2409 In general, the functions that operate on all articles should probably
2410 take a subcollection as an optional argument. This might be a
2411 namespace, or a label, or a list that has been assembled by some novel
2412 means. Some of our functions already have something like this
2413 working, but it hasn't really been standardized in any way.
2414 \end{notate}
2416 \subsubsection{Namespaces} \label{namespaces}
2418 \begin{notate}{Namespace implementation}
2419 Namespaces have to be implemented in a nicely self-similar way.
2420 Whereas an article can bear any number of labels, it can be only in
2421 one namespace at a time. (Since namespaces can be nested, we might
2422 have $A\sqsupset B \ni a$, so that the article $a$ isn't a member of
2423 $A$, but \emph{limiting} a recursive search to $A$ would still help
2424 one to find $a$.)
2426 Actually, namespaces are a lot like the filesystem, so I can imagine
2427 that we might provide the ability to symlink elements from one
2428 namespace into another (similar to textual \emph{identification}, see
2429 Section \ref{identification}). So maybe best to take what I said
2430 about only being in one namespace at a time with a grain of salt.
2431 What is probably the case is that the object \emph{will} only be in
2432 one namespace at a time, but that it can have ``virtual copies'' in
2433 other namespaces.
2435 If we go this route then we have two things to implement, roughly
2436 self-similar namespaces themselves, and a method for doing
2437 identification between them. I hope we can follow (in one direction
2438 or another) the implementation of \emph{labels}; we'll check that out
2439 now.
2441 The first step will probably be to make a namespace article-type, with
2442 a specially formatted text field (a list or table), which is to be
2443 displayed in a special way. We'll most likely want a variant on
2444 `read-article-name' that recurs if the name that is read in names a
2445 namespace.
2447 Display and deletion will both have to have some work done on them to
2448 make them namespace-compatible.
2449 \end{notate}
2451 \begin{notate}{Why namespaces} \label{why-namespaces}
2452 Frequently one will be working with a data structure which has some
2453 symmetries that you don't want to collapse. For example, you might
2454 have a \emph{Note} and a \emph{Section} with the same name in a given
2455 article. Or you might have several sections with the same name in
2456 several different articles. Or you might be working with a database
2457 like structure in which every item has a \emph{foo}-type attachment,
2458 and you want these to be represented as different scholia, not
2459 \emph{one} scholium with type \emph{foo}. Furthermore even in cases
2460 where you aren't expecting overlap, it might be handy to keep
2461 different collections strongly separated from each other. (E.g. if
2462 you have a bunch of articles coming from one resource and a bunch of
2463 very different articles coming from another resource.) In this case,
2464 it is probably often just as good to use labels and keep the different
2465 collections only weakly separated -- indeed, when there isn't overlap
2466 in names, a sufficiently well-developed system for working with labels
2467 will probably give you everything that you would have wanted from a
2468 system with namespaces. Be that as it may, overlap is prevalent
2469 enough to make namespaces useful. (Another approach to overlap is
2470 \emph{disambiguation}, which is what Wikipedia uses; but having to use
2471 different names all the time when disambiguating could get very
2472 tedious.)
2473 \end{notate}
2475 \begin{notate}{Using namespaces for importing}
2476 In Note \ref{why-namespaces}, we mentioned that namespaces could be
2477 useful when working with several articles with similar structure.
2478 Underscoring that point, it seems we may typically want to use
2479 namespaces when importing any secondary documents into the scholium
2480 system (e.g. the HDM Manifesto or Noosphere's documentation). They
2481 may also be useful for articles that are stored remotely (e.g. we
2482 might maintain one or more ``web'' namespaces).
2485 \end{notate}
2487 \begin{notate}{Maintain the `label' article as a namespace?}
2488 As one example, it might be advantageous to maintain the `label'
2489 article as a namespace!
2490 \end{notate}
2492 \begin{notate}{On `generalized-put-article'} \label{generalized-put-article}
2493 Like `put-article' (Note \ref{put-article}), but you specify
2494 a \inp{path} as well as a \inp{name}. The \inp{path}
2495 should specify the path to the namespace wherein
2496 the \inp{name}, \inp{value} pair is to be stored.
2497 \end{notate}
2499 \begin{lisp}
2500 (defun generalized-put-article (path name value)
2501 (puthash name value (generalized-get-article path)))
2502 \end{lisp}
2504 \begin{notate}{On `generalized-get-article'} \label{generalized-get-article}
2505 Like `get-article' but takes a \inp{path}. The path specifies a list
2506 of nested namespaces, and possibly, a final non-namespace item to be
2507 found in the last namespace. Optional argument \inp{current} keeps
2508 track of the ``current'' namespace as the path is digested. If only
2509 one item appears in the path and \inp{namespace} isn't given, the path
2510 points to an item in the main article table, and we return the
2511 corresponding item.
2513 Be advised that there is a little bit of potentially destructive
2514 ambiguity here. But to make up for it, notice the doubly-clever use
2515 of `and' and `cond' (to deal with the case that we're generalizing).
2516 \end{notate}
2518 \begin{lisp}
2519 (defun generalized-get-article (path &optional current)
2520 (let ((first-step (get-article path)))
2521 (cond
2522 ((and (not current) first-step)
2523 first-step)
2524 ((cdr path)
2525 (if (typedata-includes (get-article (car path)) 'namespace)
2526 (generalized-get-article (cdr path) (car path))
2527 (error "Path element not a namespace")))
2528 ((and (car path) current)
2529 (gethash current (car path)))
2530 ((car path) (get-article (car path))))))
2531 \end{lisp}
2533 \begin{notate}{Self-symmetry}
2534 If we're going to have a set-up where things look roughly the same on
2535 every level, for one thing, we may going to want to have a ``current
2536 path'' variable, so we can move from level to level and populate that
2537 level properly.
2539 We may want to have a different class of labels at every level in the
2540 hierarchy. Whether we could also have labels that reach across levels
2541 is another question. And as for metadata articles, should they be
2542 stored in the top level or should they be stored in the same namespace
2543 as the article that they apply to? Storing them in the same namespace
2544 \emph{sounds} good (it seems ``more distributed''), however remember
2545 that it may not always be possible to access a given namespace to
2546 store metadata. Perhaps the best option is to mirror whatever
2547 distributed resources one draws upon in the local implementation; then
2548 storing metadata in the namespace local to the article being treated
2549 would make some sense. Or we could have one single namespace for
2550 metadata articles (I've considered this option before) which would
2551 take data coming from all other namespaces. Seems like an interesting
2552 approach, too. These matters will require more thought.
2554 Notice that with namespaces we're pretty likely to end up repeating
2555 some of the work people have done with file systems. On the other
2556 hand, it is probably possible to use a simplified approach, with a
2557 function to accomplish ``add article to namespace at the end of this
2558 path''; like working with the file system but always from the root
2559 directory. Eventually we can add the convenience functions (really
2560 not that complicated) to prepend a default path to the root. (We seem
2561 to already have the non-interactive elements of this arrangement with
2562 `generalized-put-article' (Note \ref{generalized-put-article}) and
2563 `generalized-get-article' (Note \ref{generalized-get-article}).)
2564 \end{notate}
2566 \subsection{Data access and conversion}
2568 \begin{notate}{Introduction to data access and conversion}
2569 The functions in this section give easy access to things we're often
2570 interested in later on. The functions here are simple, but it is
2571 useful to have names for them anyway (Note
2572 \ref{principle-of-transparency}).
2573 \end{notate}
2575 \begin{lisp}
2576 (defun label-to-list (label)
2577 (mapcar (lambda (name)
2578 (format "%s" name))
2579 (scholium-text (get-article label))))
2581 (defun label-to-propertized-list (label)
2582 (mapcar (lambda (name)
2583 (propertize (format "%s" name) 'name name))
2584 (scholium-text (get-article label))))
2585 \end{lisp}
2587 \begin{notate}{On `get-backlinks'} \label{get-backlinks}
2588 This code produces the backlinks associated with \inp{name}. See Note
2589 \ref{implementation-of-backlinks} for details. Notice that throughout
2590 the code I have been applying this idiom
2591 \begin{idea}
2592 (lambda (backlink)
2593 (get-article (car backlink)))
2594 \end{idea}
2595 to the element of the returned list in order to come up with the names
2596 of the backlinked articles. However, I recently converted the
2597 backlink format to be richer than it was before so that we knew
2598 \emph{which link} was doing the linking, not just which article. So
2599 presumably we should be using this additional data at least some of
2600 the time.
2601 \end{notate}
2603 \begin{lisp}
2604 (defun get-backlinks (name)
2605 (get-metadata-field 'backlinks name))
2607 (defun get-links (name)
2608 (cdr (assoc 'links (scholium-text (metadata-article name)))))
2609 \end{lisp}
2611 \begin{notate}{On `read-article-name'}
2612 We frequently have to read the name of an article from a list. We may
2613 be able to do this in several different more intelligent ways than the
2614 one we have here! For one thing, we could use
2615 `turn-article-table-into-names' (which see). Another thing to do
2616 would be to allow some other source of input, for example, some
2617 particular namespace could be specified (this might be best handled
2618 with another function, `read-article-name-from-namespace', say). We
2619 could offer some recursion if a namespace is selected.
2620 \end{notate}
2622 \begin{lisp}
2623 (defun read-article-name ()
2624 (let* ((completion-ignore-case t)
2625 (strings (turn-article-table-into-list))
2626 (string-found (completing-read
2627 "Article: "
2628 strings))
2629 (place (- (length strings)
2630 (length (member string-found strings)))))
2631 (nth place (turn-article-table-into-names))))
2632 \end{lisp}
2634 \begin{notate}{On `read-article-path'}
2635 Like `read-article-name' but reads a path to an article through
2636 namespaces (cf. `generalized-get-article', Note
2637 \ref{generalized-get-article}).
2638 \end{notate}
2640 \begin{lisp}
2641 (defun read-article-path (&optional namespace path)
2642 (let* ((completion-ignore-case t)
2643 (strings (if namespace
2644 (turn-namespace-into-list namespace)
2645 (turn-article-table-into-list)))
2646 (string-found (completing-read
2647 "Article: "
2648 strings))
2649 (place (- (length strings)
2650 (length (member string-found strings))))
2651 (ret (nth place (if namespace
2652 (turn-namespace-into-names namespace)
2653 (turn-article-table-into-names)))))
2654 (setq path (append path (list ret)))
2655 (if (and (typedata-includes ret 'namespace)
2656 (y-or-n-p "Read further? "))
2657 (read-article-path namespace path))
2658 path))
2659 \end{lisp}
2661 \begin{notate}{Reading from non-default namespaces} \label{read-from-non-default-namespace}
2662 Perhaps there should be a ``read from this namespace'' variable that
2663 can be swapped for the default in `read-article-name'. This sort of
2664 overload system should probably be used whenever we are reading from a
2665 list of articles (just for example, see Note
2666 \ref{make-reference-in-current-article}).
2668 An alternative perspective on this matter is that it depends on the
2669 behavior of `get-article'. That function is responsible for finding
2670 the article with the given name, regardless of where it resides. So,
2671 `get-article' needs to know where to look. Perhaps `name' will
2672 contain some instructions, or, more likely, perhaps this function
2673 should take an optional argument that would help it to limit the
2674 search.
2675 \end{notate}
2677 \begin{notate}{On `link-about-article-p'} \label{link-about-article-p}
2678 This provides a quick way to tell whether one of the elements of an
2679 \inp{about} list is actually about the article named
2680 \inp{article-name}.
2681 \end{notate}
2683 \begin{lisp}
2684 (defun link-about-article-p (link article-name)
2685 (equal (linked-to-article link) article-name))
2686 \end{lisp}
2688 \subsection{Further notes on scholia-based documents}
2690 \begin{notate}{Following the design of metadata articles to make namespaces?} \label{metadata-design-for-namespaces}
2691 Note that we could in theory follow a similar pattern with the meta
2692 prefix to make additional ``namespaces'', i.e., the article ``(foo
2693 \emph{bar})'' would be the article named ``bar'' within the namespace
2694 ``foo''. We would maintain a label on these articles, as with the
2695 ``metadata'' label. But it seems more desirable to create a namespace
2696 \inp{type}, elements of which would have the property that they could
2697 contain articles which aren't elements of the main article list.
2698 \end{notate}
2700 \begin{notate}{Design of real namespaces}
2701 We currently only have one real ``namespace'' (see Note
2702 \ref{metadata-design-for-namespaces} for a way to create a fake
2703 namespace). A real namespace would probably have a list or a hash
2704 table in the \inp{text} field and a ``namespace'' token into the
2705 \inp{type} field.
2706 \end{notate}
2708 \begin{notate}{Namespace narration}
2709 Presumably a lot of verbose discussion of namespaces can be trimmed
2710 away when we actually have an implementation.
2711 \end{notate}
2713 \begin{notate}{Finding namespaces by searching the namespace hierarchy}
2714 We should sometimes be able to find namespaces, by searching through
2715 the namespace hierarchy for their name. (I think I may have recently
2716 seen an Emacs package posted to gnu.emacs.sources for doing something
2717 similar with directories or files.)
2718 \end{notate}
2720 \begin{notate}{Versioned backlinks?}
2721 Note that backlinks are outside of the editorial control of the person
2722 whose article is being linked to. Nonetheless, it may be handy to
2723 maintain versioned backlink repositories, possibly to correspond to
2724 different versions of linked-to and the linked-from articles (this
2725 could be very complicated).
2726 \end{notate}
2728 \begin{notate}{Holographic data} \label{holographic-data}
2729 There are a number of different strategies for working with
2730 ``holographic data'', i.e., data that represents a document but that
2731 contains different bits and pieces all over, which must be assembled
2732 to construct any particular view into the document. Some of these
2733 strategies involve maintenance of datastructures and some involve
2734 search. (See Note \ref{holographic-data-storage} for some further
2735 comments.) For a pictoral illustration of something vaguely similar,
2736 check out `animate-string'.
2737 \end{notate}
2739 \begin{notate}{Simulating a unified catalog using many namespaces} \label{namespaces-vs-catalogs}
2740 The argument for namespaces says that we could simulate a full catalog
2741 by having functions that trace through all of the namespaces and
2742 gather all of the articles that have been found there.
2743 \end{notate}
2745 \begin{notate}{Are namespaces out-modded by labels?} \label{namespaces-outmodded}
2746 I'm not even sure if we should be using namespaces at all, but one
2747 category of cases that seems to motivate their use that in which you
2748 have objects that contain sub-objects. Namespaces seem like a natural
2749 model, even if we decide never to use them explicitly.
2750 \end{notate}
2752 \begin{notate}{Remote subcollections}
2753 We might want to have one subcolection for each source of articles in
2754 a distributed system. For a built-in web browser, we might also want
2755 to maintain directions for re-loading everything that's been
2756 \emph{downloaded} from the internet, probably as its own subcollection
2757 (with instructions on where to find the articles on disc and
2758 remotely).
2759 \end{notate}
2761 \begin{notate}{Holographic data storage} \label{holographic-data-storage}
2762 This is the idea of a document in which data is stored ``all over'',
2763 and our views into the document get different bits and pieces of this
2764 data. For example, in Table \ref{the-quick-brown-fox}, the string
2765 ``the quick brown fox'' is stored in a somewhat non-intuitive way,
2766 namely, indexed by letter of the alphabet rather than character
2767 position. If we look at a neighborhood of the letter ``o'' (in the
2768 natural metric coming from this index), we might see something like
2769 \begin{center}
2770 ????q???k??ro?n??o?
2771 \end{center}
2772 which gives us some idea of what the document as a whole has to say.
2773 (As would any neighborhood of any element, hence the appellation
2774 ``holographic''.)
2776 Similarly, an article displayed together with its scholia gives a view
2777 into the document it is a part of. In general, its scholia may come
2778 from ``all over''. We use backlinks (Note \ref{backlinks}) to speed
2779 the location of scholia necessary for presenting such views.
2781 (Perhaps something from the theory of labels or something similar can
2782 be used to speed things up too; e.g., I suppose that in addition to
2783 generating this table, we could generate a list of the words in the
2784 text too. Something to think about I guess.)
2786 \begin{table}
2787 \begin{center}
2788 \begin{tabular}{l|l}
2789 {\bf character} & {\bf positions} \\
2790 \hline
2791 spc & 4, 10, 16\\
2792 b & 11\\
2793 c & 8\\
2794 e & 3\\
2795 h & 2\\
2796 i & 7\\
2797 k & 9\\
2798 n & 15\\
2799 o & 13, 18\\
2800 q & 5\\
2801 r & 12\\
2802 t & 1\\
2803 u & 6\\
2804 w & 14\\
2805 x & 19
2806 \end{tabular}
2807 \end{center}
2808 \caption{\label{the-quick-brown-fox}Lexicographic storage for ``the quick brown fox''}
2809 \end{table}
2810 \end{notate}
2812 \begin{notate}{World-writable components versus metadata articles} \label{metadata-article-permissions}
2813 If we're going to maintain a collection of backlinks for each
2814 linked-to article (which seems to be an exceptionally good idea), we
2815 have to decide whether to maintain such a list as a part of the
2816 article itself or as part of some other article (presumably an article
2817 that contains nothing but metadata about the article that we're
2818 working with). This is an aesthetic consideration -- we're interested
2819 in maintaining \emph{ownership} over articles, so for this reason, we
2820 don't want them to contain world-editable components. However, it may
2821 not be so nice to have the article list filled up with system-owned
2822 metadata articles, either. Perhaps this is one case in which it would
2823 be good to use a separate namespace. (It is even conceivable that
2824 users would want different behavior in different circumstances; e.g.
2825 if all the articles are owned by one person, making portions of the
2826 articles ``world-editable'' may not be such a problem.)
2827 \end{notate}
2829 \begin{notate}{Savings afforded by backlinks}
2830 Here we assume that we use metadata articles of Note
2831 \ref{metadata-article-permissions} and that we use a hash table to store the
2832 document. If we maintain a list of backlinks for each article, the
2833 added look-up cost of adding a link is $O(1)$ per linked-to article
2834 (i.e. we need to find the appropriate place to store the backlink
2835 metadatum), and the cost to display an article is $O(1)$ per
2836 linked-from article (i.e. we use the list of backlinks to find each
2837 scholium attached to the article being displayed). On the other hand,
2838 if we don't maintain backlinks, there is no look-up cost associated
2839 with adding a link, but there is a cost of $O(\#\mathrm{Articles})$
2840 associated with document display, since we have to test every article
2841 to see if it is \inp{about} the article being displayed.
2842 \end{notate}
2844 \begin{notate}{Private information}
2845 This is one potential use of namespaces (we could have a public and a
2846 private namespace... though actually this sounds a bit more like
2847 something that we would want to use \emph{labels} for). Privacy is
2848 generally considered to be an important right.
2849 \end{notate}
2851 \begin{notate}{Reading articles into a given namespace}
2852 If a bunch of scholia have been saved to a file, it would be
2853 convenient to have a way to read them all into one specific namespace.
2854 \end{notate}
2856 \begin{notate}{Intelligent search} \label{intelligent-search}
2857 One topic we must concern ourselves with from time to time is the
2858 \emph{scope of propagation}. In a large system, we don't want to have
2859 to look at everything after any given change. Even if we maintain a
2860 list of backlinks (see Note \ref{backlinks}), we might well have to
2861 search through everything in order to find the articles that are
2862 backlinked to! (Which may not be such a bad thing if we use a hash
2863 table.) Another possible solution is to try to search intelligently,
2864 by using namespaces to guide the search. If each backlink tells you
2865 roughly where the corresponding linking article can be found, then you
2866 can recover that article much more efficiently. I'm pretty sure this
2867 relates to the system for IP addressses used on the web and also to
2868 the ``humber'' system used in Xanadu. (The Wikipedia page about the
2869 IP system probably contains important background). See also Note
2870 \ref{metadata-article-overview} for related thoughts on using
2871 namespaces to limit search.
2872 \end{notate}
2874 \begin{notate}{Possible relationship between labels and `type' data}
2875 The \inp{type} field complements \emph{labels}; labels can be applied
2876 by anyone, but type data can only be changed by the object's owner.
2877 When you render an article, you look on its \inp{type} field first to
2878 get the basic type data specified by the author. Then you look at its
2879 metadata article to find backlinks; if any of these backlinks are to
2880 labels, you may find additional rendering information there.
2881 \end{notate}
2883 \begin{notate}{Movable scholia} \label{movable-scholia}
2884 At various places in the lifecycle of a scholium, we'll want it to
2885 move around, either concretely (from one base of attachment to
2886 another) or ephemerally (appearing in some new place while continuing
2887 to be attached in its original location). We already have various
2888 features associated with some of these processes, for example,
2889 transclusion (Section \ref{transclusion}) is about viewing a given
2890 article through some new window. However, we'll want to do more,
2891 e.g., one thing that should be coming soon is the ability to pass
2892 scholia ``through'' a compilation (Section \ref{quick-compilations}).
2893 We'll eventually want to be able to do the reverse as well. In
2894 general, support for the various \emph{concrete} operations
2895 (e.g. passing a scholium through a reference and making it stick) are
2896 lacking at present.
2897 \end{notate}
2899 \section{Adding articles to the digital library} \label{creation}
2901 \begin{notate}{Introduction to adding articles in the digital library}
2902 The code in this section provides various wrappers for the `scholium'
2903 function, making it easy to create scholia. Section \ref{bookkeeping}
2904 details the process of adding appropriate \inp{bookkeeping}
2905 information to new articles; articles created using the functions in
2906 this section have standard \inp{bookkeeping} information added to them
2907 automatically. Section \ref{adding-text} concerns adding scholia
2908 based on already-existing sources of text. Section \ref{interactive}
2909 presents functions that the user would call to create articles in
2910 which the \inp{text} field is filled in by the user.
2912 For \emph{editing} articles that have already been added to the
2913 library, see Section \ref{editing}.
2914 \end{notate}
2916 \begin{notate}{Setting `type' field at creation time}
2917 The user might want to set the \inp{type} field at creation time, not
2918 just \inp{text} and \inp{about} (indeed, we could probably do a better
2919 with \inp{about} in a few places, e.g. throughout Section
2920 \ref{adding-text}). But if it is not provided immediately, \inp{type}
2921 can still be edited in later.
2922 \end{notate}
2924 \subsection{Supplying initial bookkeeping information} \label{bookkeeping}
2926 \begin{notate}{On `sch-book'} \label{sch-book}
2927 Interactive functions that call `scholium' should always provide
2928 \inp{bookkeeping} information.
2930 The following definition can be extended to add any sort of initial
2931 bookkeeping information we might like to maintain. The
2932 \inp{bookkeeping} field will be revised when the article is edited
2933 (see Section \ref{editing}).
2934 \end{notate}
2936 \begin{lisp}
2937 (defun sch-book ()
2938 `((created ,user-login-name ,(current-time-string))))
2939 \end{lisp}
2941 \subsection{Adding text from an existing source} \label{adding-text}
2943 \subsubsection{Adding text from buffers} \label{adding-buffers}
2945 \begin{notate}{On `make-current-buffer-into-article'}
2946 We store the object representing the buffer in the \inp{text} field.
2947 There is no particular reason to set the \inp{type} (at least, one has
2948 yet to appear).
2950 An alternative approach would be to make an article's \inp{text}
2951 reflect the current contents of the buffer (i.e., save the buffer as a
2952 string) -- but we currently don't do this. However, it would probably
2953 be nice to have that option, or even just the option to make a certain
2954 selection into an article.
2955 \end{notate}
2957 \begin{lisp}
2958 (defun make-buffer-into-article (&optional buffer name)
2959 (let* ((buffer (or buffer
2960 (get-buffer (read-buffer
2961 "Buffer: "
2962 (buffer-name
2963 (current-buffer))
2964 t))))
2965 (name (or name
2966 (read-string "Name: "
2969 (buffer-name buffer)))))
2970 (scholium name buffer nil nil (sch-book))))
2972 (defun make-current-buffer-into-article (name)
2973 (interactive (list (read-string
2974 (concat "Name (default "
2975 (buffer-name (current-buffer)) "): ")
2978 (buffer-name (current-buffer)))))
2979 (make-buffer-into-article (current-buffer) name))
2980 \end{lisp}
2982 \begin{notate}{Arbitrary buffer over current buffer?}
2983 We could write `make-buffer-into-article' and
2984 `make-current-buffer-into-article' in such a way that the former
2985 calls the latter and uses `save-excursion'. Both approaches
2986 seem to have the same end result.
2987 \end{notate}
2989 \subsubsection{Adding text from files} \label{adding-files}
2991 \begin{notate}{On `make-file-into-article'}
2992 This function adds a file to the article list. Again, the \inp{text}
2993 field is not filled in with a string representing the text directly,
2994 but rather, with the name of the file that holds the text. A token is
2995 added to the \inp{type} field explaining that this is a file.
2996 \end{notate}
2998 \begin{lisp}
2999 (defun make-file-into-article (path name)
3000 (interactive
3001 (let* ((bufn (buffer-file-name))
3002 (pth (read-file-name
3003 (if bufn
3004 (concat "File (default: " bufn "): ")
3005 (concat "File: "))
3007 (if bufn
3008 bufn
3009 (default-directory))))
3010 (dnme (file-name-nondirectory pth))
3011 (nme (read-string (concat "Name (default: " dnme "): ")
3014 dnme)))
3015 (list pth nme)))
3016 (scholium name path nil '(file) (sch-book)))
3017 \end{lisp}
3019 \subsection{Interactively supplying text} \label{interactive}
3021 \begin{notate}{Global varibles describing new scholia}
3022 The variables `new-scholium-name' and `new-scholium-about' are used to
3023 build new articles interactively. For now, \inp{type} is ignored by
3024 these functions. Also, we don't have a `new-scholium-text' field,
3025 since we get the text another way. It could be that an approach with
3026 a `new-scholium-text' variable would allow us to unify the treatment
3027 here with the one used in previous subsections.
3028 \end{notate}
3030 \begin{lisp}
3031 (defvar new-scholium-name nil "Name of our new scholium.")
3032 (defvar new-scholium-about nil "What the new scholium is about.")
3033 \end{lisp}
3035 \begin{notate}{On `new-scholium-mode'}
3036 This mode is invoked by `make-scholium' in the buffer in which the new
3037 scholium's \inp{text} is to be supplied.
3038 \end{notate}
3040 \begin{lisp}
3041 (define-minor-mode new-scholium-mode
3042 "Mode for composing a new scholium.
3043 \\{new-scholium-mode-map}"
3044 :init-value nil
3045 :keymap '(("\C-c\C-c" . escape-scholium-creation)))
3046 \end{lisp}
3048 \begin{notate}{On `escape-scholium-creation'}
3049 Once the new scholium's \inp{text} has been supplied, this function
3050 creates a scholium from that text and other data the user has
3051 supplied. It then restores the window configuration that was active
3052 before `make-scholium' ran. It also nullifies `new-scholium-name'
3053 and `new-scholium-about', since we're done with these things.
3054 \end{notate}
3056 \begin{lisp}
3057 (defun escape-scholium-creation ()
3058 (interactive)
3059 (scholium new-scholium-name
3060 (buffer-substring-no-properties (point-min) (point-max))
3061 new-scholium-about
3063 (sch-book))
3064 (kill-buffer (concat "Editing scholium: " new-scholium-name))
3065 (set-window-configuration sch-win-config)
3066 (setq new-scholium-name nil
3067 new-scholium-about nil))
3068 \end{lisp}
3070 \begin{notate}{On `make-scholium'} \label{make-scholium}
3071 This function is called every time the user makes a scholium with new
3072 text (i.e. text that is typed in on the fly). Functions for making
3073 scholia about articles, parts of articles, buffers, etc., are given in
3074 this document and all use this function.
3075 \end{notate}
3077 \begin{lisp}
3078 (defun make-scholium ()
3079 (setq sch-win-config (current-window-configuration))
3080 ;; we allow this to be set elsewhere
3081 (unless new-scholium-name
3082 (setq new-scholium-name (read-string "Scholium name: ")))
3083 (set-buffer (get-buffer-create "Scholia Display"))
3084 (other-window -1)
3085 (split-window-vertically)
3086 (other-window 1)
3087 (switch-to-buffer (get-buffer-create (concat "Editing scholium: "
3088 new-scholium-name)))
3089 (new-scholium-mode))
3090 \end{lisp}
3092 \begin{notate}{Redisplay after running `make-scholium'} \label{redisplay-after-running-make-scholium}
3093 It would probably be fairly convenient to redisplay whatever object
3094 was being displayed after `make-scholium' has run. (It would be nice
3095 to have the configuration of windows be 100\% consistent!) In order
3096 to make this be efficient, we would probably want to a system for
3097 incremental markup, as described in Note \ref{incremental-markup}. Presumably this just means
3098 adding `redisplay-article' to an appropriate hook.
3099 \end{notate}
3101 \begin{notate}{Add a `make-scholium-hook'?}
3102 We could add a hook here if we wanted to make it easy to do
3103 interesting things after a scholium is added, like update the display.
3104 (We might want to make a section on default settings -- and we might
3105 want to make more hooks throughout the scholium system code.)
3106 \end{notate}
3108 \subsubsection{Scholia attached to the current article} \label{attached-main}
3110 \begin{notate}{On `make-scholium-about-current-article'}
3111 This function makes a scholium about the article as a whole.
3112 \end{notate}
3114 \begin{lisp}
3115 (defun make-scholium-about-current-article ()
3116 (interactive)
3117 (when name-of-current-article
3118 (setq new-scholium-about `(((,name-of-current-article))))
3119 (make-scholium)))
3120 \end{lisp}
3122 \begin{notate}{On `make-scholium-about-part-of-current-article'} \label{make-scholium-about-part-of-current-article}
3123 This function makes a scholium about one specific portion of the
3124 article.
3126 This function makes the (somewhat unrealistic seeming) assumption that
3127 the current article and the current buffer are the same thing. This
3128 situation should be resolved.
3130 However, if no article is current yet, then perhaps we should
3131 offer to make a scholium about the current buffer?
3132 \end{notate}
3134 \begin{lisp}
3135 (defun make-scholium-about-part-of-current-article (beg end)
3136 (interactive "r")
3137 (if name-of-current-article
3138 (progn
3139 (setq new-scholium-about
3140 `((,name-of-current-article
3141 (passage
3142 ,beg
3143 ,end))))
3144 (make-scholium)
3145 (deactivate-mark)
3146 (message (concat (format "%s--%s" beg end) " added.")))
3147 (message "Make some article current first.")))
3148 \end{lisp}
3150 \begin{notate}{The use of `deactivate-mark' in this code}
3151 Since regions are being selected interactively, unless
3152 we `deactivate-mark', we will be left with a highlighted
3153 region after some of the scholium-creating function have
3154 run. This doesn't seem clean to me.
3155 \end{notate}
3157 \begin{notate}{On `make-scholium-about-current-line'}
3158 Here is a little convenience wrapper for working with lists.
3159 \end{notate}
3161 \begin{lisp}
3162 (defun make-scholium-about-current-line ()
3163 (interactive)
3164 (make-scholium-about-part-of-current-article (line-beginning-position)
3165 (line-end-position)))
3167 (defun make-scholium-about-current-line-quickly ()
3168 (interactive)
3169 (setq new-scholium-name (buffer-substring-no-properties
3170 (line-beginning-position)
3171 (line-end-position)))
3172 (make-scholium-about-part-of-current-article (line-beginning-position)
3173 (line-end-position)))
3175 (defun make-scholium-about-current-line-quickly-and-completely ()
3176 (interactive)
3177 (scholium (buffer-substring-no-properties
3178 (line-beginning-position)
3179 (line-end-position))
3180 (buffer-substring-no-properties
3181 (line-beginning-position)
3182 (line-end-position))
3183 `((,name-of-current-article
3184 (passage
3185 ,(line-beginning-position)
3186 ,(line-end-position))))
3188 (sch-book)))
3190 (defun make-scholium-about-current-sentence ()
3191 (interactive)
3192 (make-scholium-about-part-of-current-article (line-beginning-position)
3193 (line-end-position)))
3194 \end{lisp}
3196 \begin{notate}{Semantics of lists} \label{semantics-of-lists}
3197 Lists may benefit some special semantics. In particular, it might be
3198 useful to only display the scholia that are attached to \emph{the
3199 current line} (or item more generally). Also, an indicator to show
3200 the existence of scholia attached to other lines (when such scholia do
3201 in fact exist).
3202 \end{notate}
3204 \begin{notate}{Scoring}
3205 Maybe the way to go with scoring would be to make a change to the
3206 \inp{type} field to indicate that the thing has type ``score 10'' or
3207 whatever. Or perhaps we would want to attach a scholium?
3208 \end{notate}
3210 \begin{notate}{Locally-stored data versus indexed data} \label{locally-stored-vs-indexed}
3211 This reminds me of the different models of data storage. We could
3212 keep everything local (a score field for each scholium) or store
3213 things in an index (look-up each scholium to see if it has a score).
3214 The magic of hash tables says that lookup is ``linear'' but is the
3215 factor lower if the data is kept locally? Maybe on average.
3217 Of course, if you have to search a collection to find the extent of
3218 some predicate, that will take \emph{some} time; if everything
3219 matching a certain description has been stored on a certain list, then
3220 you already have the predicate's extent without search.
3222 There's really no reason not to store some things locally if we know
3223 that search is going to always be local (e.g. the score of a certain
3224 article is probably fine to store locally) \emph{and} we have
3225 permission to store that data locally. See Note
3226 \ref{holographic-data} for more on this general topic -- the issues
3227 here have been pretty much resolved with in the design of metadata
3228 articles (Note \ref{metadata-article-overview}).
3229 \end{notate}
3231 \begin{notate}{Local list of scholia}
3232 One example of how local lists could come in handy (like we were
3233 talking about in Note \ref{locally-stored-vs-indexed}) would be to
3234 keep a local list of all the scholia that are attached to the current
3235 article. Then, if changes have to be propagated, we just look at the
3236 things on this list, rather than having to search through all of the
3237 articles again to figure out which scholia are attached to the current
3238 article. Of course, the local list could be kept updated as the set
3239 of scholia attached to the current article changes. This would (I
3240 think) be an optimization, and isn't essential for building a working
3241 system.
3242 \end{notate}
3244 \subsubsection{Creating a scholium that applies to several regions}
3246 \begin{notate}{On `reading-regions-mode'}
3247 This mode is invoked by
3248 `make-scholium-about-several-parts-of-current-article', and
3249 adds an editing mode in the buffer containing the current
3250 article that enables the user to select regions that the
3251 scholium will be \inp{about}.
3252 \end{notate}
3254 \begin{lisp}
3255 (define-minor-mode reading-regions-mode
3256 "Mode for reading in regions.
3257 \\{new-scholium-mode-map}"
3258 :init-value nil
3259 :keymap '(("\C-c\C-c" . add-region)
3260 ("\C-c\C-g" . escape-reading-regions-mode))
3261 (message "C-c C-c to add regions; C-c C-g to make scholium."))
3262 \end{lisp}
3264 \begin{notate}{On `add-region'}
3265 This function adds regions to `new-scholium-about'.
3266 \end{notate}
3268 \begin{lisp}
3269 (defun add-region (beg end)
3270 (interactive "r")
3271 (setq new-scholium-about
3272 (cons `(,name-of-current-article
3273 (passage
3274 ,(region-beginning)
3275 ,(region-end)))
3276 new-scholium-about))
3277 (deactivate-mark)
3278 (message (concat (format "%s--%s" beg end) " added.")))
3279 \end{lisp}
3281 \begin{notate}{On `escape-reading-regions-mode'}
3282 When all of the regions desired have been selected, this function
3283 calls `make-scholium' to finish things off.
3284 \end{notate}
3286 \begin{lisp}
3287 (defun escape-reading-regions-mode ()
3288 (interactive)
3289 (reading-regions-mode -1)
3290 (make-scholium))
3291 \end{lisp}
3293 \begin{notate}{On `make-scholium-about-several-parts-of-current-article'} \label{on-make-scholium-about-several-parts-of-current-article}
3294 This function makes a scholium that applies to several portions of the
3295 article, using the mode and so on featured in this section.
3297 (Note, it doesn't seem that this is displayed quite right; I'm
3298 getting two copies of the scholium's text in the Scholia
3299 Display buffer.)
3300 \end{notate}
3302 \begin{lisp}
3303 (defun make-scholium-about-several-parts-of-current-article ()
3304 (interactive)
3305 (let ((article (get-article name-of-current-article)))
3306 (if (article-buffered article)
3307 (switch-to-buffer (get-buffer (scholium-text article)))
3308 (switch-to-buffer "Main Article Display"))
3309 (setq new-scholium-about nil)
3310 (reading-regions-mode 1)))
3311 \end{lisp}
3313 \subsubsection{Scholia about the current buffer} \label{about-buffer}
3315 \begin{notate}{Making scholia about the current buffer}
3316 We present facilities for making new scholia about the current buffer
3317 or file that this buffer is visiting. Corresponding functions for
3318 displaying scholia that are attached to the current buffer appear in
3319 section \ref{rendering}. This function ensures that the buffer is
3320 associated with on article on the article list; otherwise, we can't
3321 make a scholium about it.
3322 \end{notate}
3324 \begin{notate}{On `call-if-user-adds-current-buffer-to-article-list'}
3325 This is used by functions that require the current buffer to
3326 be an article; typically they recall themselves after the
3327 buffer has been added. It is used by
3328 `make-scholium-about-current-buffer' and
3329 `display-scholia-about-current-buffer'.
3330 \end{notate}
3332 \begin{lisp}
3333 (defun call-if-user-adds-current-buffer-to-article-list (fct)
3334 (when (y-or-n-p "Buffer not an article, add to list? ")
3335 (make-current-buffer-into-article
3336 (read-string (concat "Name (default: "
3337 (buffer-name
3338 (current-buffer)) "): ")
3341 (buffer-name (current-buffer))))
3342 (funcall fct)))
3343 \end{lisp}
3345 \begin{notate}{On `make-scholium-about-current-buffer'}
3346 This function makes a scholium about the current buffer,
3347 requiring that it be an article. (Maybe we should
3348 just add the current buffer to the article list
3349 transparently, rather than giving the prompt in
3350 `call-if-user-adds-current-buffer-to-article-list'.)
3351 \end{notate}
3353 \begin{lisp}
3354 (defun make-scholium-about-current-buffer ()
3355 (interactive)
3356 (let ((article (get-article (buffer-name (current-buffer)))))
3357 (if (not article)
3358 (call-if-user-adds-current-buffer-to-article-list
3359 'make-scholium-about-current-buffer)
3360 (setq new-scholium-about
3361 `(((,(buffer-name (current-buffer))))))
3362 (make-scholium))))
3363 \end{lisp}
3365 \begin{notate}{Scholium creation modalities} \label{scholium-creation-modalities}
3366 We developed all sorts of creation facilities for generic articles,
3367 shouldn't we have them all over again for buffers? It seems only fair
3368 that there would be some symmetry between the way articles and buffers
3369 are handled. Maybe there is some way to reuse the work.
3371 On the other hand, maybe we don't need a lot of complex functions for
3372 specially handling buffers, since once the buffer has been made into
3373 an article, all of the functions for working with articles apply.
3374 (Contrast Note \ref{bias-towards-buffers}!)
3375 \end{notate}
3377 \begin{notate}{Making a scholium about a file.}
3378 Doing something like what `make-scholium-about-current-buffer' does
3379 that makes a scholium about the current buffer \emph{as} a file
3380 shouldn't be very different at all. I'll want to think a little more
3381 about the relevance of doing things this way: it may not really matter
3382 if we run the exporting and importing routines just right. (We could
3383 also write a function to make scholia about a file without displaying
3384 the file.)
3385 \end{notate}
3387 \subsubsection{Creating references} \label{creating-references}
3389 \begin{notate}{Fancy references} \label{fancy-references}
3390 In Note \ref{references} it isn't made completely clear what the set
3391 of reference targets is comprised of. One might be led to assume that
3392 it is only possible to reference to an \emph{article}. In the current
3393 implementation, that assumption is correct; `follow-reference' calls
3394 `display-article', which in turn only knows how to display
3395 \emph{articles}. However, in theory we could just as well reference
3396 any object that the system knows how to display; so, if
3397 `display-article' was overloaded to work with regions as well as
3398 articles, for example, there would be no problem with referencing
3399 regions (although the code for `make-reference-in-current-article'
3400 would have to be adjusted slightly). It would be nice to add this
3401 feature, since HTML already has targets that are approximately this
3402 general (well, more like ``go to a specific point within the given
3403 document''). It shouldn't be too much to ask to enable following a
3404 reference and then performing a given action (e.g. ``find the first
3405 occurance of \emph{foo} in the referenced document'').
3407 Another relevant thing to point out is that we can have different
3408 kinds of references appear in different colors (Note
3409 \ref{color-and-style}); this is true of other sorts of linking as
3410 well (Note \ref{generalized-links}). Compare Note
3411 \ref{thought-processes}.
3412 \end{notate}
3414 \begin{notate}{Abstract connections}
3415 References have two \inp{about} fields, one comprising the reference's
3416 target, and the other, the region from which the reference originates.
3417 This shows how an abstract connection between two documents can be
3418 formed by a third element, rather than such connections being the
3419 exclusive domain of \inp{about} data itself. This is an important
3420 feature for semantic networks; larger-scale structures can be
3421 expressed using basic pieces.
3422 \end{notate}
3424 \begin{notate}{On `genref'} \label{genref}
3425 Instead of using `gensym' (which causes problems) we do something
3426 similar to generate references with unique ids. Note that this might
3427 cause some problems when we go to the distributed way of doing things
3428 (or even just save and restore articles with references in them after
3429 making some intervening edits), since references with the same names
3430 might mean different things. But of course, this is true of all
3431 scholia with the same names, so I propose not to worry about it too
3432 much right now.
3434 It may turn out to be advantageous to use a reference counter that is
3435 local to each article.
3437 Actually, the scheme proposed here seems pretty weak; saving files and
3438 then reading them back in after Emacs has been shut down could cause
3439 problems. It might be much better to have a reference counter in each
3440 metadata article, so that the collection of references associated with
3441 a given article is always unique. Furthermore, references associated
3442 with a given article should possibly be recorded on that article's
3443 metadata explicitly \emph{as references}.
3444 \end{notate}
3446 \begin{lisp}
3447 (defvar *reference-counter* 0)
3449 (defun genref ()
3450 (setq *reference-counter* (1+ *reference-counter*)))
3451 \end{lisp}
3453 \begin{notate}{On `make-reference-in-current-article'} \label{make-reference-in-current-article}
3454 This function is similar to
3455 `make-scholium-about-part-of-current-article' (Note
3456 \ref{make-scholium-about-part-of-current-article}) except that the
3457 \inp{type} is set to ``reference''. References currently don't have any
3458 \inp{text}, but we could later set things up to let them have a
3459 docstring or something like that.
3461 (Are backlinks working properly in an article that has several
3462 references associated with it?)
3463 \end{notate}
3465 \begin{lisp}
3466 (defun make-reference-in-current-article (beg end &optional target)
3467 (interactive "r")
3468 (let ((target (or target
3469 (read-article-name))))
3470 (if name-of-current-article
3471 (when target
3472 (scholium `(reference ,name-of-current-article ,(genref))
3474 `((,name-of-current-article
3475 (passage
3476 ,beg
3477 ,end))
3478 (,target))
3479 'reference)
3480 (deactivate-mark))
3481 ;; Maybe the message should instead be an offer to make
3482 ;; a scholium about the current buffer?
3483 (message "Make some article current first."))))
3484 \end{lisp}
3486 \begin{notate}{Speedy reference creation}
3487 It would be handy to be able to make a reference to an article and
3488 automatically create and follow the reference, all at the same time.
3489 (Maybe also subsets of these actions, like create but don't follow.)
3490 Probably we could do something similar for generalized references.
3491 \end{notate}
3493 \begin{lisp}
3494 (defun create-follow-reference ()
3495 (interactive)
3496 (let ((name (buffer-substring (point) (mark))))
3497 (unless (get-article name)
3498 (save-excursion
3499 (set-buffer (get-buffer-create name))
3500 (make-current-buffer-into-article name)))
3501 (make-reference-in-current-article (min (point) (mark))
3502 (max (point) (mark))
3503 name)
3504 (display-article name)))
3505 \end{lisp}
3507 \begin{notate}{Come-from references} \label{come-from-references}
3508 As weird as it might sound, it could be handy to have a function for
3509 adding references to the current article from some other article (or class
3510 of articles). See Note \ref{backlinks} for further comments. (It
3511 seems possible, though maybe not too likely, that we would be able to
3512 use the outline of `make-reference-in-current-article' to create a generic
3513 function for both ``come-from'' and ``goto'' references.)
3514 \end{notate}
3516 \begin{notate}{Inspecting or changing reference target, deleting reference, changing ``alt text''}
3517 Various operations that you might like to do with a reference need should
3518 to be supported. changing the ``alt text'' should be supported
3519 automatically -- just edit the text -- but there is the chance that
3520 the user could screw things up and accidentally delete the whole
3521 scholium if they do the wrong thing, so we may want to provide some
3522 assistance.
3523 \end{notate}
3525 \begin{notate}{Reference component access} \label{reference-access-functions}
3526 These functions give easy access to information specifying the
3527 referenced article (the target), the region the reference applies to,
3528 and the name of the article the reference lies in. These functions
3529 rely on the formulaic nature of the \inp{type} data of references,
3530 namely, a link to the passage wherein the reference is made is given,
3531 followed by a link to the referenced article.
3533 Notice that these functions would have to change if we later
3534 allow multiple sources (presumably, regions) to be part of the
3535 same reference.
3536 \end{notate}
3538 \begin{lisp}
3539 (defun reference-source-link (reference)
3540 (first (scholium-about reference)))
3542 (defun reference-from-article (reference)
3543 (car (reference-source-link reference)))
3545 (defun reference-to-article (reference)
3546 (car (second (scholium-about reference))))
3547 \end{lisp}
3549 \begin{notate}{Justification of the representation of references}
3550 It might seem excessive to have backlinks to a reference on the
3551 reference target and the reference source, but remember that we want
3552 to be able to display references as scholia. Now, one thing that
3553 might be the case is that instead of storing a standard backlink on
3554 the reference target, we might want to store a special
3555 ``referenceed-by'' backlink. But \emph{that} is probably excessive,
3556 at least, given our rendering scheme (see Note \ref{mark-things-up}).
3557 \end{notate}
3559 \subsubsection{New undirected articles} \label{new-undirected}
3561 \begin{notate}{On `make-new-undirected-article'}
3562 Although one could simply create a new buffer and add that buffer to
3563 the article list (as in Section \ref{adding-buffers}), sometimes it
3564 may be more intuitive to simply add a new undirected article directly
3565 to the article list.
3566 \end{notate}
3568 \begin{lisp}
3569 (defun make-new-undirected-article ()
3570 (interactive)
3571 (setq new-scholium-about nil)
3572 (make-scholium))
3573 \end{lisp}
3575 \subsubsection{Followups} \label{followups}
3577 \begin{notate}{Introduction to followups}
3578 This section is about making scholia about other already-existing
3579 scholia. It relies on markup features from Section \ref{rendering},
3580 and its presence here is a bit ugly (Note \ref{principle-of-order}).
3581 Perhaps it will be moved somewhere else later.
3582 \end{notate}
3584 \begin{notate}{Complex ``about'' features for scholia}
3585 More complicated features like creating scholia directly about several
3586 regions of a given scholium or like creating a scholium that relates
3587 to several regions of several different scholia can be coded up soon,
3588 following the style of section \ref{attached-main}.
3589 \end{notate}
3591 \begin{notate}{On `name-of-current-scholium'}
3592 The function can be called from anywhere; ``current'' is defined
3593 relative to the position of `point' in the Scholia Display buffer.
3594 (It is natural to assume that there is only one current scholium,
3595 given the way the contents of this buffer have been put together.)
3597 Note that \emph{scholia} appear once in the Scholia Display buffer, so
3598 there is only one ``current scholium'' (with one name) when we look at
3599 things this way. If we were going to do something like this for the
3600 main article buffer, then we'd need to do a bit more. (In fact,
3601 various functions to associate marked regions with scholia need just
3602 this sort of special touch.)
3603 \end{notate}
3605 \begin{lisp}
3606 (defun name-of-current-scholium ()
3607 (interactive)
3608 (save-excursion
3609 (set-buffer (get-buffer-create "Scholia Display"))
3610 (let ((ret (car (scholia-named-at-point))))
3611 (if ret
3612 (message (format "%s" ret))
3613 (message "Position cursor on a scholium in Scholia Display."))
3614 ret)))
3616 (defun make-scholium-about-current-scholium ()
3617 (interactive)
3618 (when (equal (buffer-name (current-buffer)) "Scholia Display")
3619 (let ((cur (name-of-current-scholium)))
3620 (when cur
3621 (progn (setq new-scholium-about `(((,cur))))
3622 (make-scholium))))))
3623 \end{lisp}
3625 \subsection{Further notes on adding articles to the digital library}
3627 \begin{notate}{Forbid the creation of ``empty'' scholia?}
3628 Perhaps `make-scholium' should disallow (or at least display an idiot
3629 box about) the creation of ``empty'' scholia -- they seem somewhat
3630 silly.
3631 \end{notate}
3633 \begin{notate}{Transcluded strings}
3634 We'd should have some function to insert an auto-updating string (like
3635 the name for the buffer as an article). We would typically want such
3636 auto-updating portions to appear in a specially colored face.
3637 \end{notate}
3639 \begin{notate}{Multi-reference creation?}
3640 This section should probably cover: the event of interactively making
3641 a scholium that relates to several different pieces of text from
3642 several different articles. Note that you could probably do things
3643 like this by using the generic list, and marking things in different
3644 ways that show their relationship together, the create the new
3645 scholium from that list.
3646 \end{notate}
3648 \begin{notate}{Anonymous scholia}
3649 Creating ``anonymous'' scholia should probably be made possible; by
3650 which I mean, the names of these scholia would be filled in
3651 automatically but would be non-significant (compare `gensym'). Of
3652 course, if we could have automatic names that were significant that
3653 would be cool too.
3654 \end{notate}
3656 \begin{notate}{Merging editorial comments}
3657 It would be nice if there was an easy way to merge editorial comments
3658 into the main document, corresponding to the ability to make such
3659 comments in the first place (Note \ref{straightforward-applications}).
3660 \end{notate}
3662 \section{Rendering articles} \label{rendering}
3664 \subsection{Formatting articles for display} \label{formatting-articles}
3666 \begin{notate}{``Formatting'' versus ``display'' versus ``rendering''} \label{why-we-say-rendering}
3667 The term ``formatting'' seems to capture a specific notion of
3668 producing a user-visible version of an arbitrary article, that is then
3669 ``displayed''. ``Rendering'' is meant to capture a more general idea,
3670 which includes non-user-visable features (e.g. invisible text
3671 properties). Some sorts of articles will require further work to
3672 ``render'' (see Note \ref{transformative} and Note
3673 \ref{functional}).
3674 \end{notate}
3676 \begin{notate}{Generality, or lack thereof, in the rendering system developed here}
3677 It woulb be great to have all sorts of different kinds of rendering
3678 systems. (For one example additional to those mentioned in
3679 \ref{why-we-say-rendering}, see Note
3680 \ref{interactive-and-actionable-scholia}; we could supply other
3681 examples!) For now, we have limited ourselves to something pretty
3682 basic.
3683 \end{notate}
3685 \begin{notate}{Producing plain text}
3686 The function `sch-plain-text' uses various criteria to render scholium
3687 system objects as a string (the collection of acceptable objects is
3688 the same as the collection of link targets, plus articles specified
3689 simply by name). Its behavior can be fine-tuned by changing the
3690 variable `sch-plain-text-hook'.
3691 \end{notate}
3693 \begin{notate}{On `sch-plain-text-hook'} \label{sch-plain-text-hook}
3694 Alternative ways of setting the return value of `sch-plain-text'.
3695 \end{notate}
3697 \begin{lisp}
3698 (defvar sch-plain-text-hook nil)
3699 \end{lisp}
3701 \begin{notate}{On `sch-plain-text'} \label{sch-plain-text}
3702 This function is called by `mark-up-scholium' to render scholia that
3703 are to be displayed alongside the main article, and also by
3704 `transclude-article' (see Note \ref{transclude-article}) and other
3705 functions in Section \ref{transclusion}.
3707 Its goal is to turn arbitrary articles into strings. This will be
3708 done in different ways depending on the sort of article in question.
3709 (And could be done in other ways depending on other stuff.) Compare
3710 Note \ref{user-crafted-semantics}.
3712 Here's how it works: different kinds of ``objects'' are to be
3713 distinguished from one another by simple tests -- is the `car' equal
3714 to \verb|passage|? Does looking up the object in the article table
3715 produce anything? Then act as appropriate, grabbing the text that is
3716 specified. Currently it works on input \emph{article names} or
3717 input \emph{articles}. (If input is both the name of an article
3718 and an article, it will be treated as a name.)
3720 Another thing that might be handy to be able to process is
3721 \emph{simple strings}, which aren't article names, or articles
3722 (obviously).
3724 Note that links are rendered differently depending on context.
3726 Links can't actually run from arbitrary object to arbitrary
3727 object within the current version of the system. That can
3728 probably be fixed easily.
3730 Converting the function to render scholium system objects in general
3731 is a step towards answering the request in Note
3732 \ref{name-of-current-article} about extending the purview of
3733 `display-article'. At that point, it will take more than just a
3734 \inp{title} as argument, certainly; and it will need a ``triage''
3735 phase in order to figure out what sort of object it has been applied
3736 to; various modifications will have to be made so that it can be
3737 applied to various sorts of objects.
3738 \end{notate}
3740 \begin{lisp}
3741 (defun sch-plain-text (title-or-article)
3742 ;; this overloading of the input & reliance upon `get-article' to
3743 ;; sort things out... could probably be revised into something
3744 ;; better
3745 (let* ((obj (or (get-article title-or-article)
3746 title-or-article))
3747 (text (scholium-text obj))
3748 (type (scholium-type obj))
3749 ret)
3750 ;; This seems like the correct way to override a `cond' form.
3751 (run-hooks 'sch-plain-text-hook)
3752 (when (not ret)
3753 (cond
3754 ((bufferp text)
3755 (save-excursion (set-buffer (get-buffer text))
3756 (setq ret (buffer-string))))
3757 ((typedata-includes type 'file)
3758 (let ((bufs (buffer-list))
3759 (live nil))
3760 (while (and bufs (not live))
3761 (when (equal (buffer-file-name (car bufs))
3762 (expand-file-name text))
3763 (setq live (car bufs)))
3764 (setq bufs (cdr bufs)))
3765 (if live
3766 (progn (set-buffer live)
3767 (setq ret (buffer-string)))
3768 (find-file text)
3769 (setq ret (buffer-string))
3770 (kill-buffer (current-buffer)))))
3771 ;; these quoted things should presumably themselves be rendered
3772 ;; as links (and we probably don't need the crazy markup for
3773 ;; things about the whole buffer, ever)
3774 ((typedata-includes type 'reference)
3775 (if (equal (reference-to-article obj)
3776 name-of-current-article)
3777 (setq ret
3778 ;; it might be kind of cool to at least include a
3779 ;; snippet of the context of this link, say 3 lines
3780 ;; worth
3781 (format "\"%s\" links here."
3782 (reference-from-article obj)))
3783 (setq ret
3784 (format "This is a link from \"%s\" to \"%s\"."
3785 (reference-from-article obj)
3786 (reference-to-article obj)
3787 obj))))
3788 ((stringp text)
3789 (setq ret text))
3791 (setq ret (format "%S" text)))))
3792 ret))
3793 \end{lisp}
3795 \begin{notate}{Turn list of ``links here'' items into listing}
3796 It would be nice to be able to view all of the ``links here''
3797 articles in a listing (as in Section \ref{catalog}), and from
3798 there in a compilation (Note \ref{making-a-compilation}).
3799 \end{notate}
3801 \begin{notate}{Rendering special list forms}
3802 With a small loss of transparency (note
3803 \ref{principle-of-transparency}), we can set up some specially-encoded
3804 \inp{text} fields. See, e.g., Section \ref{transclusion}.
3805 \end{notate}
3807 \begin{notate}{Strategy for `cond's}
3808 Any time we see a `cond' in this code, we could wrap it in a backquote
3809 and unquote a variable that says how to deal with things that come up
3810 later in the code (see Note \ref{principle-of-order}).
3811 \end{notate}
3813 \begin{notate}{Actionable references} \label{actionable-references}
3814 When displaying a reference as the main article, it would be nice to
3815 have the names of the articles (or other objects) themselves rendered
3816 as references to the articles (or other objects) in question. These
3817 wouldn't officially be ``references'' from the point of view of the
3818 system (unless they were temporary ones), but they would act like
3819 references for the user.
3821 Some examples of this sort of thing appear in Section \ref{linear-browsing},
3822 and are hooked in by `scholia-display-extras-hook'
3823 (Note \ref{scholia-display-extras-hook}).
3824 \end{notate}
3826 \begin{notate}{Render the names of articles?}
3827 Depending on the value of a variable like `sch-use-names' or something
3828 of that sort, this could print the names of the scholia above their
3829 text contents. We might also want to print a list of articles that
3830 this article is ``about'' (assuming there is more than one).
3831 \end{notate}
3833 \subsection{Managing windows and buffers} \label{managing-windows-and-buffers}
3835 \begin{notate}{Side-by-side buffers} \label{side-by-side-buffers}
3836 The first display style shows the main article in one buffer and
3837 scholia about this article in another buffer. The scholia may be
3838 attached to specific regions of the main article, in which case, this
3839 connection is shown graphically. Other display styles
3840 (e.g. threading, see Note \ref{threading}) are in the works.
3841 \end{notate}
3843 \begin{notate}{Special treatment of buffers and files} \label{bias-towards-buffers}
3844 Buffers and files need some special treatment for display, even if
3845 they don't need to be given much attention at scholium-creation time
3846 (Note \ref{scholium-creation-modalities}). For example, it would be
3847 nice to set up automatic display of scholia associated with a given
3848 file if some spceial variable is set. One class of buffers that
3849 requires special treatment are the \emph{killed} ones (see Note
3850 \ref{killed-buffers}). This issue relates to Note
3851 \ref{the-emacs-way}.
3852 \end{notate}
3854 \begin{notate}{Simpler side-by-side annotation}
3855 A simpler method for doing side-by-side editing has been discussed
3856 recently on the help-gnu-emacs mailing
3857 list\footnote{{\tt http://lists.gnu.org/archive/html/help-gnu-emacs/2005-07/msg00276.html}}.
3858 This gives local features similar to some of those provided by the scholium
3859 system, but none of the global features. (We should make sure that we
3860 actually \emph{can} simulate this behavior, I think it should be no problem.)
3861 \end{notate}
3863 \begin{notate}{A physical scholium system} \label{physical-scholium-system}
3864 Working on this paper, I've taken to printing the document out
3865 single-sided and binding the drafts along the margin, so that each
3866 page has a blank facing page that I then use for notes. Sounds
3867 familar, doesn't it? This approach is helping me understand how to
3868 use paper better. And it is giving me some ideas about useful
3869 features to work into the electronic version. See also Note
3870 \ref{large-form}.
3871 \end{notate}
3873 \begin{notate}{Working with large-form scholium systems} \label{large-form}
3874 With larger pieces of paper, or other media, it is possible to put
3875 together scholium-based documents with more content and more than two
3876 columns. With a couple of screens, or a larger screen, useful things
3877 along these lines could be accomplished with Emacs too. (As it is,
3878 two side-by-side windows is about all that can be managed on my
3879 computer.)
3881 Working with large format documents, I noticed some interesting
3882 effects. On the left, I might see a document assembled out of several
3883 smaller articles (say, by identification), and on the right, I would
3884 see all of the comments that applied to any of these articles, while a
3885 third columns would give comments that applied to text in the other
3886 columns, or to the document as a whole, or to any of the other
3887 articles that had gone into building previous columns.
3889 Even with just a couple of columns to work with, various complex
3890 things like this should be possible to do on the computer (e.g. with
3891 different colors or different levels of indentation).
3893 (The point is, eventually should be able to make more interesting sort
3894 compilations than those described in Section
3895 \ref{quick-compilations}.)
3896 \end{notate}
3898 \begin{notate}{Avoiding information overload} \label{avoiding-information-overload}
3899 A tricky option would be to just display the scholia that relate
3900 to portions of the document that are on the current screen. The paper
3901 version of Note \ref{physical-scholium-system} does this by default.
3902 But I'm not sure how to make Emacs behave this way.
3903 \end{notate}
3905 \begin{notate}{Context} \label{context}
3906 Context is important. This is one of the reasons that scholia
3907 themselves are important -- they get comments situated in a certain
3908 \emph{con}text. The notion of context seems to be different for
3909 \emph{text} and \emph{hypertext}. In text, everthing appears in
3910 context, whereas in hypertext, nearby things sometimes don't appear at
3911 all; they reside on the other side of a link, and may never be seen by
3912 a reader. But this duality is somewhat misleading, in particular, it
3913 is sometimes thecase that ``information overload'' would occur if
3914 everything appeared on the same page or in the same place. And
3915 sometimes the context of the page can be misleading; regular text
3916 frequently relies on global contextual features. (And of course,
3917 readers might not actually see everything that is on the page!) It is
3918 an interesting feature of reality and human psychology that contexts
3919 are often decipherable -- we can figure out how things fit together.
3920 A ``good'' hypertext model should presumably include features that
3921 reflect this aspect of our thinking, and allow users to explicitly
3922 recontextualize things as they see fit. For some technical
3923 suggestions on this matter, see Note \ref{displaying-nearby-scholia}.
3924 \end{notate}
3926 \begin{notate}{Dot dot dot}
3927 How should scholia in later generations be displayed? In the default
3928 mode, without threading, a ``dot dot dot'' would be useful. (And in
3929 the case of scholia that bridge the gap between two articles, the
3930 ``dot dot dot'' probably needs to have a special meaning.) Anyway,
3931 note that these dot-dot-dotted things could be found by a depth-first
3932 search through the document collection. (Find anything \inp{about}
3933 the current article, then find anything \inp{about} that, etc., then
3934 find the next thing \inp{about} the current article,
3935 etc.)\footnote{Compare the 2nd figure in Corneli and Krowne (2005)
3936 (cf. Footnote \ref{corneli-krowne}, Page \pageref{corneli-krowne}).}.
3937 % How to get page reference corresponding to a label?
3938 \end{notate}
3940 \begin{lisp}
3941 (defvar pre-sch-win-config nil "Saved window configuration.")
3942 (defvar sch-win-config nil "Saved window configuration.")
3944 (defvar buffer-associated-with-current-article nil)
3945 \end{lisp}
3947 \begin{notate}{On `article-buffered'}
3948 Here's a little convenience function that tells you whether the
3949 article's text lives in a buffer or not.
3950 \end{notate}
3952 \begin{lisp}
3953 (defun article-buffered (article)
3954 (bufferp (scholium-text article)))
3955 \end{lisp}
3957 \begin{notate}{Make new buffered article}
3958 We should provide some command to make a new article in a new
3959 buffer, all in one shot.
3960 \end{notate}
3962 \begin{notate}{Detaching articles from buffers}
3963 Perhaps it should be possible to detach a buffered article from the
3964 buffer that contains it.
3965 \end{notate}
3967 \begin{notate}{On `scholia-overwhelm-display'} \label{scholia-overwhelm-display}
3968 This function displays scholium stuff. It is called by
3969 `display-article' (Note \ref{display-article}) and
3970 `display-scholia-about-current-buffer'
3971 (Note \ref{display-scholia-about-current-buffer}). If
3972 there is a main article buffer (i.e. the article to be displayed lives
3973 in its own buffer), we use that buffer to display the article;
3974 otherwise, we use the ``Main Article Display'' buffer. Scholia that
3975 match the appropriate set of conditions in `mark-things-up' will be
3976 rendered to the ``Scholia Display'' buffer.
3977 \end{notate}
3979 \begin{lisp}
3980 (defun scholia-overwhelm-display (text)
3981 (unless pre-sch-win-config
3982 (setq pre-sch-win-config (current-window-configuration)))
3983 (delete-other-windows)
3984 (split-window-horizontally)
3985 (if rendering-target-buffer
3986 (pop-to-buffer rendering-target-buffer t)
3987 (switch-to-buffer (get-buffer-create "Main Article Display") t))
3988 (erase-buffer)
3989 (insert text)
3990 (goto-char (point-min))
3991 (setq buffer-associated-with-current-article (current-buffer))
3992 (other-window 1)
3993 (switch-to-buffer (get-buffer-create "Scholia Display") t)
3994 (erase-buffer))
3995 \end{lisp}
3997 \begin{notate}{Switching between views} \label{switching-between-views}
3998 We offer a few convenient functions for switching between the
3999 article-plus-scholia browsing display and whatever came before. It
4000 would also be nice to offer a function for switching between the
4001 article display and the generic listing display.
4002 \end{notate}
4004 \begin{lisp}
4005 (defun back-to-normal ()
4006 (interactive)
4007 (setq sch-win-config (current-window-configuration))
4008 (set-window-configuration pre-sch-win-config)
4009 (setq pre-sch-win-config nil))
4011 (defun back-to-other-view ()
4012 (interactive)
4013 (setq pre-sch-win-config (current-window-configuration))
4014 (set-window-configuration sch-win-config)
4015 (setq sch-win-config nil))
4016 \end{lisp}
4018 \subsection{Sorting scholia for markup purposes} \label{sorting}
4020 \begin{notate}{Introduction to sorting scholia}
4021 The main function in this section is `sort-scholia-by-beg-position',
4022 which is called by `mark-things-up'.
4024 The use for this function is to put scholia in the order in which they
4025 will be rendered; the order is given by sorting the scholia on their
4026 \inp{about} data. Since there are several different kinds of
4027 \inp{about} data, the sorting criteria are a little complicated. For
4028 one thing, each scholium may be about several different articles, but
4029 here we only want to sort relative to their relationship to one given
4030 article.
4032 The criterion we use when sorting is: scholia that are about the whole
4033 article go first; then, we rank any other scholia according to their
4034 \emph{first} beginning position. (Thus, any scholia that are about
4035 several regions within the same article need to have a subsidiary sort
4036 done to order the indicated regions; this is accomplished, as
4037 needed, by the function `first-beginning-about-article', below.)
4038 \end{notate}
4040 \begin{notate}{On `first-beginning-about-article'}
4041 Return 0 if \inp{about} is about all of \inp{article}, i.e., otherwise
4042 return the character position of the first region within \inp{article}
4043 that \inp{about} is actually about. If there is none, return nil.
4044 (Actually, let me note that in the usage we have established so far,
4045 we would already know that in the case that \inp{about} is a string,
4046 it is about the article here, and in the case that \inp{about} is a
4047 one-layer list, similarly; so some of the tests we do here are as yet
4048 unneeded.)
4050 Here we're assuming that if there is \emph{some} link to the article
4051 that isn't a passage link, then we treat the link as about the article
4052 as a whole. The case in which the link is about the whole article
4053 \emph{and} some part of the article might possibly be better treated
4054 some other way; but I'll leave that case for subsequent work.
4055 \end{notate}
4057 \begin{lisp}
4058 (defun first-beginning-about-article (about article)
4059 (cond
4060 ;; condition for the scholium to be about the article as a whole.
4061 ;; The condition is that there is _some_ link to the article that
4062 ;; is NOT a ``passage''-type link. In this case, we just return 0.
4063 ((member-if (lambda (link)
4064 (and (equal (car link) article)
4065 (not (link-type-accessor link 'passage))))
4066 about)
4068 ;; else, collect the regions of `article' that `about' indicates,
4069 ;; and sort them.
4071 (let* ((marking-links
4072 (let (marked)
4073 (mapc (lambda (elt)
4074 (when (and
4075 (typedata-includes-passage (link-type elt))
4076 (equal (linked-to-article elt) article))
4077 (setq marked (cons elt marked))))
4078 about)
4079 marked))
4080 (earliest-link
4081 (car (sort
4082 marking-links
4083 (lambda (link1 link2)
4084 (< (link-beginning link1)
4085 (link-beginning link2)))))))
4086 (link-beginning earliest-link)))))
4087 \end{lisp}
4089 \begin{notate}{On `sort-scholia-by-beg-position'} \label{sort-scholia-by-beg-position}
4090 This function orders \inp{scholia} according to the magnitude of the
4091 smallest beginning a region of \inp{article} that the input scholia
4092 mark. All links are considered when finding the first marked region.
4093 \end{notate}
4095 \begin{lisp}
4096 (defun sort-scholia-by-beg-position (scholia article)
4097 (setq
4098 scholia
4099 (sort scholia
4100 (lambda (scholium1 scholium2)
4101 (let ((beg1 (first-beginning-about-article
4102 (scholium-about scholium1)
4103 article))
4104 (beg2 (first-beginning-about-article
4105 (scholium-about scholium2)
4106 article)))
4107 (and beg1
4108 beg2
4109 (< beg1 beg2)))))))
4110 \end{lisp}
4112 \begin{notate}{Incremental markup} \label{incremental-markup}
4113 Instead of sorting everything each time we display, it would be nice
4114 to handle things incrementally: just add new markup for the newly
4115 created scholium, and store things in their natural order after
4116 reparsing. I think that this approach should work, but it would
4117 involve making a number of changes to the code. (Note that
4118 in the setup we're using, updates to metadata may have to be
4119 wholesale, even if updates to text properties are incremental.)
4120 \end{notate}
4122 \subsection{Marking things up} \label{marking-things-up}
4124 \begin{notate}{Introduction to marking things up}
4125 As mentioned in the introduction (Note
4126 \ref{text-properties-and-overlays}): \emph{when articles are
4127 displayed, both overlays and text properties are used for markup}.
4128 Overlays make it possible to put visible markup into font locked
4129 buffers. However, when text is cut and pasted or whatever, overlays
4130 disappear, so we use text properties too, to add a needed degree of
4131 permanence to the markup.
4132 \end{notate}
4134 \subsubsection{Faces for overlays}
4136 \begin{notate}{A more abstract face function}
4137 Perhaps `new-simple-scholium-face' could take an argument -- say the
4138 scholium -- and provide a different face for each user, or a different
4139 face for each type, or whatever. Probably there should be a variable
4140 called `scholium-face-function' that points you to the \emph{actual}
4141 function that is going to be in use. Using this sort of abstraction
4142 throughout would certainly facilitate user customization, and so,
4143 would be a good thing.
4144 \end{notate}
4146 \begin{notate}{On `new-simple-scholium-face'}
4147 Adapted from ttn's {\tt ricette-mode.el}. \emph{Nota bene}: new faces
4148 are automatically customizable, so if you don't like the way they
4149 look, you can change them.
4150 \end{notate}
4152 \begin{lisp}
4153 (defmacro new-simple-scholium-face (num color doc)
4154 (let ((prop (intern (concat "sch-face-" (int-to-string num)))))
4155 `(progn
4156 (defvar ,prop ',prop)
4157 (defface ,prop
4158 '((t (:foreground ,(symbol-name color)
4159 :underline ,(symbol-name color)))) ,doc))))
4160 \end{lisp}
4162 \begin{notate}{Underlining versus foreground} \label{underlining-versus-foreground}
4163 It is worth considering using the underline attribute instead or in
4164 addition to the foreground attribute: underlining would be less
4165 obtrusive in documents that already use faces. We could have two
4166 variants; one with underlining for the main article, one foreground
4167 for the scholia display. We could also give users some
4168 immediately-customizable options. (Do the default colors I picked out
4169 work well?)
4170 \end{notate}
4172 \begin{lisp}
4173 (new-simple-scholium-face 1 maroon1 "First scholium face.")
4174 (new-simple-scholium-face 2 aquamarine1 "Second scholium face.")
4175 (new-simple-scholium-face 3 IndianRed1 "Third scholium face.")
4176 (new-simple-scholium-face 4 yellow1 "Fourth scholium face.")
4177 (new-simple-scholium-face 5 firebrick1 "Fifth scholium face.")
4178 (new-simple-scholium-face 6 plum1 "Sixth scholium face.")
4179 \end{lisp}
4181 \begin{notate}{Reference face} \label{reference-face}
4182 A special face for references. We don't currently have a special face
4183 for \emph{visited} references, but this can be added if/when we start
4184 keeping track of which references have been visited (see Note
4185 \ref{visited-references}). We might also want to record and display
4186 information about visited articles in general.
4187 \end{notate}
4189 \begin{lisp}
4190 (defface sch-reference-face
4191 '((t (:foreground "red" :underline "red")))
4192 "Face for references in the scholium system.")
4193 \end{lisp}
4195 \begin{notate}{Special face for scholia about whole article?}
4196 It might be good to have a special face (and perhaps other
4197 special treatment, like a special section of the scholia display
4198 buffer) for scholia that apply to the whole of the main article.
4199 \end{notate}
4201 \begin{notate}{Special face for transclusions that have been collapsed} \label{collapsed-face}
4202 We're going to have to have a special face for transclusions that
4203 have been collapsed (see Note \ref{transcluding-and-outlines}).
4204 \end{notate}
4206 \subsubsection{Masks and miscellaneous markup mechanics}
4208 \begin{notate}{Color by number} \label{color-by-number}
4209 The `scholia-count' variable keeps track of how many scholia have been
4210 displayed. The `scholium-face' function selects a face to use when
4211 displaying the next scholium according to this count. This simple
4212 display mechanism seems sort of lame (hence, it is turned on with the
4213 `use-crazy-font-lock' variable); better things may come later, see,
4214 e.g. Note \ref{color-and-style}.
4216 Note that turning off ``crazy font lock'' makes it so that no text
4217 properties are added to the buffer, but of course it would be best if
4218 text properties were added and overlays omitted. On the other hand,
4219 we need to do some thinking to sort out the use of text properties
4220 versus the use of overlays. Cutting and pasting multiple copies of
4221 some markup in the same buffer may cause some trouble at commit time.
4222 See Section \ref{transclusion}; also, compare Note
4223 \ref{aggressive-dop}.
4224 \end{notate}
4226 \begin{lisp}
4227 (defvar scholia-count 0 "Number of scholia about the article found.")
4229 (defun scholium-face ()
4230 (let ((short-count (mod scholia-count 6)))
4231 (cond ((eq short-count 0)
4232 'sch-face-1)
4233 ((eq short-count 1)
4234 'sch-face-2)
4235 ((eq short-count 2)
4236 'sch-face-3)
4237 ((eq short-count 3)
4238 'sch-face-4)
4239 ((eq short-count 4)
4240 'sch-face-5)
4241 ((eq short-count 5)
4242 'sch-face-6))))
4244 (defvar use-crazy-font-lock t)
4245 (defvar main-article-overlays nil)
4246 (defvar scholia-overlays nil)
4247 \end{lisp}
4249 \begin{notate}{Overlays and text properties adjust when editing}
4250 By default, overlays and text properties will move appropriately when
4251 text is added to the buffer. This is important!
4252 \end{notate}
4254 \begin{notate}{Access to rendering target buffer} \label{access-to-rendering-target-buffer}
4255 The rendering target buffer is either ``Main Article Display'' if the
4256 current article isn't buffered, or whatever buffer the article lives
4257 in if it is buffered. (Well, actually, we can always redirect
4258 rendering to any buffer of our choice; but the preceding statement
4259 accurately describes the default operation.) We use
4260 `get-rendering-target-buffer' as a shorthand when we grab the
4261 rendering target buffer, and `set-buffer-to-rendering-target-buffer'
4262 to make that buffer current for editing. (Note that we \emph{could}
4263 go about this in a slightly different way, namely set the
4264 `rendering-target-buffer' variable to ``Main Article Display'' instead
4265 of `nil' when there is nothing to override the default -- but what
4266 would be the point?)
4267 \end{notate}
4269 \begin{lisp}
4270 (defun get-rendering-target-buffer ()
4271 (get-buffer (or rendering-target-buffer
4272 (get-buffer "Main Article Display"))))
4274 (defun set-buffer-to-rendering-target-buffer ()
4275 (set-buffer (get-rendering-target-buffer)))
4276 \end{lisp}
4278 \begin{notate}{The `scholia' property} \label{the-scholia-property}
4279 At render time, we use a text property (which we call
4280 \emph{`scholia'}) to associate regions with the scholia that are
4281 attached to them. A region can be associated with more than one
4282 scholium, \emph{so the `scholia' text property stores a list}.
4283 Specifically, a list identifying the \emph{links} that associate
4284 various scholia with this region (see Note \ref{link-ids}).
4286 This information helps us restore order to shifted markup when
4287 committing edits (see Section \ref{parsing}).
4288 \end{notate}
4290 \begin{notate}{Link-id's} \label{link-ids}
4291 The elements of stored in the `scholia' text property's list are
4292 ordered pairs (two-element lists), each containing information of the
4293 following form: (1) the \emph{name} of a scholium associated with this
4294 buffer position; paired with, (2), the link number corresponding to
4295 (one of) the link(s) through which said scholium came to be associated
4296 with the particular region being marked up.
4298 Lists of this form are a fairly common idiom in this work, and they
4299 get a special name, the \emph{link-id}.
4300 \end{notate}
4302 \begin{notate}{Experiment with many `scholium' properties} \label{many-scholium-properties}
4303 All else equal, it might be advantageous to use independent `scholia'
4304 properties instead of just one `scholium' property (see Note
4305 \ref{inserting-text-in-middle-of-marked-up-region}).
4307 Accordingly, I tried switching over to using one `scholium' property
4308 for each marked-up region. These properties were given somewhat
4309 complicated names -- namely, the link-ids that are currently stored as
4310 elements of the `scholia' property (Note \ref{the-scholia-property}).
4311 However, this doesn't work, as suggested by the following example.
4312 \begin{idea}
4313 (progn (put-text-property (point) (1+ (point)) '(foo 1) t)
4314 (put-text-property (point) (1+ (point)) '(foo 1) nil)
4315 (text-properties-at (point)))
4316 \end{idea}
4317 This is because\footnote{Thanks Andreas Schwab, help-gnu-emacs,
4318 2005/12/12. \label{so-called-text-property-bug}}
4319 \begin{idea}
4320 (eq '(foo 1) '(foo 1)) ;=> nil
4321 \end{idea}
4323 The Emacs text property engine is uniformly `eq'-based instead of
4324 `equal'-based. (So, if we happened to have an association between
4325 link-id's and integers, this would have worked, but that seems like a
4326 silly kludge.)
4328 Indeed, this `eq' preference is pretty much fatal to the utility of
4329 non-symbol text properties (unless we managed to hang directly onto
4330 the actual link-ids that would be used for the names of the text
4331 properties, which seems infeasible; or alternatively used some other
4332 sort of weird work-around, as above). A further difficulty is
4333 associated with the fact that these various `scholium' text properties
4334 would be indiscriminately mixed in with any other text properties that
4335 happened to be stored at point, requiring filtering for any useful en
4336 masse processing.
4338 I have some ideas that could possibly improve the prospects for doing
4339 away with the `scholia' property and replacing it with several
4340 `scholium' properties, but it seems like anything realistic would
4341 hacking Emacs C. But since it seems that there are no immediate
4342 problems associated with using just one `scholia' property, we plunge
4343 ahead that way.
4344 \end{notate}
4346 \begin{notate}{On `add-to-scholia-property-within-region'} \label{add-to-scholia-property-within-region}
4347 For each character in the region between \inp{beg} and \inp{end}, this
4348 function grabs the `scholia' property and replaces it with a version
4349 that has been modified to include the input \inp{value} (a link-id;
4350 see Note \ref{the-scholia-property}).
4352 The same property is used in the Scholia Display buffer, although that
4353 may be a bit of an abuse (cf. Note
4354 \ref{using-scholia-property-for-everything}); something simpler would
4355 work for our needs there -- but the current way is expedient. Also,
4356 it seems to be suggestive -- perhaps in the future we'll be able to
4357 treat the Scholia Display buffer as a proper scholium-based article
4358 itself, presumably by using transclusion and identification, as
4359 appropriate (see Section \ref{derivative}).
4360 \end{notate}
4362 \begin{lisp}
4363 (defun add-to-scholia-property-within-region (start end value)
4364 (while (< start end)
4365 (put-text-property start (1+ start) 'scholia
4366 (add-to-or-start-list
4367 (get-text-property start 'scholia)
4368 value))
4369 (setq start (1+ start))))
4370 \end{lisp}
4372 \begin{notate}{On `current-markup'} \label{current-markup}
4373 This variable will be used to record the regions of the article being
4374 displayed which have scholia attached to them and are, consequently,
4375 marked up. This information will be stored at markup time by
4376 `mark-up-region' (Note \ref{mark-up-region}). It is important to have
4377 this information on record so that we have something to compare to
4378 after editing takes place (see Section \ref{committing}).
4380 Its format is a list of elements of the form
4381 \begin{idea}
4382 ((<name> <link number>) <beg> <end>)
4383 \end{idea}
4384 where `beg' and `end' denote the beginning and end of the region
4385 marked up via the specified link (but see Note
4386 \ref{investigating-current-markup}!).
4387 \end{notate}
4389 \begin{lisp}
4390 (defvar current-markup nil)
4391 \end{lisp}
4393 \begin{notate}{Investigating `current-markup' in the context of masks} \label{investigating-current-markup}
4394 If the link in question is being masked, then the format of
4395 `current-markup' changes from the form described in Note
4396 \ref{current-markup} to the following:
4397 \begin{idea}
4398 ((mask (<name> <link number>)) <beg> <end>)
4399 \end{idea}
4400 where `beg' and `end' denote the beginning and ending of
4401 one particular region coming from the mask for the indicated
4402 link.
4404 I'm not sure this is really sufficient information. Should we know
4405 \emph{which part} of the mask we're dealing with? I.e., use something
4406 like a link-id, but for mask components?
4407 \end{notate}
4409 \begin{notate}{On `mark-up-region'} \label{mark-up-region}
4410 Like `add-to-scholia-property-within-region', but also adds to
4411 `current-markup' (see Note \ref{current-markup}).
4412 \end{notate}
4414 \begin{lisp}
4415 (defun mark-up-region (start end value)
4416 (add-to-scholia-property-within-region start end value)
4417 (setq current-markup
4418 (add-to-or-start-list current-markup
4419 (list value start end))))
4420 \end{lisp}
4422 \begin{notate}{On `non-printing-types'}
4423 This variable will record a list of the types of scholia that we
4424 typically don't want to print when displaying an article. The
4425 `derives-from' type is an example of a scholium that we typically
4426 don't want to print; see Note \ref{include-article}.
4428 User should temporarily set `non-printing-types' to `nil' before
4429 `mark-things-up' runs whenever they wish to display all scholia.
4430 \end{notate}
4432 \begin{lisp}
4433 (defvar non-printing-types nil)
4434 \end{lisp}
4436 \begin{notate}{Masking links} \label{masking-links}
4437 It is sometimes necessary to use links that point at something other
4438 than the thing that they were pointed at originally -- or more
4439 typically, the same thing, but found in a different place (Note
4440 \ref{updating-link-extent}).
4442 For example, consider the common case of a link pointing at some
4443 region of text found in a given article. If the linked-to article
4444 gets edited, the link under consideration may have to be adjusted if
4445 it is going to continue to point at the ``correct'' region.
4447 Thus, when a linked-to article changes, it will typically have to
4448 communicate changes to back to the linking article; or rather, to the
4449 metadata article associated with the linking article (Note
4450 \ref{metadata-article-overview}). These changes take the form of
4451 \emph{masks}, which cover and re-route links.
4453 A given mask may continue to change as the linked-to article changes.
4454 The strategy for keeping masks up-to-date is as follows. When we
4455 discover (at commit time) that a link needs to be redirected, an entry
4456 in the ``masks'' metadata field of the article containing the link is
4457 created or adjusted. Specifically, the new link(s) designed to
4458 replace the old link are stored as an entry on the ``masks'' list, as
4459 an ordered pair consisting of: (1) old link-id; followed by, (2) the
4460 new link(s) replacing the old one. Subsequent changes in the
4461 linked-to article cause old masks to be deleted and new masks to be
4462 swapped in; we never do ``recursive masking''.
4464 Mask-bearing links are clearly distinguished as such (at markup time),
4465 so that we can easily identify them later (when parsing markup). The
4466 function that generates the mask-identifying tags is
4467 `compute-usable-about-data' (Note \ref{compute-usable-about-data}),
4468 and the function that picks these tags out from among the others at
4469 commit time is `store-link-masks' (Note \ref{store-link-masks}).
4470 Indeed, `store-link-masks' is responsible for creating new masks as
4471 well.
4473 At the other end of the process, the function
4474 `compute-usable-about-data' examines each link from the \inp{about}
4475 data of the linking article together with any corresponding masks, and
4476 replaces any link that is masked with the data coming from that mask
4477 (Note \ref{compute-usable-about-data}).
4479 (Changes to the linking article's \inp{about} data can change
4480 link-id's, or do away with the requirement for a particular mask
4481 altogether -- this will have to be dealt with when we have mechanisms
4482 for changing \inp{about} data!)
4483 \end{notate}
4485 \begin{notate}{Masks} \label{masks}
4486 In light of the comments in Note \ref{masking-links}, it is possible
4487 to think of a mask as a map that takes a given link to to a region,
4488 and replaces it with a list of several regions.
4490 The format of a mask, then, is
4491 \begin{idea}
4492 ((<name> <link number>) &rest regions)
4493 \end{idea}
4494 where the regions are pairs (two-element lists), each giving the
4495 beginning and end of a region that the link is being redirected to.
4497 This format lacks generality! Certainly a link that is pointing to
4498 something other than a region may need to be redirected, for example,
4499 a link pointing at a page, when the page gets deleted. For the time
4500 being, these interesting cases can be dealt with through \emph{ad hoc}
4501 measures. Eventually we'll want to make a study of all of the
4502 different redirection cases; but getting the platform working
4503 reasonably well takes priority. (See also Note
4504 \ref{generality-of-masks}.)
4506 Finally, observe that the format used here is related to the format of
4507 the `current-markup' variable (Note \ref{current-markup}).
4509 For an interesting meditation on masking perceptions, see
4510 Lem\footnote{Stanislaw Lem, The Futurological Congress}.
4511 \end{notate}
4513 \begin{notate}{Generality of masks} \label{generality-of-masks}
4514 Once we have more general sorts of masks (Note \ref{masks}), we'll
4515 have a host of new and interesting conditions to consider. Different
4516 types of links will presumably have to be masked in different ways,
4517 and under different conditions.
4519 Furthermore, we will eventually be masking \inp{text} data as well as
4520 \inp{about} data.
4521 \end{notate}
4523 \begin{notate}{On `compute-usable-about-data'} \label{compute-usable-about-data}
4524 This function runs within the scope of `mark-things-up' (Note
4525 \ref{mark-things-up}). Its role is to identify the regions to be
4526 marked up, based on the \inp{about} data expressed by attached
4527 scholia, and augmented by any masks associated with this data. In
4528 short, this is the mask-applying part of the algorithm described in
4529 Note \ref{masking-links}.
4531 The way it works is as follows. We look through all of the links
4532 (\emph{although we really don't need to do this anymore, given that we
4533 have specifically identified the relevant links by using link-id'ed
4534 backlinks in the article being displayed; the change would have to
4535 come in at the level of `mark-things-up' or higher}) -- and if the
4536 link is relevant, then it will be reflected in the value returned by
4537 `compute-usable-about-data'. However, if the link is masked, it will
4538 be the mask that is reflected, instead of the link itself.
4540 Recall that we can't `assoc' the link across the masks; we need
4541 to `assoc' the link-id instead.
4543 The format of the return value is kind of ugly; we could almost
4544 certainly do without the extra `list' layer.
4546 Note that in the return value, the name of the \emph{scholium} is
4547 supplied, not the name of the linked-to article -- we'll subsequently
4548 know (when applying markup) that all of the links apply to the
4549 linked-to article, whereas we won't know where these links are coming
4550 from unless we record that specially.
4551 \end{notate}
4553 \begin{lisp}
4554 (defun compute-usable-about-data ()
4555 (let (usable-data
4556 (about (scholium-about scholium))
4557 (masks (get-metadata-field 'masks
4558 (scholium-name
4559 scholium)))
4560 (link-number 0))
4561 (dolist (link about)
4562 (setq link-number (1+ link-number))
4563 (when (link-about-article-p link name-of-current-article)
4564 (let* ((link-id (list (scholium-name scholium) link-number))
4565 (mask (assoc link-id masks)))
4566 (if mask
4567 (dolist (reg (cdr mask))
4568 (setq usable-data
4569 (add-to-or-start-list
4570 usable-data
4571 `((mask ,(car mask)) ,@reg))))
4572 (setq usable-data
4573 (add-to-or-start-list
4574 usable-data
4575 (append (list (list (scholium-name scholium)
4576 link-number))
4577 (let ((beg (link-beginning link)))
4578 (if beg
4579 (list beg (link-end link))
4580 (list nil))))))))))
4581 usable-data))
4582 \end{lisp}
4584 \begin{notate}{On `mark-things-up-customizations'} \label{mark-things-up-customizations}
4585 This may not have to be used.
4586 \end{notate}
4588 \begin{lisp}
4589 (defvar mark-things-up-customizations nil)
4590 \end{lisp}
4592 \begin{notate}{On `scholia-display-pre-update-hook'} \label{scholia-display-pre-update-hook}
4593 This gives us a chance to do various customizations to the environment
4594 before the main part of `mark-things-up' runs.
4596 I imagine that the role that it will play will be similar to the one
4597 played by the functions that run right in `pre-mark-up', namely to zap
4598 variables and settings that we don't want to have around anymore.
4599 \end{notate}
4601 \begin{lisp}
4602 (defvar scholia-display-pre-update-hook nil)
4603 \end{lisp}
4605 \begin{notate}{On `pre-mark-up' }
4606 This function generally zaps things, to prepare for markup.
4607 \end{notate}
4609 \begin{lisp}
4610 (defun pre-mark-up ()
4611 (setq current-markup nil)
4612 (save-excursion
4613 (set-buffer-to-rendering-target-buffer)
4614 (remove-list-of-text-properties (point-min)
4615 (point-max)
4616 '(scholia)))
4617 (mapcar #'delete-overlay main-article-overlays)
4618 (setq main-article-overlays nil)
4619 (setq scholia-count 0))
4620 \end{lisp}
4622 \begin{notate}{On `mark-things-up-hook'} \label{mark-things-up-hook}
4623 For unconditional customizations to `mark-things-up'.
4624 The functions added to this hook run after everything
4625 else `mark-things-up' does is done.
4626 \end{notate}
4628 \begin{lisp}
4629 (defvar mark-things-up-hook nil)
4630 \end{lisp}
4632 \begin{notate}{On `mark-things-up'} \label{mark-things-up}
4633 This function assembles text, text properties, and overlays: it is the
4634 main rendering engine, called by `display-article' to get
4635 scholia and appropriate markup onto the screen. It is important
4636 that `raw-scholia' be defined (and be a list of scholia)
4637 for this function to work properly.
4639 The first part of the plot is to delete the old markup; we call
4640 `pre-mark-up' to take care of this.
4642 A list of ``raw scholia'' is expected to be present in the context in
4643 which this function runs; typically this data is provided by
4644 `display-article' (see Note \ref{display-article}), but it can be
4645 supplied by any stand-in (e.g. `display-scholia-about-current-buffer'
4646 of Note \ref{display-scholia-about-current-buffer}).
4648 The raw scholia are first sorted using `sort-scholia-by-beg-position'
4649 (Note \ref{sort-scholia-by-beg-position}) and then translated into a
4650 usable form by `compute-usable-about-data' (Note
4651 \ref{compute-usable-about-data}).
4653 The function `mark-things-up' can handle different sorts of scholia
4654 differently (e.g., references are marked up in the conventional way);
4655 see Note \ref{ancillary-mark-things-up}.
4657 In order to \emph{selectively} display scholia, the `raw-scholia'
4658 variable should be modified before this function runs.
4659 \end{notate}
4661 \begin{lisp}
4662 (defun mark-things-up ()
4663 (pre-mark-up)
4664 (let ((scholia (sort-scholia-by-beg-position
4665 raw-scholia
4666 name-of-current-article)))
4667 (dolist (scholium scholia)
4668 (unless (typedata-includes-element-of-list
4669 (scholium-type scholium)
4670 non-printing-types)
4671 (let ((usable-about-data (compute-usable-about-data))
4672 (current-position-in-scholia-display (point)))
4673 (cond
4674 ((and
4675 (typedata-includes (scholium-type scholium) 'reference)
4676 (equal (reference-from-article scholium)
4677 name-of-current-article))
4678 (mark-up-reference))
4680 (mark-up-scholium)))))))
4681 (run-hooks 'mark-things-up-hook))
4682 \end{lisp}
4684 \begin{notate}{Ancillary functions for `mark-things-up'} \label{ancillary-mark-things-up}
4685 The functions that assemble and apply the markup, and in particular
4686 the value stored on the `scholia' property, run within the scope of
4687 `mark-things-up'. The `scholia' property is built according to
4688 the description from Note \ref{the-scholia-property}.
4690 References are rendered by `mark-up-reference'; regular
4691 scholia are rendered by `mark-up-scholium'. \emph{Note that there are
4692 only two different nontrivial kinds of markup at present.}
4694 Some \emph{very} ancillary functions are described in Note
4695 \ref{functions-for-adding-overlays}.
4696 \end{notate}
4698 \begin{notate}{Functions for adding overlays} \label{functions-for-adding-overlays}
4699 These function run within the scope of `mark-up-scholium' to
4700 add overlays to the display.
4701 \end{notate}
4703 \begin{lisp}
4704 (defun add-overlays-in-scholia-display-buffer ()
4705 (setq scholia-overlays
4706 (cons
4707 (make-overlay current-position-in-scholia-display
4708 (point)
4709 (get-buffer "Scholia Display")
4711 scholia-overlays))
4712 (overlay-put (car scholia-overlays)
4713 'face (scholium-face)))
4715 (defun add-overlays-in-rendering-target-buffer ()
4716 (setq main-article-overlays
4717 (cons
4718 (make-overlay (second elt)
4719 (third elt)
4720 (get-rendering-target-buffer)
4722 main-article-overlays))
4723 (overlay-put (car main-article-overlays)
4724 'face (scholium-face)))
4725 \end{lisp}
4727 \begin{notate}{On `mark-up-reference'} \label{mark-up-reference}
4728 We call this function from `mark-things-up' (Note
4729 \ref{mark-things-up}) to render a scholium if it has reference type
4730 and its \inp{about} data indicates that that the reference originates
4731 from (i.e., appears in) the current article. See Note
4732 \ref{reference-access-functions} for a description of the format of
4733 the return value of the function `reference-source-link' used here.
4735 References should perhaps be rendered differently depending on their
4736 sub-type (in particular, a different face could be used for references
4737 with different sub-types).
4739 (Do we really want to loop through all of the elements of
4740 `usable-about-data'? Mightn't there be something there corresponding
4741 to the linked-to article?)
4742 \end{notate}
4744 \begin{lisp}
4745 (defun mark-up-reference ()
4746 (save-excursion
4747 (set-buffer-to-rendering-target-buffer)
4748 (dolist (elt usable-about-data)
4749 (mark-up-region (second elt)
4750 (third elt)
4751 (first elt))
4752 (when use-crazy-font-lock
4753 (setq main-article-overlays
4754 (cons
4755 (make-overlay (second elt)
4756 (third elt)
4757 (get-rendering-target-buffer)
4759 main-article-overlays))
4760 (overlay-put (car main-article-overlays)
4761 'face 'sch-reference-face)))))
4762 \end{lisp}
4764 \begin{notate}{Using the `scholia' property for everything!} \label{using-scholia-property-for-everything}
4765 Notice that we use the same `scholia' property for references, and not
4766 some special property. This seems to make reparsing easier (see
4767 Section \ref{parsing}) -- but we can also easily filter the
4768 references out of the collection of all scholia when needed (Note
4769 \ref{follow-reference}).
4770 \end{notate}
4772 \begin{notate}{Alternate reference display}
4773 In Note \ref{references} we asserted that references will be displayed
4774 as markup. However, we could certainly set things up so that we could
4775 switch between the normal view and a view where references are
4776 displayed as ``proper scholia''.
4777 \end{notate}
4779 \begin{notate}{On `mark-up-scholium'}
4780 This inserts scholia and marks them up, together with the marked up
4781 regions (when these exist; the function does both whole-article
4782 scholia and region-specific scholia).
4784 The `scholia-count' variable is set for purposes of face selection;
4785 see Note \ref{color-by-number}.
4786 \end{notate}
4788 \begin{lisp}
4789 (defun mark-up-scholium ()
4790 ;; this part takes place in the scholia display buffer
4791 (insert (sch-plain-text (scholium-name scholium)))
4792 (add-to-scholia-property-within-region
4793 current-position-in-scholia-display
4794 (point)
4795 ;; add a list to make it possible to reuse the scholium property
4796 (list (scholium-name scholium)))
4797 (when use-crazy-font-lock
4798 (add-overlays-in-scholia-display-buffer))
4799 (insert "\n\n")
4800 ;; this part is relevant to the buffer containing the main article
4801 (dolist (elt usable-about-data)
4802 (when (second elt)
4803 (save-excursion
4804 (set-buffer-to-rendering-target-buffer)
4805 (mark-up-region (second elt)
4806 (third elt)
4807 (first elt))
4808 (when use-crazy-font-lock
4809 (add-overlays-in-rendering-target-buffer)))))
4810 ;; adjust count once everything else is done here, so same count
4811 ;; applies in both buffers (useful for coloration purposes)
4812 (setq scholia-count (1+ scholia-count)))
4813 \end{lisp}
4815 \begin{notate}{Markup in the Scholia Display buffer} \label{markup-in-scholia-buffer}
4816 There is no technical reason to use overlays here, because we assume
4817 that this buffer is not subject to font-lock (i.e. we could use text
4818 properties for everything). But, for the sake of uniformity, we
4819 always use overlays for fontification. Also, there's no particular
4820 reason to maintain the `scholia' property as a list in this buffer, but
4821 we do that too.
4822 \end{notate}
4824 \begin{notate}{Make ``Scholia Display'' read-only?}
4825 Maybe `mark-things-up' should set and unset read-only status for the
4826 Scholia Display buffer. Some of the functions we've written so far do
4827 toggle read-only status. We should make a firm decision one way or
4828 the other!
4830 At present, it seems to me that it is best to have it be editable and
4831 have code ready to propagate changes back to their sources. Indeed,
4832 this would make a good example of the power of this system. See Note
4833 \ref{precedent-for-identification}.
4834 \end{notate}
4836 \subsubsection{Further notes on marking things up}
4838 \begin{notate}{Highlighting the current scholium}
4839 Note that it may prove to be useful to highlight the \emph{current}
4840 scholium in some way, or current \emph{scholia} with some kind of
4841 color-coded depth showing how many scholia are about the current piece
4842 of text. (``Current'' here comes from where the point is in the main
4843 article display, but I suppose it might be reasonable to do something
4844 similar with the scholia display buffer.)
4845 \end{notate}
4847 \begin{notate}{Semantics of color}
4848 The actual markup behavior should depend on the semantics that are
4849 currently \emph{en vogue}, see Note \ref{color-and-style} and Note
4850 \ref{user-crafted-semantics}. Maybe we should be using a hook or a
4851 redefinable function to handle the ``when use-crazy-font-lock'' case.
4852 \end{notate}
4854 \begin{notate}{Lots of different overlay styles possible} \label{overlay-styles}
4855 In theory we could have a lot of different overlay styles.
4856 Implementing these styles seems a little tricky, but isn't too
4857 impossible. Note that some of the different overlay setups may
4858 benefit from having more information than just the name stored locally
4859 (assuming that it takes a lot of time to look things up by name to
4860 find more properties, which isn't necessarily a fair assumption in the
4861 case of hash tables).
4863 One example of something that would be nice would be to have nested
4864 scholia display well. (I'm sure they would even work consistently at
4865 present.) It may be that delimiters would be a more effective way of
4866 illustrating such relationships.
4867 \end{notate}
4869 \begin{notate}{Sometimes we don't want overlays at all}
4870 Another point is that sometimes we don't want overlays to show up at
4871 all -- they could be very distracting when attached to code, for
4872 example. Whether or not an overlay is shown in a given instance may
4873 depend on global state variables, properties of the article that is
4874 being marked up, or specific data that has been stored as part of a
4875 scholium. (We'll have to add more code to handle these sorts of
4876 criteria.)
4877 \end{notate}
4879 \begin{notate}{Emacs task: blinking?} \label{blinking}
4880 This is a pretty minor issue, but it would be cool to hack a
4881 \emph{display independent} blink property into emacs. Blinking
4882 already works for cursors. So, how to do it for text? The point is
4883 that if there was a ``blink'' feature in Emacs, the ``move to region''
4884 things could make the text they find blink (this would work for
4885 monochrome displays of Note \ref{monochrome} just as well as any
4886 other).
4887 \end{notate}
4889 \begin{notate}{Displaying nearby scholia} \label{displaying-nearby-scholia}
4890 A nice display system will put some of the scholia nearby the current
4891 document onscreen. The default operation of `mark-things-up'
4892 (performed through the offices of `sort-scholia-by-beg-position') is
4893 to show an article together with \emph{its} scholia in order; Note
4894 \ref{ancestors} talks about going the other way. But we can do still
4895 more complicated things.
4897 People like having nearby things to look at. This is one reason that
4898 print dictionaries, for example, are kind of fun. You look at the
4899 dictionary, and you can see words that are nearby lexicographically;
4900 sometimes they are related and sometimes they aren't.
4902 In different contexts, different sorts of ``closeness'' may be
4903 relevant, and different sorts semantics would help make the contextual
4904 display useful.
4905 \end{notate}
4907 \subsection{Display interface} \label{display-interface}
4909 \begin{notate}{Selective Displays} \label{selective-displays}
4910 More selective displays could be offered. For example, we might
4911 display only the articles that are ``about'' the current article
4912 \emph{and} that are of some specified ``type''. We could also take
4913 bookkeeping information into account, or ``meta-level'' information
4914 like what subcollection (or namespace?) of the digital library the
4915 article is located in. Metalevel information (maybe by definition)
4916 comes from outside of the system itself, for example, we might display
4917 only scholia from a certain directory. These sorts of deployments are
4918 where the real power of this system lies. (See Note
4919 \ref{selection-methods} for general comments along these lines, and
4920 Note \ref{ancestors} for somewhat similar thoughts along a diverging
4921 line.)
4922 \end{notate}
4924 \subsubsection{Different treatment for buffered and non-buffered articles}
4926 \begin{notate}{On `rendering-target-buffer'} \label{rendering-target-buffer}
4927 If a given \inp{name} is associated with a buffered article, then that
4928 buffer will be where the article is displayed. If the article to be
4929 displayed is in a buffer, this variable will be set that buffer
4930 object. Otherwise it will be set to nil.
4931 \end{notate}
4933 \begin{lisp}
4934 (defvar rendering-target-buffer nil)
4935 \end{lisp}
4937 \begin{notate}{Dealing with killed buffers} \label{killed-buffers}
4938 For some reason, `rendering-target-buffer' gets set to the ``killed
4939 buffer'' object when the buffer containing the main article is killed.
4940 That isn't nice; presumably we'll need to add a function to the
4941 `kill-buffer-hook' that will ensure that if this buffer is killed,
4942 this variable will be set back to nil (or whatever it should in fact
4943 be set to). We will presumably also have to remove this function from
4944 the hook when the main article changes.
4945 \end{notate}
4947 \begin{notate}{Better way to name (or access) buffered articles} \label{name-or-access-buffered-articles}
4948 Either we should search on the \inp{text} field for the current
4949 buffer, and ignore the name, or we should store the ``official'' name
4950 of the buffer as a buffer-local variable. (E.g. this buffer
4951 \emph{should} be called ``SBDM for CBPP'' but
4952 `display-scholia-about-current-buffer' can, at present, only access
4953 the buffer by its `buffer-name'. I think that adding a buffer-local
4954 variable at creation time would probably be very straightforward, then
4955 we just need to look-up that variable instead of using `buffer-name'.
4956 (Of course, we could make `buffer-name' be the default for the
4957 ``buffer article name''.) Note that unless the article is created by
4958 the approved means, we won't have a chance to store the variable; this
4959 suggests that the display section should come after the creation
4960 section (which makes plenty of sense). Note that \emph{everywhere}
4961 `buffer-name' appears in this paper things will have to be modified if
4962 we make this sort of switch.
4963 \end{notate}
4965 \subsubsection{Display mechanics}
4967 \begin{notate}{What just happened to the screen?}
4968 The simple display mechanism we use here will overwhelm your whole
4969 display (see Note \ref{scholia-overwhelm-display}); use {\tt M-x
4970 back-to-normal} to return to the pre-display window configuration.
4971 \end{notate}
4973 \begin{notate}{Making `sch-plain-text' work with weird types}
4974 We should either make sure that `sch-plain-text' can handle all
4975 articles with many different \inp{type}s.
4976 \end{notate}
4978 \begin{notate}{On `scholia-display-post-update-hook'}
4979 This provides a way to customize the article (and
4980 scholia) being displayed.
4981 \end{notate}
4983 \begin{lisp}
4984 (defvar scholia-display-post-update-hook nil)
4986 (add-to-list 'non-printing-types 'fake)
4987 \end{lisp}
4989 \begin{notate}{On `scholia-display-extras-hook'} \label{scholia-display-extras-hook}
4990 This hook is run at the end of `scholia-display-extras'
4991 (Note \ref{scholia-display-extras}) and allows for easy
4992 tweaking of the scholia display (for example, displaying
4993 special sorts of scholia for articles with certain types).
4995 Some basic additions to this hook appear in Section
4996 \ref{linear-browsing}.
4997 \end{notate}
4999 \begin{notate}{On `scholia-display-extras'} \label{scholia-display-extras}
5000 This is used to add some extra stuff to the Scholia Display for
5001 purposes of navigation and establishing context. It is called by
5002 `display-article' (Note \ref{display-article}) and
5003 `display-scholia-about-current-buffer' (Note
5004 \ref{display-scholia-about-current-buffer}).
5006 It might be nice to have this in the main article window, but that
5007 could also be confusing, especialy if the main article is associated
5008 with some buffer; so I'm taking the route of caution here. Also note
5009 that according to the principle of order \ref{principle-of-order} this
5010 stuff should probably appear much later on in the document, perhaps in
5011 Section \ref{linear-browsing}.
5013 It might be more appropriate to have some of these extra features
5014 display in or above the main article buffer; the info system has a
5015 nice un-editable bar for display of various navigational data.
5016 \end{notate}
5018 \begin{lisp}
5019 (defun scholia-display-extras ()
5020 ;; this setting is useful for presentations.
5021 (goto-char (point-min))
5022 ;; Be careful that this is ignored when the article is saved or
5023 ;; otherwise processed internally.
5024 (insert
5025 "Title: "
5026 (propertize (format "%s" name-of-current-article) 'face 'italic)
5027 "\n\n")
5028 (goto-char (point-max))
5029 (run-hooks 'scholia-display-extras-hook)
5030 (goto-char (point-min)))
5031 \end{lisp}
5033 \begin{notate}{More than one parent} \label{more-than-one-parent}
5034 We'll want to allow \emph{more than one} parent eventually; compare
5035 what happens when following a scholium/reference in a region that has
5036 more than one of these things written about it. For the purposes of
5037 markup, ``parent'' may become a variable (so add `(reference-to-parent
5038 foo)' for the foo parent) and maybe, if the various reference scholium
5039 objects created here are actually helpful, make them include lists of
5040 references? Multi-references haven't been done anywhere in this code
5041 so far, but they seem like a reasonable idea. See also Note
5042 \ref{forward-in-parent}, Note \ref{backward-in-parent}.
5043 \end{notate}
5045 \begin{notate}{Text for display purposes only} \label{display-purposes-only}
5046 I think the setup will work so that individual sections that bear
5047 identification markup will all have their changes propagated properly,
5048 i.e., independently. However, I think we may have to do a little more
5049 work to make sure that the name of the article (currently shown in
5050 italics whenever an article is displayed, though it would probably be
5051 nicer to emulate the style used by {\tt info}) and any other
5052 after-the-fact textual additions are ignored whenever the article is
5053 saved.
5054 \end{notate}
5057 \subsubsection{Display styles}
5059 \begin{notate}{On `display-style'} \label{display-style}
5060 As discussed in Section \ref{stylistic-considerations}, there are a
5061 number of different styles we'd like to offer users to choose between
5062 when they go to display an article. For now, the relevant settings
5063 for the display style variable are `plain' (the default, displaying
5064 all scholia) and `contextual' (which causes only those scholia
5065 associated with the region being displayed to appear; see Note
5066 \ref{contextual-display}).
5068 There are a few problems here: if we go with the contextual display,
5069 what about scholia that apply to the article as a whole? That's a
5070 little tricky. I guess for now we just leave them out?
5072 Set this variable with `set-display-style', not manually.
5073 \end{notate}
5075 \begin{lisp}
5076 (defvar display-style 'plain)
5077 \end{lisp}
5079 \begin{notate}{On `window-displayed-substring'}
5080 This variable will hold the string that is being shown
5081 through a given window at a given point in time.
5082 \end{notate}
5084 \begin{lisp}
5085 (defvar window-displayed-substring nil)
5086 \end{lisp}
5088 \begin{notate}{On `set-display-style'} \label{set-display-style}
5089 Use this function to control the setting of `display-style' (Note
5090 \ref{display-style}). Relevant arguments are `plain', or
5091 `contextual'.
5093 (Actually, anything but `contextual' will set `display-style' to
5094 its default setting. Eventually, we might want to be able to
5095 have contextual display together with some other non-default features,
5096 at which point we'll have to adjust this function appropriately.)
5097 \end{notate}
5099 \begin{lisp}
5100 (defun set-display-style (style)
5101 (cond ((eq style 'contextual)
5102 ;; we may need a "double hook" here, so we get the local
5103 ;; hooks set up in the correct window
5104 (add-hook 'display-article-hook
5105 'initiate-contextual-updating)
5106 (setq display-style 'contextual))
5108 (remove-hook 'display-article-hook
5109 'initiate-contextual-updating)
5110 (setq display-style 'plain))))
5111 \end{lisp}
5113 \begin{notate}{On `initiate-contextual-updating'}
5114 This function gets the rendering target buffer set up
5115 to do live-updating of scholia.
5117 For now, this function doesn't do anything for labels -- since
5118 for now, labels typically don't have scholia on their \inp{text}.
5119 However, this can be undone later, if necessary.
5121 In addition, we don't yet have any code for getting rid of contextual
5122 updating in an individual buffer OTF.
5123 \begin{idea}
5124 (remove-hook 'window-scroll-functions
5125 'set-window-displayed-substring t)
5126 \end{idea}
5127 \end{notate}
5129 \begin{lisp}
5130 (defun initiate-contextual-updating ()
5131 (unless (typedata-includes (scholium-type article) 'label)
5132 (save-excursion (set-buffer rendering-target-buffer)
5133 (add-hook 'window-scroll-functions
5134 'maybe-update-scholia-display nil t))))
5135 \end{lisp}
5137 \begin{notate}{On `maybe-update-scholia-display'} \label{maybe-update-scholia-display}
5138 In order for this to work optimally, we'd might to keep track of
5139 a list of the current scholia that are being displayed. But
5140 for now, I suppose (contrary to this function's name) we can just
5141 redisplay all the scholia we encounter every time.
5142 \end{notate}
5144 \begin{lisp}
5145 (defun maybe-update-scholia-display ()
5146 (set-window-displayed-substring)
5147 ;; this is just a ridiculous thing to run -- for testing purposes
5148 ;; only. Eventually, we'll actually want to analyse the text,
5149 ;; figure out which scholia are relevant, and update the scholia
5150 ;; display.
5151 (save-excursion (set-buffer (get-buffer-create "*scratch*"))
5152 (erase-buffer)
5153 (insert window-displayed-substring)))
5154 \end{lisp}
5156 \begin{notate}{On `set-window-displayed-substring'}
5157 This function will be an element of the `window-scroll-functions'
5158 hook when the display mode is set to `contextual'.
5159 \end{notate}
5161 \begin{lisp}
5162 (defun set-window-displayed-substring
5163 (setq window-displayed-substring
5164 (buffer-substring (window-start)
5165 (window-end))))
5166 \end{lisp}
5168 \subsubsection{Displaying articles}
5170 \begin{notate}{On `display-article-hook'}
5171 We will later do some ``interesting'' things with this function, so we
5172 add a hook. For example, one use for this hook is to maintain a
5173 history of articles that have been displayed; see Section
5174 \ref{temporal}.
5175 \end{notate}
5177 \begin{lisp}
5178 (defvar display-article-hook nil)
5179 \end{lisp}
5181 \begin{notate}{On `raw-scholia-selector'}
5182 This function is here both to select raw scholia for display when
5183 `display-article' runs, and to provide for a choice between different
5184 ways of selecting raw scholia. It returns a list of scholia.
5186 This function is set up to run within the scope of `display-article'
5187 (Note \ref{display-article}).
5189 We select slightly different scholia when the article that is being
5190 displayed is a label; in particular, we don't want to display scholia
5191 that indicate the current article as a `parent', since these scholia
5192 will already be listed in the label's \inp{text} itself.
5194 If we're trying to display scholia contextually, then this function
5195 should probably be doctored with some, to make it so that the initial
5196 set of scholia that are displayed are contextually appropriate, i.e.,
5197 are just those associated with the on-screen portion of the buffer
5198 that is being displayed.
5199 \end{notate}
5201 \begin{lisp}
5202 (defun raw-scholia-selector (&optional what-is-displayed)
5203 (cond ((eq what-is-displayed 'label)
5204 (remove-if
5205 (lambda (scholium)
5206 (member-if (lambda (link)
5207 (member 'parent (cdr link)))
5208 (scholium-about scholium)))
5209 (mapcar (lambda (backlink)
5210 (get-article (car backlink)))
5211 (get-backlinks name-of-current-article))))
5212 (t (mapcar (lambda (backlink)
5213 (get-article (car backlink)))
5214 (get-backlinks name-of-current-article)))))
5216 ;; (eq display-style 'contextual)
5217 ;; (save-excursion (set-buffer (get-buffer-create "*scratch*"))
5218 ;; (erase-buffer)
5219 ;; (insert window-displayed-substring))
5220 ;; nil
5221 \end{lisp}
5223 \begin{notate}{On `display-article'} \label{display-article}
5224 Display article found via \inp{path} (which can just be the name of an
5225 article in the main article tabel), if said article exists. If the
5226 article lives in a buffer, that buffer will be where the article is
5227 displayed; otherwise the article is displayed in the ``Main Article
5228 Display'' buffer. Note that this function can also be used to display
5229 labels (it calls `display-label'; but see Note
5230 \ref{display-scholia-about-labels}, since some other approach might be
5231 valuable sometimes).
5233 I don't want to have all of the children appear as scholia when a
5234 label is browsed, at least not by default; but it is kind of neat to
5235 know that they can be made to appear; if we don't do the `remove-if'
5236 then the scholia display will be the OTF-assembled compilation
5237 mentioned in Note \ref{bits-and-pieces}.
5239 It makes more sense to always run `display-article-hook' after the
5240 `cond', and to put things that are conditional upon being in this
5241 specific branch into `scholia-display-post-update-hook' or, barring
5242 that, some additional branch-specific hook. This of course means that
5243 the parent will be added to the history list if that is where we
5244 browse from; this is intended.
5246 If it turns out to be needed here, we could reuse the trick of running
5247 a hook and then making a test before the `cond', which we're familiar
5248 with from e.g. `sch-plain-text' (Note \ref{sch-plain-text}).
5250 It would be good to make the buffer disposition (left? right?)
5251 is consistent when we use this function to display labels; I
5252 think we have it sorted out properly for the display of
5253 ``normal'' articles.
5255 We may want to treat namespaces and labels together in the same
5256 `cond' branch (currently namespaces aren't handled specially by
5257 this function).
5259 Since we are now reading in paths, these paths have to be parsed.
5260 This is the job of `generalized-get-article' (see Note
5261 \ref{generalized-get-article}).
5262 \end{notate}
5264 \begin{lisp}
5265 (defun display-article (path)
5266 (interactive (list (read-article-path)))
5267 (let* ((article (generalized-get-article path))
5268 (name (scholium-name article)))
5269 (if (not article)
5270 (error "No article by that name found")
5271 (setq name-of-current-article name)
5272 (cond
5273 ((typedata-includes (scholium-type article) 'label)
5274 (display-label name)
5275 (setq rendering-target-buffer "*Generic List*")
5276 (switch-to-buffer (get-buffer "*Generic List*"))
5277 (setq buffer-read-only nil)
5278 (switch-to-buffer (get-buffer-create "Scholia Display") t)
5279 (erase-buffer)
5280 (let ((raw-scholia (raw-scholia-selector 'label)))
5281 (mark-things-up))
5282 (scholia-display-extras)
5283 (switch-to-buffer (get-buffer "*Generic List*"))
5284 (setq buffer-read-only t)
5285 (pop-to-buffer "Scholia Display")
5286 (other-window -1))
5288 (if (article-buffered article)
5289 (setq rendering-target-buffer (scholium-text article))
5290 (setq rendering-target-buffer nil))
5291 (run-hooks 'scholia-display-pre-update-hook)
5292 (scholia-overwhelm-display (sch-plain-text article))
5293 (let ((raw-scholia (raw-scholia-selector)))
5294 (mark-things-up))
5295 (scholia-display-extras)
5296 (pop-to-buffer (get-rendering-target-buffer))
5297 (run-hooks 'scholia-display-post-update-hook)))
5298 (run-hooks 'display-article-hook))))
5299 \end{lisp}
5301 \begin{notate}{Argument of `display-article' is typically a string}
5302 Note that for typical interactive use, a string is expected, which
5303 means a string is produced, which means that when `get-article' is
5304 called in the next line, bad things will happen for articles whose
5305 names are not strings -- unless we do something about it.
5306 \end{notate}
5308 \begin{notate}{Would have liked to associate a type with paths} \label{associate-a-type-with-paths}
5309 It would be nice to use a special type of object to distinguish
5310 between paths and names. (I.e., if `read-article-path' returns an
5311 object of type path when it actually builds a path and
5312 `generalized-get-article' looks for this type before deciding what to
5313 do, we could be OK just passing in an article name to the generalized
5314 function.) But I'm not sure how to assert that a given form has a
5315 given type (or even whether this is possible). Maybe by working with
5316 structs one could do it, but I don't understand structs (their
5317 documentation seems to be lacking).
5319 Note, the idea of associating a type with a form seems very
5320 scholiumific. But I've forgotten whether Lisp has anything for doing
5321 this.
5322 \end{notate}
5324 \begin{notate}{On `redisplay-article'}
5325 This accomplishes a simple task.
5327 It would be nice if we could get the point restored to
5328 its original position after this thing runs.
5330 Also, it would be good to have the function run automatically
5331 after scholia have been added about the document.
5332 \end{notate}
5334 \begin{lisp}
5335 (defun redisplay-article ()
5336 (interactive)
5337 (display-article name-of-current-article))
5338 \end{lisp}
5340 \subsubsection{Displaying scholia about a given buffer}
5342 \begin{notate}{On `display-scholia-about-current-buffer'} \label{display-scholia-about-current-buffer}
5343 This function is similar to `display-article' (\ref{display-article}),
5344 but it works directly on the buffer level. (Stylistically this
5345 function should probably just be a thin wrapper, but we're running
5346 with it for now.)
5348 This function should perhaps check to see whether the
5349 current buffer has been \emph{edited} since the last time
5350 this function (or similar, through other means) was executed.
5351 If the buffer has been edited, the user should probably
5352 be prompted, and asked whether to reparse (Section \ref{parsing})
5353 before redisplaying.
5354 \end{notate}
5356 \begin{lisp}
5357 (defun display-scholia-about-current-buffer ()
5358 (interactive)
5359 (let ((article (get-article (buffer-name (current-buffer)))))
5360 (if article
5361 (progn
5362 (setq rendering-target-buffer (current-buffer))
5363 (run-hooks 'scholia-display-pre-update-hook)
5364 (scholia-overwhelm-display (sch-plain-text article))
5365 (let ((raw-scholia
5366 (mapcar (lambda (backlink)
5367 (get-article (car backlink)))
5368 (get-backlinks name-of-current-article))))
5369 (mark-things-up))
5370 (scholia-display-extras)
5371 (pop-to-buffer (get-rendering-target-buffer))
5372 (run-hooks 'scholia-display-post-update-hook)
5373 ;; weird!
5374 (run-hooks 'display-article-hook))
5375 (call-if-user-adds-current-buffer-to-article-list
5376 'display-scholia-about-current-buffer))))
5377 \end{lisp}
5379 \begin{notate}{Running `display-article-hook' from `display-scholia-about-current-buffer'?}
5380 It seems a bit little weird to have to run this hook here.
5381 \end{notate}
5383 \begin{notate}{Automatically display scholia about any found buffer}
5384 It might be handy to integrate the scholium system into
5385 day-to-day Emacs operation by adding
5386 `display-scholia-about-current-buffer' to the `find-file-hook'.
5387 \end{notate}
5389 \begin{notate}{Displaying a generic buffer together with scholia}
5390 You should be able to simply call
5391 `display-scholia-about-current-buffer' after loading the buffer
5392 (\emph{untested}). To turn it on all the time, add it to the
5393 appropriate hook. Note that this won't add any new scholia to the
5394 system. (To add new scholia at \emph{file} load time, we'll need some
5395 additional code.)
5396 \end{notate}
5398 \subsubsection{Displaying labels} \label{displaying-labels}
5400 \begin{notate}{On `display-label-hook'}
5401 This provides a way to customize the behavior of
5402 `display-label'.
5403 \end{notate}
5405 \begin{lisp}
5406 (defvar display-label-hook nil)
5407 \end{lisp}
5409 \begin{notate}{On `currently-displayed-label'}
5410 This gives us a handle on the most recently displayed
5411 label. This facilitates only the simplest
5412 improvement to reverting behavior.
5413 \end{notate}
5415 \begin{lisp}
5416 (defvar currently-displayed-label nil)
5417 \end{lisp}
5419 \begin{notate}{On `display-label'} \label{display-label}
5420 The function `display-label' uses the catalog browsing feature of
5421 Section \ref{catalog}. If we want to do other interesting rendering
5422 things with articles that have special types, we can follow the usage
5423 of `display-label' in `display-article'. It might be good for this
5424 function to run its own hook, e.g., for maintaining a special history
5425 (see \ref{history-for-listing}).
5426 \end{notate}
5428 \begin{lisp}
5429 (defun display-label (name)
5430 (interactive
5431 (list
5432 (let* ((completion-ignore-case t)
5433 (label-names
5434 (scholium-text (get-article 'label)))
5435 (label-strings (mapcar (lambda (name)
5436 (format "%s" name))
5437 label-names))
5438 (string-found (completing-read
5439 "Label: "
5440 label-strings))
5441 (place (- (length label-strings)
5442 (length (member string-found label-strings)))))
5443 (nth place label-names))))
5444 (article-menu-listing (label-to-propertized-list name))
5445 (run-hooks 'display-label-hook))
5447 (add-hook 'display-label-hook (lambda ()
5448 (setq currently-displayed-label name)))
5450 (defalias 'list-label 'display-label)
5451 \end{lisp}
5453 \begin{notate}{On `display-intersection-of-labels'} \label{display-intersection-of-labels}
5454 For displaying everything bearing every one of the
5455 input \inp{labels}.
5456 \end{notate}
5458 \begin{lisp}
5459 (defun display-intersection-of-labels (&rest labels)
5460 (let ((intersection (label-to-list (car labels)))
5461 (ctn (cdr labels)))
5462 (while ctn
5463 (setq intersection (intersection intersection
5464 (label-to-list (car ctn))
5465 :test 'equal))
5466 (setq ctn (cdr ctn)))
5467 (article-menu-listing (turn-list-into-propertized-list
5468 intersection))))
5469 \end{lisp}
5471 \begin{notate}{On `display-difference-of-labels'} \label{display-difference-of-labels}
5472 For purposes of simplicity, this is set up to work with two labels
5473 only, for the time being.
5474 \end{notate}
5476 \begin{lisp}
5477 (defun display-difference-of-labels (label-A label-B)
5478 (article-menu-listing (turn-list-into-propertized-list
5479 (set-difference (label-to-list label-A)
5480 (label-to-list label-B)))))
5481 \end{lisp}
5483 \begin{notate}{Label derivatives} \label{label-derivatives}
5484 It might be the case that someone
5485 would want to add a new label to the elements of an intersection
5486 or difference (as would be found by internal routines of
5487 `display-intersection-of-labels' and `display-difference-of-labels').
5488 \end{notate}
5490 \begin{notate}{Display type in another column}
5491 Probably it would be good to have another accessor that would
5492 show the article's type in a second column. This could be
5493 especially useful in a context in which a section can contain
5494 both notes and subsections (just for example).
5495 \end{notate}
5497 \begin{notate}{Display scholia about labels too, at least sometimes} \label{display-scholia-about-labels}
5498 It would probably be good to be able to be able to compose and
5499 display scholia about labels, since they are, after all,
5500 also articles. Probably this should be optional, since there are
5501 times when we just want to see the list and not think of it as
5502 an article. And in addition, if we do plan to display scholia
5503 about labels only sometimes, we'll have to decide what to do with
5504 the contents of the scholia display buffer at times when we just
5505 want to display the list and not its scholia. One trick might be to
5506 make the listing prefer to appear in the window wherein the scholia
5507 are displayed in such a case, if it exists; this way both windows
5508 wouldn't confusingly appear at the same time. (Compare Note
5509 \ref{redisplay-after-running-make-scholium}.)
5510 \end{notate}
5512 \subsubsection{Finding marked regions} \label{finding-marked-regions}
5514 \begin{notate}{On `find-marked-regions'}
5515 This function is used in the subsequent section (Section
5516 \ref{overlays-on-off}) to locate the parts of the buffer
5517 that have scholia written about them. Note that
5518 this scheme might have been outmoded by stuff in Section
5519 \ref{parsing}.
5520 \end{notate}
5522 \begin{lisp}
5523 (defun find-marked-regions ()
5524 (let (names-and-positions
5525 (next-change-point (point-min)))
5526 (while next-change-point
5527 (let ((next-region (find-next-marked-region)))
5528 (when next-region
5529 (setq names-and-positions
5530 (cons next-region
5531 names-and-positions)))))
5532 names-and-positions))
5533 \end{lisp}
5535 \begin{notate}{On `find-next-marked-region'}
5536 This function is within the scope of `find-marked-regions'. Should be
5537 able to find all the regions associated with any scholium. Right now,
5538 this function is working in a simplified universe in which scholia and
5539 regions are mapped to each other in 1-1 way!
5540 \end{notate}
5542 \begin{lisp}
5543 (defun find-next-marked-region ()
5544 (let* ((beg (next-single-property-change next-change-point
5545 'scholia))
5546 (end (when beg
5547 (next-single-property-change beg
5548 'scholia))))
5549 (setq next-change-point end)
5550 (when end
5551 (list
5552 (get-text-property beg 'scholia)
5553 (list (cons beg end))))))
5554 \end{lisp}
5556 \subsubsection{Turning overlays off and on} \label{overlays-on-off}
5558 \begin{notate}{Overlays exercises}
5559 As an exercise with text properties and overlays, here is some code
5560 for turning the overlays on and off in the Scholium Display and main
5561 article buffers.
5562 \end{notate}
5564 \begin{notate}{Turning overlays off}
5565 It is easy enough to turn overlays off; this is accomplished for the
5566 main article buffer and the Scholia Display buffer by
5567 `sch-turn-main-article-overlays-off' and
5568 `sch-turn-scholia-overlays-off', respectively.
5569 \end{notate}
5571 \begin{lisp}
5572 (defun sch-turn-main-article-overlays-off ()
5573 (interactive)
5574 (mapcar #'delete-overlay main-article-overlays)
5575 (setq main-article-overlays nil))
5577 (defun sch-turn-scholia-overlays-off ()
5578 (interactive)
5579 (mapcar #'delete-overlay scholia-overlays)
5580 (setq scholia-overlays nil))
5581 \end{lisp}
5583 \begin{notate}{Turning overlays on}
5584 Turning overlays on is a bit trickier. In order to be able to turn
5585 scholia on, we need to be able to find all the regions that have
5586 scholia attached to them. This is accomplished (for the main article
5587 buffer only, I think) by `find-marked-regions'.
5588 \end{notate}
5590 \begin{lisp}
5591 (defun sch-turn-main-article-overlays-on ()
5592 (interactive)
5593 ;; to save from potential overlap weirdness
5594 (sch-turn-main-article-overlays-off)
5595 (save-excursion
5596 (let ((names-and-positions (find-marked-regions)))
5597 (dolist (info names-and-positions)
5598 (let* ((name (car info))
5599 (marked-regions (cadr info))
5600 (scholium (get-article name))
5601 (beg (point)))
5602 (save-excursion
5603 (set-buffer-to-rendering-target-buffer)
5604 (dolist (reg marked-regions)
5605 ;; add "transient" overlay
5606 (when use-crazy-font-lock
5607 (setq main-article-overlays
5608 (cons
5609 (make-overlay (car reg)
5610 (cdr reg)
5611 (get-rendering-target-buffer)
5613 main-article-overlays))
5614 ;; using `scholium-face' here is a bit weird
5615 (overlay-put (car main-article-overlays)
5616 'face (scholium-face))))))))))
5618 (defun sch-turn-scholia-overlays-on ()
5619 (interactive)
5621 \end{lisp}
5623 \begin{notate}{Using these functions as a subroutine for initial markup?}
5624 It doesn't make a whole lot of sense to use these functions for
5625 initial markup, because they involve a bit of search that would be
5626 unneeded at that stage. However, it would be good to take another
5627 look at `mark-things-up' and see if we can get any further insights
5628 into how to write this function from there. (Presumably this function
5629 was initially based on that one already...)
5630 \end{notate}
5632 \section{Browsing} \label{browsing}
5634 \subsection{Scholia browsing} \label{browse-scholia}
5636 \begin{notate}{Introduction to scholia browsing}
5637 The point of this section is to associate scholia with the regions of
5638 the article that they apply to, and to enable the user to quickly find
5639 and navigate between the marked-up regions in the displayed version of
5640 this article and their associated scholia.
5641 \end{notate}
5643 \begin{notate}{Moving without reparsing} \label{moving-with-reparsing}
5644 The functions for scholia browsing are likely to move you to the
5645 ``wrong place'' unless the buffer has been parsed and the scholia
5646 locations are up-to-date (i.e., it will move you to the specified
5647 region, but this will probably be the wrong region).
5648 \end{notate}
5650 \begin{notate}{Problem with the design of the `move-to...-scholium' functions}
5651 These probably shouldn't be using overlays as the source of their
5652 information about where scholia reside, since overlays are not
5653 necessarily going to be there!
5655 (I guess this means ``if the content has been cut and pasted.'' I'm
5656 guessing that there are cases where we would like to use this
5657 function under conditions in which cutting and pasting may have taken
5658 place. I'm not sure exactly what those cases would be, since I'm not
5659 sure exactly when this function is called. Seems it is, so far, only
5660 called in the case of scrolling the main article display to a certain
5661 region, namely a region with an attached scholium. It might be
5662 reasonable just to use overlays in that case (?). This is a somewhat
5663 curious point, and since it actually deals with something sort of
5664 fundamental in Emacs, maybe it would be best to give it more thought
5665 \emph{later}, especially since this function is probably useful right
5666 \emph{now}.)
5668 They can be turned off altogether (Section \ref{overlays-on-off}) or
5669 one by one (Note \ref{overlay-styles}).
5671 (That is a good point. Audience, what do you think?)
5673 Anyway, the logic of the function is probably going to be similar
5674 no matter what guts we use.
5676 Note that there is a funny case of two references that begin
5677 at the same point (and, possibly, end at the same point as well).
5678 I think this case isn't handled well by the function the way it
5679 is written.
5681 This is a general matter that goes beyond these functions -- and
5682 should probably be noted as such somewhere.
5683 \end{notate}
5685 \begin{notate}{On `move-to-next-region-with-scholium' and `move-to-previous-region-with-scholium'} \label{move-to-next-or-previous-region-with-scholium}
5686 This moves the point to the beginning of the next region that has a
5687 scholium about it (if there is one).
5689 (I'm noticing a bug when the function is used interactively with the
5690 binding selected in Section \ref{bindings} and the cursor is
5691 positioned on a right paren; calling the function with M-x in this
5692 case doesn't result in the same problem.)
5694 Note these two functions are not quite symmetrical, because we
5695 want the cursor to end up at the beginning of the marked
5696 region. (I think there will be a problem if we try to go to the
5697 beginning of a scholium that is attached at the beginning of
5698 the article, but that isn't such a big deal.)
5699 \end{notate}
5701 \begin{lisp}
5702 (defun move-to-next-region-with-scholium ()
5703 (interactive)
5704 (let ((change (next-overlay-change (point))))
5705 (if (overlays-at change)
5706 (progn (goto-char change)
5707 (list change (next-overlay-change change)))
5708 (if (overlays-at (next-overlay-change change))
5709 (progn (goto-char (next-overlay-change change))
5710 (list (next-overlay-change change)
5711 (next-overlay-change (next-overlay-change
5712 change))))
5713 (message "No subsequent regions with scholia about them.")
5714 nil))))
5716 (defun move-to-previous-region-with-scholium ()
5717 (interactive)
5718 (let ((change (previous-overlay-change (point))))
5719 (if (overlays-at change)
5720 (progn (goto-char change)
5721 (list change (previous-overlay-change change)))
5722 (if (overlays-at (previous-overlay-change change))
5723 (progn (goto-char (previous-overlay-change change))
5724 (list (previous-overlay-change change)
5725 (previous-overlay-change (previous-overlay-change
5726 change))))
5727 (message "No previous regions with scholia about them.")
5728 nil))))
5730 (defun scroll-article-display-to-next-region-for-current-scholium ()
5731 (interactive)
5732 (save-excursion
5733 (set-buffer buffer-associated-with-current-article)
5734 (let (found
5735 (curpoint (point)))
5736 (while (and (not found)
5737 (not (eobp))
5738 (move-to-next-region-with-scholium))
5739 (mapc (lambda (overlay)
5740 (when (equal (overlay-get overlay 'scholia)
5741 (name-of-current-scholium))
5742 (setq found t)))
5743 (overlays-at (point)))
5744 (if found
5745 (recenter)))
5746 (when (not found)
5747 (goto-char curpoint)
5748 (message "Scholium not about further regions in buffer.")))))
5750 (defun scroll-article-display-to-previous-region-for-current-scholium ()
5751 (interactive)
5752 (save-excursion
5753 (set-buffer buffer-associated-with-current-article)
5754 (let (found
5755 (curpoint (point)))
5756 (while (and (not found)
5757 (not (bobp))
5758 (move-to-previous-region-with-scholium))
5759 (mapc (lambda (overlay)
5760 (when (equal (overlay-get overlay 'scholia)
5761 (name-of-current-scholium))
5762 (setq found t)))
5763 (overlays-at (point)))
5764 (if found
5765 (recenter)))
5766 (when (not found)
5767 (goto-char curpoint)
5768 (message "Scholium not about previous regions in buffer.")))))
5769 \end{lisp}
5771 \begin{notate}{Cycling through regions}
5772 It wouldn't be too hard to make a variant of
5773 `scroll-article-display-to-previous-region-for-current-scholium' that
5774 cycles through the regions that the current scholium is about.
5775 \end{notate}
5777 \begin{notate}{On `move-to-first-region-for-scholium'} \label{move-to-first-region-for-scholium}
5778 Move you to the beginning of the region marked up by the scholium
5779 named \inp{name}. Should this be made interactive?) At present, it
5780 is only called by `move-to-first-region-for-current-scholium'.
5781 \end{notate}
5783 \begin{lisp}
5784 (defun move-to-first-region-for-scholium (name)
5785 (pop-to-buffer (get-buffer rendering-target-buffer))
5786 (let ((beg (point-max))
5787 (about (scholium-about (get-article name))))
5788 (dolist (link about)
5789 ;; this should be revised in light of the
5790 ;; fact that a link can be multiply typed
5791 (when (and (typedata-includes-passage (link-type elt))
5792 (equal (linked-to-article link)
5793 name-of-current-article)
5794 (< (link-beginning link) beg))
5795 (setq beg (link-beginning link))))
5796 (unless (equal beg (point-max))
5797 (goto-char beg))))
5798 \end{lisp}
5800 \begin{notate}{On `move-to-first-region-for-current-scholium'}
5801 This uses the function `move-to-first-region-for-scholium' from
5802 section \ref{browse-scholia}; the thought behind including the
5803 function here is that it establishes a relationship between
5804 the Scholia Display buffer and the main article buffer (however
5805 it could probably go in section \ref{browse-scholia} equally well).
5807 This should probably be complemented by a function
5808 `move-to-last-region-for-current-scholium'.
5810 Also, it should probably have some intelligent message
5811 (not to say ``error message'') if the scholium applies to
5812 the article as a whole.
5814 (Gives some error, complaining about `elt' being void.
5815 Can this run in the Scholia Display buffer as well as the
5816 main article buffer?)
5817 \end{notate}
5819 \begin{lisp}
5820 (defun move-to-first-region-for-current-scholium ()
5821 (interactive)
5822 (let ((current (name-of-current-scholium)))
5823 (move-to-first-region-for-scholium current)))
5824 \end{lisp}
5826 \subsection{Local browsing} \label{local}
5828 \begin{notate}{Introduction to local browsing}
5829 This section will describe purely local navigation commands that
5830 require little in the way of additional data structures. The main
5831 idea for the functions in this section is to make it so that focus can
5832 move from the current article to adjacent articles (either articles
5833 that are about the current article or articles that the current
5834 article is about), or more generally, to articles within some
5835 neighborhood of the current article (articles that we can reach by
5836 stepping from adjacent article to its adjacent articles, etc.). We
5837 re-use the listing mechanism from the previous section as needed.
5838 \end{notate}
5840 \begin{notate}{On `read-scholia-property-at-point'}
5841 Suppose we simply want to make the current scholium into the new
5842 current article. That's what the next function is for.
5843 \end{notate}
5845 \begin{lisp}
5846 (defun read-scholia-property-at-point ()
5847 (get-text-property (point) 'scholia))
5848 \end{lisp}
5850 \begin{notate}{On `scholia-named-at-point'}
5851 I think that this should strip out the ``mask'' tags
5852 from the link-ids, but leave the name parts. Since it
5853 is only used by interactive functions, this seems fine,
5854 and appropriate.
5855 \end{notate}
5857 \begin{lisp}
5858 (defun scholia-named-at-point ()
5859 (mapcar (lambda (id)
5860 (if (eq (car id) 'mask)
5861 (car (second id))
5862 (car id)))
5863 (read-scholia-property-at-point)))
5864 \end{lisp}
5866 \begin{notate}{On `follow-scholium'} \label{follow-scholium}
5867 This causes the current scholium to become the current article.
5869 Eventually we'll want to be able to run this command with a
5870 mouse-click.
5871 \end{notate}
5873 \begin{lisp}
5874 (defun follow-scholium ()
5875 (interactive)
5876 (let ((current (name-of-current-scholium)))
5877 (when current
5878 (display-article current))))
5879 \end{lisp}
5881 \begin{notate}{On `follow-reference'} \label{follow-reference}
5882 This reads the `scholia' property at point and either follows the
5883 reference at point (if there is only one) or allows the user to choose
5884 between references (if there are several).
5886 We might want to provide an additional function for following links
5887 \emph{in general}; basically the strategy for that is, just don't do
5888 the `remove-if' filtering.
5889 \end{notate}
5891 \begin{lisp}
5892 (defun follow-reference ()
5893 (interactive)
5894 (let ((references
5895 (remove-if (lambda (name)
5896 (not (typedata-includes
5897 (scholium-type (get-article name))
5898 'reference)))
5899 (scholia-named-at-point))))
5900 (cond
5901 ((equal (length references) 1)
5902 (let* ((ref (get-article (car references)))
5903 (to-article (reference-to-article ref)))
5904 (if (equal to-article name-of-current-article)
5905 (display-article (reference-from-article ref))
5906 (display-article to-article)))
5907 ;; maybe `display-article' should be returning
5908 ;; some non-`nil' value so that we don't have to do this.
5910 (references
5911 ;; this sort of disambiguation is really only needed if the
5912 ;; references have different targets. Two distinct references
5913 ;; to the same thing overlaying each other could be treated as
5914 ;; one for simple following purposes.
5915 (list-articles references))
5917 (message "No reference at point.")
5918 nil))))
5920 (defun follow-reference-or-scholium ()
5921 (interactive)
5922 (unless (follow-reference)
5923 (follow-scholium)))
5925 (defun display-an-article-that-current-article-is-about ()
5926 (interactive)
5927 (let ((abouts (scholium-about
5928 (get-article name-of-current-article))))
5929 (cond
5930 ((equal (length abouts) 1)
5931 (display-article (car abouts)))
5932 (abouts
5933 (list-articles abouts))
5935 (message "Article isn't about any other articles.")))))
5936 \end{lisp}
5938 \begin{notate}{On `current-scholium-is-about'}
5939 This function is similar to the previous one, but it applies to
5940 scholia. Since one presumably knows that the current scholium is
5941 about the current article, this is most useful when a scholium is
5942 about several different articles, as it allows the user to move
5943 ``down'' to any of them.
5944 \end{notate}
5946 \begin{lisp}
5947 (defun current-scholium-is-about ()
5948 (scholium-about (get-article (name-of-current-scholium))))
5950 (defun display-an-article-that-current-scholium-is-about ()
5951 (interactive)
5952 (let ((abouts (current-scholium-is-about)))
5953 (cond
5954 ((equal (length abouts) 1)
5955 (display-article (car abouts))
5956 (message "Note: scholium is only about current article."))
5957 (abouts
5958 (list-articles abouts))
5960 (message "Article isn't about any other articles.")))))
5961 \end{lisp}
5963 \subsection{Catalog browsing} \label{catalog}
5965 \begin{notate}{Content-free browsing}
5966 A popular style of browsing ignores the content of the objects
5967 themselves and looks only at their metadata. Examples include library
5968 catalogs or lists of search engine results. Since you aren't actually
5969 browsing the articles directly, this is ``browsing a catalog'' more
5970 than it is ``browsing the library''.
5972 Using this technique, one should be able to selectively choose
5973 subcollections to look at, e.g. all the works by a given author or
5974 what have you. In this section, we provide code for browsing by
5975 article name. The code is an interface to a generic browsing/listing
5976 command based on Emacs's built-in `list-buffers' command. This setup
5977 is designed with extensibility in mind, however it may be useful to
5978 rewrite the selection mechanism (or add an alternate version) in order
5979 to make each line in the current display into a bibliography-style or
5980 index-card style reference. This would make the information fit on
5981 the screen better (and such modifications should be easy to make
5982 later).
5984 See Note \ref{standard-article-menu-accessors} for a description of
5985 the data that are displayed along with names in the listing. We may
5986 eventually want to be able to switch between several alternative
5987 data-listings, e.g., we might want name, type, and namespace; or name,
5988 article-about list, about-article list. With if complicated lists
5989 like this are used, we may want to have more than one line associated
5990 with each name.
5992 We currently provide only very basic functions for working with these
5993 listings.
5994 \end{notate}
5996 \begin{notate}{Catalog browsing in the scholium system}
5997 This code provides a generic way to perform actions on rich objects
5998 from a list. It is assumed that each object has several attributes
5999 that a user may be interested in. ``Name'', ``size'' and ``mode'' are
6000 familiar examples from `list-buffers'; here there can be an
6001 arbitrary number of arbitrary attributes. This makes this
6002 mechanism useful in some cases where `completing-read' would not
6003 provide the user with enough information.
6005 The way attributes are obtained from objects is left up to the
6006 user, as are the actual actions that can be performed on the
6007 objects.
6009 Generality comes at an obvious, unavoidable, cost, namely any given
6010 deployment of this interface requires some extra set up -- examples
6011 are provided.
6012 \end{notate}
6014 \begin{notate}{Predicate support for listing} \label{predicate-support-for-listing}
6015 Just for example, one thing people might want to do would be to list
6016 the articles in the vicinity of the article being browsed or in a
6017 certain section from a paper, and so on. The function will work with
6018 any set that we can select; what we need are a bunch of functions for
6019 doing the selection.
6020 \end{notate}
6022 \begin{notate}{History support for listing} \label{history-for-listing}
6023 It would be good to maintain a special history list for this display,
6024 that way if you browse a succession of nested catalogs, you can go
6025 backwards and forwards to choose the best catalog. (Catalogs are
6026 similar to directories from dired, gopher, etc.) See Section
6027 \ref{temporal} for a discussion of history support in general (start
6028 with Note \ref{thematic-histories}).
6029 \end{notate}
6031 \begin{notate}{Purpose of generality}
6032 Different menus may be useful for different purposes. A collection of
6033 article \inp{name}s may frequently be insufficient data from which to
6034 choose an article. Different data may be useful for different times
6035 and purposes, so we've made the system extensible. It may be useful
6036 to change the overall \emph{style} of the display as well (e.g. to
6037 select from a list of multi-line records rather than a list of lines);
6038 modifications at this level are on hold until such time as they are
6039 needed.
6040 \end{notate}
6042 \begin{notate}{On `make-generic-menu-mode'}
6043 This takes the name of the menu (as a space-separated string) together
6044 with a list of bindings to be used in that particular menu mode.
6046 This should provide a docstring for the mode it creates.
6047 \end{notate}
6049 \begin{lisp}
6050 (defmacro make-generic-menu-mode
6051 (mode bindings)
6052 (let* ((modedash (downcase (replace-regexp-in-string " " "-" mode)))
6053 (modesymbol (intern (concat modedash "-mode")))
6054 (mapname (intern (concat modedash "-map"))))
6055 `(progn
6056 (defvar ,mapname)
6057 (setq ,mapname (make-keymap))
6058 (suppress-keymap ,mapname t)
6059 (dolist (binding ,bindings)
6060 (define-key ,mapname (car binding) (cdr binding)))
6061 (defun ,modesymbol ()
6062 (kill-all-local-variables)
6063 (use-local-map ,mapname)
6064 (setq major-mode (quote ,modesymbol))
6065 (setq mode-name ,mode)
6066 (setq truncate-lines t)
6067 (setq buffer-read-only t)))))
6068 \end{lisp}
6070 \begin{notate}{On `generic-menu-noselect'} \label{generic-menu-noselect}
6071 The basic idea of this is that we have some \inp{objects} and some
6072 functions to map across the objects to extract the information from
6073 the objects (\inp{accessors}). The functions must be set up to
6074 produce strings as their output. The functions correspond to columns
6075 in the display; individual objects correspond to rows. This is the
6076 same idea no matter what the source of the objects is. (In
6077 particular, it might be a good idea for a later version of this
6078 function to accept either a hash table or a list as the source of the
6079 objects; see Note \ref{browsing-subcollections}.) Note that columns
6080 of the display are assumed to be as wide as their widest item!
6081 \end{notate}
6083 \begin{lisp}
6084 (defun generic-menu-noselect (objects accessors)
6085 (let (cols)
6086 (dolist (get-this accessors)
6087 ;; if we built this front-to-back rather than back-to-front,
6088 ;; that would be better
6089 (setq cols (cons
6090 (cons (car get-this)
6091 (mapcar (cdr get-this) objects))
6092 cols)))
6093 ;; find the width of the columns.
6094 (let ((lens (mapcar (lambda (col)
6095 (let ((len 0))
6096 (dolist (str col)
6097 (let ((candidate (length str)))
6098 (when (> candidate len)
6099 (setq len candidate))))
6100 len))
6101 cols)))
6102 (with-current-buffer (get-buffer-create "*Generic List*")
6103 (setq buffer-read-only nil)
6104 (erase-buffer)
6105 (while cols
6106 (goto-char (point-min))
6107 (goto-char (line-end-position))
6108 (dolist (str (car cols))
6109 (insert str " ")
6110 ;; fill with spaces to make up for lost space
6111 (insert-char 32 (- (car lens) (length str)))
6112 (unless (equal (forward-line) 0)
6113 (newline))
6114 (goto-char (line-end-position)))
6115 (setq cols (cdr cols))
6116 (setq lens (cdr lens)))
6117 (goto-char (point-min))
6118 (current-buffer)))))
6119 \end{lisp}
6121 \begin{notate}{Improved sorting of article listing}
6122 Sorting could be done using autocompletion on the name of the column
6123 to sort on, too, which would be kind of nice. Or we could make a
6124 command to sort on the current column, or reorder columns according to
6125 the values on the current line or just about anything you might like.
6127 But I don't think sorting is going to work at all until we have a
6128 consistent way of identifying the fields to sort; in the case of
6129 strings with spaces in them, `sort-fields' won't work. Since we
6130 compute the width of each of the columns in `generic-menu-noselect',
6131 if we were to store this info (perhaps as a text property attached to
6132 each column heading), we could adroitly divide the text up to find the
6133 strings we're trying to sort. See Note \ref{text-properties-in-article-listing}.
6134 \end{notate}
6136 \begin{lisp}
6137 (defun Generic-menu-sort (col)
6138 (interactive "P")
6139 (save-excursion
6140 (sort-fields (or col 1) (progn (goto-line 2)
6141 (point))
6142 (point-max))))
6143 \end{lisp}
6145 \begin{notate}{Hierarchies for browsing}
6146 Hierarchies are somewhat similar to menus, e.g., we might
6147 want to use hierarchies to display sub-library relationships.
6148 (This is like KM's ontology browser.) Of course, graph
6149 browsing would be even more generic (but display of these
6150 things seems a bit far removed from what we can do right now).
6151 \end{notate}
6153 \begin{notate}{Reuse of names from article listing}
6154 It would be nice if names were displayed together with quote marks
6155 making the printed versions of the names appropriate for direct
6156 re-use.
6157 \end{notate}
6159 \begin{notate}{On `standard-article-menu-accessors'} \label{standard-article-menu-accessors}
6160 Note that it would be easy to provide more metadata -- just revise
6161 this variable with additional fields as desired. See Note
6162 \ref{generic-menu-noselect} for a description of how accessors work.
6163 \end{notate}
6165 \begin{lisp}
6166 (defvar standard-article-menu-accessors
6167 '(("Name" . identity)
6168 ("C" . (lambda (elt) " "))))
6169 \end{lisp}
6171 \begin{notate}{Control panels} \label{control-panels}
6172 A little control panel on the left of the article listing comprised of
6173 various toggle-state elements provides a way to interactively
6174 manipulate the articles individually or \emph{en masse} (see section
6175 \ref{masse}). (The only feature in the control panel for now is an
6176 indicator showing which article is current; this is indicated by a dot
6177 in the ``C'' column.)
6178 \end{notate}
6180 \begin{notate}{On `article-menu-listing-hook'}
6181 This is here to
6182 customize the behavior of the article menu listing. Currently it
6183 is used to offset the activities invoked by
6184 `currently-displayed-label-hook'; whereas we want
6185 `currently-displayed-label' to be defined when the listing is
6186 used to display a label, we'd rather it be `nil' when something
6187 other than a label has been displayed, since anything else could
6188 be misleading.
6189 \end{notate}
6191 \begin{lisp}
6192 (defvar article-menu-listing-hook nil)
6193 \end{lisp}
6195 \begin{notate}{On `article-menu-listing'}
6196 The optional input \inp{subset} is a list of article names to pump
6197 into the generic menu; it defaults to the list of ``plain'' articles
6198 as recorded on the corresponding label. The optional input
6199 \inp{accessors} specifies the functions to use to extract information
6200 from the articles named by \inp{subset}; it is in the format of, and
6201 defaults to, `standard-article-menu-accessors'. (Note that function
6202 plays a similar role to `Buffer-menu-revert' from buff-menu.el.)
6203 \end{notate}
6205 \begin{lisp}
6206 (defun article-menu-listing (&optional subset accessors)
6207 (interactive)
6208 (pop-to-buffer
6209 (generic-menu-noselect
6210 ;; maybe this should always handle propertizing itself?
6211 (or subset
6212 (label-to-propertized-list 'plain))
6213 (or accessors
6214 standard-article-menu-accessors)))
6215 ;; note, this runs every time, even if the current article
6216 ;; isn't on the list.
6217 (article-menu-point-out-current-article)
6218 (article-menu-mode)
6219 (run-hooks 'article-menu-listing-hook))
6221 (add-hook 'article-menu-listing-hook (lambda ()
6222 (setq currently-displayed-label
6223 nil)))
6224 \end{lisp}
6226 \begin{notate}{On `turn-article-table-into-list'}
6227 I hate to actually use this function the way it is used in
6228 `display-article'... probably we should just select from the
6229 \emph{plain} articles there, and write a separate function to display
6230 other articles. In short, there really shouldn't be any need to use
6231 this function, except maybe for debugging purposes or \emph{explicit}
6232 listing of all the articles (whenever that really needs to be done).
6233 \end{notate}
6235 \begin{lisp}
6236 (defun turn-article-table-into-list ()
6237 (let ((names (list t)))
6238 (maphash (lambda (name value)
6239 ;; It might be nice to have %S here, but
6240 ;; I don't know if it would be _useful_
6241 (nconc names (list (format "%s" name))))
6242 article-table)
6243 (cdr names)))
6244 \end{lisp}
6246 \begin{notate}{On `turn-article-table-into-names'}
6247 This is a variant of `turn-article-table-into-list'
6248 that produces the actual names of the articles;
6249 probably it should supercede the other, since we could
6250 get the print names by mapping over the output of this
6251 function, obviously.
6252 \end{notate}
6254 \begin{lisp}
6255 (defun turn-article-table-into-names ()
6256 (let ((names (list t)))
6257 (maphash (lambda (name value)
6258 (nconc names (list name)))
6259 article-table)
6260 (cdr names)))
6261 \end{lisp}
6263 \begin{notate}{On `turn-article-table-into-propertized-list'}
6264 This combines the best of both `turn-article-table-into-list' and
6265 `turn-article-table-into-names'. Compare
6266 `label-to-propertized-list'.
6267 \end{notate}
6269 \begin{lisp}
6270 (defun turn-article-table-into-propertized-list ()
6271 (let ((names (list t)))
6272 (maphash (lambda (name value)
6273 (nconc names
6274 (list
6275 (propertize (format "%s" name) 'name name))))
6276 article-table)
6277 (cdr names)))
6278 \end{lisp}
6280 \begin{notate}{On `turn-list-into-propertized-list'} \label{turn-list-into-propertized-list}
6281 Turns an arbitrary list into a propertized list.
6282 \end{notate}
6284 \begin{lisp}
6285 (defun turn-list-into-propertized-list (lis)
6286 (let (names)
6287 (mapc (lambda (name)
6288 (setq names (cons
6289 (propertize (format "%s" name) 'name name)
6290 names)))
6291 lis)
6292 names))
6293 \end{lisp}
6295 \begin{notate}{Special-purpose listings} \label{special-listings}
6296 Here are a few functions to list special collections of articles.
6297 The function `article-menu-list-labels' is perhaps particularly
6298 noteworthy; browsing labels seems to be a powerful way of organizing
6299 and retrieving information, see Note \ref{browsing-subcollections}.
6300 \end{notate}
6302 \begin{lisp}
6303 (defun article-menu-list-plain-articles ()
6304 (interactive)
6305 (article-menu-listing))
6307 (defun article-menu-list-all-articles ()
6308 (interactive)
6309 (article-menu-listing (turn-article-table-into-propertized-list)))
6311 (defun article-menu-list-metadata-articles ()
6312 (interactive)
6313 (article-menu-listing (label-to-propertized-list 'metadata)))
6315 (defun article-menu-list-labels ()
6316 (interactive)
6317 (article-menu-listing (label-to-propertized-list 'label)))
6319 (defun list-articles (lis)
6320 (interactive)
6321 (article-menu-listing (turn-list-into-propertized-list lis)))
6322 \end{lisp}
6324 \begin{notate}{Using text properties in the article listing} \label{text-properties-in-article-listing}
6325 The approach that I've been using so far, searching for spaces, won't
6326 work if the names of the columns have spaces in them. Something more
6327 sophisticated (probably using text properties) would work better in
6328 general. It would also be handy to tuck the articles ``true names''
6329 in as text properties attached to the print names.
6330 \end{notate}
6332 \begin{notate}{On `article-menu-display-article'}
6333 The point is to grab the name of the article on the currrent line of
6334 the listing and display it. This needs to be checked a bit in the
6335 multicolumn case (which itself needs to be explored).
6336 \end{notate}
6338 \begin{lisp}
6339 (defun article-menu-display-article ()
6340 (interactive)
6341 (when (> (line-number-at-pos) 1)
6342 (save-excursion
6343 (goto-char (line-beginning-position))
6344 (search-forward-regexp "[. >] .")
6345 (setq name-of-current-article
6346 (get-text-property (point) 'name))
6347 (article-menu-point-out-current-article)
6348 (display-article name-of-current-article))))
6349 \end{lisp}
6351 \begin{notate}{On `article-menu-mark-article'}
6352 Use this to mark the article mentioned on this line.
6353 \end{notate}
6355 \begin{lisp}
6356 (defun article-menu-mark-article ()
6357 (interactive)
6358 (setq buffer-read-only nil)
6359 (when (> (line-number-at-pos) 1)
6360 (goto-char (line-beginning-position))
6361 (delete-char 1)
6362 (insert ">")
6363 (when (< (line-number-at-pos)
6364 (progn (save-excursion (goto-char (point-max))
6365 (line-number-at-pos))))
6366 (forward-line 1)))
6367 (setq buffer-read-only t))
6368 \end{lisp}
6370 \begin{notate}{On `article-menu-unmark-article'}
6371 Use this to remove any mark on the article mentioned on this line.
6372 \end{notate}
6374 \begin{lisp}
6375 (defun article-menu-unmark-article ()
6376 (interactive)
6377 (setq buffer-read-only nil)
6378 (when (and (> (line-number-at-pos) 1)
6379 (not (save-excursion (goto-char (line-beginning-position))
6380 (looking-at "\\."))))
6381 (goto-char (line-beginning-position))
6382 (delete-char 1)
6383 (insert " ")
6384 (when (< (line-number-at-pos)
6385 (progn (save-excursion (goto-char (point-max))
6386 (line-number-at-pos))))
6387 (forward-line 1)))
6388 (setq buffer-read-only t))
6390 (defun article-menu-unmark-all-articles ()
6391 (interactive)
6392 (setq buffer-read-only nil)
6393 (save-excursion (goto-line 2)
6394 (goto-char (line-beginning-position))
6395 (while (re-search-forward "^>" nil t)
6396 (replace-match " ")))
6397 (setq buffer-read-only t))
6398 \end{lisp}
6400 \begin{notate}{On `article-menu-point-out-current-article'}
6401 This is a non-interactive function that puts a dot in front
6402 of the current article when the article listing is generated.
6403 \end{notate}
6405 \begin{lisp}
6406 (defun article-menu-point-out-current-article ()
6407 (goto-char (point-min))
6408 (setq buffer-read-only nil)
6409 (save-excursion (when (search-forward-regexp "^\\." nil t)
6410 (replace-match " ")))
6411 (when (and
6412 name-of-current-article
6413 (search-forward-regexp
6414 ;; maybe this `(format "%s" name-of-current-article)'
6415 ;; stuff should be stored as some kind of function,
6416 ;; like `print-name-of-article' or something like that
6417 (concat "^[. ] " (regexp-quote
6418 (format "%s" name-of-current-article)))
6419 nil t))
6420 (replace-match (concat ". " (substring (match-string 0) 2))))
6421 (goto-char (line-beginning-position))
6422 (setq buffer-read-only t))
6423 \end{lisp}
6425 \begin{notate}{Features of the article menu} \label{features-of-the-article-menu}
6426 The only ``actionable'' feature of the current listing is display.
6427 See also Note \ref{control-panels}.
6428 \end{notate}
6430 \begin{lisp}
6431 (make-generic-menu-mode "Article Menu"
6432 '(("g" . article-menu-listing)
6433 ("m" . article-menu-mark-article)
6434 ("u" . article-menu-unmark-article)
6435 ("U" . article-menu-unmark-all-articles)
6436 ("q" . quit-window)
6437 ("\C-m" . article-menu-display-article)))
6438 \end{lisp}
6440 \begin{notate}{Additional actions}
6441 We also want to have a function that will give the semantics for
6442 ``select'' and other sorts of things that we might be able to do to
6443 the objects that we've listed. (Maybe we should pass this in along
6444 with the objects, and set it up as a local variable that can be called
6445 later.)
6446 \end{notate}
6448 \begin{notate}{Search engine interface} \label{search-engine-interface}
6449 It will be useful to interface this browsing mechanism with a
6450 simple predicate matching mechanism. Sometimes we'll want to
6451 restrict search (Note \ref{restricting-search}), but for now,
6452 we might as well write a function that searches everything.
6454 A more advanced search engine would apply general predicates
6455 to create the list (e.g. it would allow the user to
6456 restrict to scholia of a certain type, or that \emph{have}
6457 scholia of a given type, or that match other computed properties).
6459 Other basic advances would be to have a second column that
6460 showed the actual match, and to display the matches in order
6461 according to the position of the articles in question within
6462 some specific linearization of the document (e.g. the main one).
6464 The main functions in the ``search engine'' so far are
6465 `article-menu-list-articles-matching-regexp' (Note
6466 \ref{article-menu-list-articles-matching-regexp}) and
6467 `article-menu-list-articles-matching-predicate' (Note
6468 \ref{article-menu-list-articles-matching-predicate})
6469 \end{notate}
6471 \begin{notate}{On `article-menu-list-articles-matching-regexp'} \label{article-menu-list-articles-matching-regexp}
6472 This makes a listing showing all of the articles that match
6473 \inp{regexp}.
6475 \emph{(It would be nice if we could leave out meta, reference,
6476 code, and label types of articles in the default version of
6477 this.)}
6478 \end{notate}
6480 \begin{lisp}
6481 (defun article-menu-list-articles-matching-regexp (regexp)
6482 (interactive "MRegexp: ")
6483 (let ((matches (mapcar
6484 (lambda (name)
6485 (propertize (format "%s" name) 'name name))
6486 (remove-if
6487 (lambda (elt)
6488 (not
6489 (with-temp-buffer
6490 ;; rough, not bothering with
6491 ;; `sch-plain-text'
6492 (let ((article (get-article elt)))
6493 (insert
6494 (format "%s"
6495 (scholium-name (get-article elt)))
6496 "\n"
6497 (format "%s"
6498 (scholium-text article)))
6499 (goto-char (point-min))
6500 (search-forward-regexp regexp
6501 nil t)))))
6502 (turn-article-table-into-names)))))
6503 (if matches
6504 (article-menu-listing matches)
6505 (message "No hits."))))
6506 \end{lisp}
6508 \begin{notate}{On `article-menu-list-articles-matching-predicate'} \label{article-menu-list-articles-matching-predicate}
6509 This is a way to pick out all of the articles in the library
6510 that match a given predicate.
6511 \end{notate}
6513 \begin{lisp}
6514 (defun article-menu-list-articles-matching-predicate (pred)
6515 (let ((matches (mapcar
6516 (lambda (name)
6517 (propertize (format "%s" name) 'name name))
6518 (remove-if (lambda (elt) (not (funcall pred elt)))
6519 (turn-article-table-into-names)))))
6520 (if matches
6521 (article-menu-listing matches)
6522 (message "No hits."))))
6523 \end{lisp}
6525 \begin{notate}{Restricting search} \label{restricting-search}
6526 If we have lots of subcollections, then we will sometimes need to
6527 search through all of them, and sometimes, only through some subset.
6528 When doing search, there are two efficient ways to limit things (and
6529 these are very similar): either add subcollections that match some
6530 predicate, or remove subcollections that match some predicate.
6531 \end{notate}
6533 \begin{notate}{Saving search results}
6534 It would be handy to be able to store the listings generated by
6535 search in some workspace. As a prior step, one needs to be able
6536 to turn the arbitrary listing into an article (specifically, a
6537 label)!
6538 \end{notate}
6540 \begin{notate}{Browsing subcollections} \label{browsing-subcollections}
6541 Compare Section \ref{displaying-labels} (should that stuff go here?).
6542 Also note that functionality for displaying sub-objects made out of
6543 hash tables should probably be worked in. Note that browsing from
6544 list to list is similar to the Gopher experience.
6546 One special sort of subcollection to browse would be one generated by
6547 search. A variant of `multi-occur' that resolves at the scholium
6548 level would be very handy to have (see Note
6549 \ref{search-engine-interface}).
6550 \end{notate}
6552 \begin{notate}{Display all matches in full}
6553 Instead of just providing the \emph{listing}, sometimes
6554 it could be handy to display a concatenation of all
6555 matching texts (maybe with the matching words highlighted).
6556 Compare Note \ref{derivative-works-in-the-scholium-system}.
6557 \end{notate}
6559 \begin{notate}{On `display-article-listing'}
6560 This just puts the cursor in the article listing.
6561 \end{notate}
6563 \begin{lisp}
6564 (defun display-article-listing ()
6565 (interactive)
6566 (pop-to-buffer "*Generic List*"))
6567 \end{lisp}
6569 \begin{notate}{Arrangement of listing window}
6570 The generic list should always go on the \emph{left} in our display,
6571 and similarly with files that have their own buffers. This is
6572 especially relevant whenever we're treating the listing as an article,
6573 cf. Note \ref{display-label}. It is possible, although perhaps
6574 unlikely, that sometimes we'll want article listings to be mapped into
6575 the Main Article Display set to a Generic List Mode.
6576 \end{notate}
6578 \begin{notate}{Static catalog display }
6579 It might be advantageous to not have the display disappear -- which
6580 presumably means, display the articles that it lists as scholia
6581 attached to it; otherwise, they display and their scholia display, and
6582 there isn't enough room on the display for the catalog. Something
6583 like this should be easy enough to do.
6584 \end{notate}
6586 \begin{notate}{Electric catalog}
6587 Probably we could write things so that sections display directly when
6588 the cursor moves over the relevant line in the catalog. This would
6589 make browsing entries very speedy.
6590 \end{notate}
6592 \begin{notate}{Scholia attached to sections}
6593 When we import the system (Note \ref{import-scholium-system}),
6594 an article is created for each section that is displayed
6595 as a listing. Such articles are currently displayed
6596 together with all of the articles \emph{in} the section shown
6597 as attached scholia. It would probably be nice to be able
6598 to turn this ``feature'' off (also perhaps on a
6599 browsing-style-dependant basis).
6600 \end{notate}
6602 \subsection{Temporal browsing} \label{temporal}
6604 \begin{notate}{History models}
6605 I had the idea to make a generic browser that could be used as
6606 the backend for both the scholium system's temporal browser and
6607 for my lynx-based browser nero. (It may prove to be most
6608 convenient to simply embed a new nero in the scholium system,
6609 indeed, this seems fairly likely to happen.) But I think it makes
6610 more sense at this point just to write a working scholia browser.
6611 That sort of abstractification can come later; the design will
6612 feature some effort in this direction, but perhaps largely in the
6613 form of notes about how to make things fully general and
6614 abstract.
6616 What is a temporal browser? Typically, a list of history elements
6617 that can be added to when new pages are encountered, and from which
6618 elements are deleted as new paths through the network get trod.
6620 For example, if the user browser pages $A$, $B$, and $C$ in order,
6621 there will be a history list $H=(A\ B\ C)$. Upon going \emph{back},
6622 the history list becomes $H=(A\ B)$, and a future list is created,
6623 $F=(C)$. If the user then visits a new page $D$, the history list
6624 becomes $H=(A\ B\ D)$ and $F=()$.
6626 In order to make access \emph{quick}, one obvious design strategy is
6627 to store pages that have been browsed locally (i.e., rather than
6628 re-downloading them each time they are browsed). Of course, if the
6629 pages are already stored locally, this issue is moot. And in this
6630 case, to save storage space (at a small time cost), we should be
6631 recording \emph{metadata} (names or pointers) on the history list, not
6632 the pages themselves.
6634 There are a couple of other models to consider.
6636 First, we can store our history data in a \emph{tree}. In this
6637 ``\emph{istree}'' model, what we would see in the above scenario is:
6638 \begin{align*}
6639 & T=(A) \\
6640 & T=(A\ B) \\
6641 & T=(A\ (B\ C))) \\
6642 & T=(A\ (B\ C\ D))
6643 \end{align*}
6645 I.e., each level of the tree stores the parent node as the car, and a
6646 list of children as the cdr (children are stored as atoms if they
6647 themselves are childless, or as the head of lists if they have
6648 children). To keep track of where we are in the tree, we need a list
6649 of directions (cars and cdrs). In the current case, the list would be
6650 (in the order of application): \emph{cdr, car, cdr, cdr}. (For
6651 purposes of maintaining a symmetry which will be seen momentarily, we
6652 always return a \emph{list} in which the current node is the car.) If
6653 the user moves \emph{back} from $D$ to its parent $B$, the
6654 supplementary list becomes \emph{cdr, car}, in other words, we find
6655 the most recent parent (car) in the list. If the user moves back
6656 again from $B$, the supplementary list becomes \emph{nil}, which means
6657 we are at the first node.
6659 The data structure is simple, but confessedly, the explanation is a
6660 bit complicated! Another simple model keeps track of the \emph{full
6661 history}. In this case, the model evolves as follows:
6662 \begin{align*}
6663 & T=(A) \\
6664 & T=(A\ B) \\
6665 & T=(A\ B\ C\ B\ D)
6666 \end{align*}
6668 This model has the benefit of retaining data about \emph{loops}
6669 (e.g. the short loop $B$, $C$, $B$). Loops can be lopped off by the
6670 following algorithm: starting at the end of the list (i.e. the current
6671 node), make a list of nodes that have been encountered, and trace
6672 backward. If the previous node hasn't been encountered, put it at the
6673 beginning of our growing loop-free list. If it has been encountered,
6674 search backward for the earliest appearance of the last novel node,
6675 and add the element preceding that one to the loop-free list. Moving
6676 ``back'' in the sense of the truncated history list of traditional
6677 browsers can be accomplished by finding antecedent of the earliest
6678 appearance of the current node. E.g., if the user wants to move
6679 \emph{back}, we add the antecedent $B$ to the list, to obtain
6680 $T=(A\ B\ C\ B\ D\ B)$. If the user wants to move \emph{back} again, we obtain
6681 $T=(A\ B\ C\ B\ D\ B\ A)$, since $A$ is the earliest immediate
6682 prequel to $B$.
6683 Similarly, to move \emph{forward} at this point, we find the
6684 latest immediate sequel to the current node; in this case, $B$ again,
6685 and put $T=(A\ B\ C\ B\ D\ B\ A\ B)$.
6687 We can also recover the data stored in the istree model. This is left
6688 as an easy exercise to the reader, but the algorithm is given in the
6689 code; for reasons of generality (and simplicity!), \emph{we are
6690 adopting the full history model as the basis of this browser}.
6692 A variety of interesting novel browser actions can be performed
6693 using this information, e.g., finding all the pages you looked at
6694 before or after this one.
6695 \end{notate}
6697 \begin{notate}{Science (fiction) tie-in}
6698 Users can tap into the lived experience of a time lord (assuming we
6699 retain the ``temporal'' metaphor), or the experience of a Wolframian
6700 particle (compare NKS) if we consider a spatial metaphor instead.
6701 We'll let you sort out the paradoxes. (\emph{Hint:} you never
6702 step in the same river twice.)
6703 \end{notate}
6705 \begin{notate}{Tabbed browsing}
6706 Users of the full history model may be in less immediate need of
6707 ``tabs'' (in the form of multiple histories) than users of the truncated
6708 history model. Alternate browsing paths are (close to) natively
6709 available. Futhermore, a page can be marked as a divider between
6710 one ``tab'' and another. Indeed, this gives us an analogy to the
6711 ``tabs'' than stick out of file folders in a physical filing cabinet.
6712 (The only difference is that pages can be in multiple files at the
6713 same time, which is as it should be.) This means that
6714 multiple histories can be used (in a read-only mode) as virtual
6715 \emph{cabinets} for organizing information. The actual system of
6716 cabinetry need not be maintained here; implementing extra browsing
6717 features is a good activity for some rainy day.
6719 On the other hand, see Note \ref{thematic-histories}.
6720 \end{notate}
6722 \begin{notate}{Thematic histories} \label{thematic-histories}
6723 It might be useful to keep a record of several different sorts of
6724 histories, e.g. of editing events or ``catalog pages'' (Note
6725 \ref{history-for-listing}). These
6726 alternate histories wouldn't have much to do with the temporal
6727 browser per se. Emacs does this in some cases (e.g. recording the
6728 input history for various interactive functions separately).
6730 If we're going to do this, probably the code in this section
6731 should be written in a somewhat more generic way.
6732 \end{notate}
6734 \begin{lisp}
6735 (defvar sb-history nil)
6737 (add-hook 'display-article-hook
6738 (lambda ()
6739 (sb-add-article-to-history name-of-current-article)))
6740 \end{lisp}
6742 \begin{notate}{Instead of adding the name} \label{instead-of-names}
6743 Maybe we should be adding directions on how to get the article.
6744 The name might not be sufficient if we end up working with
6745 nested structures.
6746 \end{notate}
6748 \begin{notate}{Complexities could be handled by `display-article'}
6749 Of course, additional sorts of access instructions (like those alluded
6750 to in Note \ref{instead-of-names}) could be handled by
6751 `display-article'. \emph{This section} does not depend on article
6752 names being stored as strings.
6753 \end{notate}
6755 \begin{lisp}
6756 (defun sb-add-article-to-history (article)
6757 (setq sb-history (nconc sb-history (list article))))
6759 (defun sb-back ()
6760 (interactive)
6761 (let ((current (car (last sb-history)))
6762 (n 0)
6763 found)
6764 (while (not found)
6765 (if (equal (nth n sb-history) current)
6766 (progn (setq found t)
6767 (if (> n 0)
6768 (display-article (nth (1- n) sb-history))
6769 (message "Already at beginning of history.")))
6770 (setq n (1+ n))))))
6772 (defun sb-forward ()
6773 (interactive)
6774 (let* ((current (car (last sb-history)))
6775 (max (1- (length sb-history)))
6776 (n (1- max))
6777 found)
6778 (while (not found)
6779 (if (equal (nth n sb-history) current)
6780 (progn (setq found t)
6781 (if (< n (1- max))
6782 (display-article (nth (1+ n) sb-history))
6783 (message "Already at end of future")))
6784 (setq n (1- n))))))
6785 \end{lisp}
6787 \begin{notate}{Keeping track of visited references} \label{visited-references}
6788 It seems like we might want to keep track of information about visited
6789 references in some data structures maintained by the temporal browser.
6790 Alternatively, we could put this information into the metadata
6791 articles attached to the articles that have been visited (which would
6792 make it easy to report the number of visits to the article owners).
6793 See Note \ref{reference-face}.
6794 \end{notate}
6796 \begin{notate}{Function to go all the way back}
6797 Should be able to go all the way back to the beginning
6798 of the history list in one go.
6799 \end{notate}
6801 \begin{notate}{On `sb-previous'}
6802 This gives the most recently browsed article besides the current
6803 one.
6804 \end{notate}
6806 \begin{lisp}
6807 (defun sb-previous ()
6808 (car (last sb-history 2)))
6809 \end{lisp}
6811 \begin{notate}{Be careful to avoid cycles}
6812 I'm not sure that the formulation of temporal browsing given in this
6813 section actually works! It needs a critical review to make sure that
6814 the future actually has an end, for example. I seem to be discovering
6815 problems by using display-only text (see Note
6816 \ref{display-purposes-only}).
6817 \end{notate}
6819 \subsection{Linear browsing} \label{linear-browsing}
6821 \begin{notate}{Browsing through the contents of a label} \label{browsing-through-the-contents-of-a-label}
6822 In Note \ref{multidimensional-visual-browsing}, the idea of being able
6823 to move forward through the document's natural structure was
6824 discussed. One of the easiest ways to define this sort of structure
6825 is relative to the contents of some label. A more advanced mode would
6826 stitch together several labels, e.g., the sections and subsections of
6827 a document, with some simple logic for moving from label to label. In
6828 addition, a given article might appear as part of several labels, in
6829 which case, the user could be presented with possible directions to
6830 travel in. This is in some sense an extension of Section \ref{local},
6831 since it gives more local directions to go in. It is also similar to
6832 the idea of following through a set of slides (and presumably would
6833 make it easy to implement such an arrangement).
6835 The key thing seems to be identification of the ``parent'' label(s)
6836 to use for this purpose. Maybe this info is already available in
6837 the form of backlinks? Although, note that we might not always
6838 want to turn on this sort of label browsing for all labels all the
6839 time.
6840 \end{notate}
6842 \begin{notate}{Disposition of code for linear browsing}
6843 Some code for additional graphical features has been added
6844 to the scholia display by `scholia-display-extras'. It would
6845 be good to add some commands to do a semantically similar
6846 sort of navigation non-graphically, here. When the multi-parent
6847 browsing ideas from Note \ref{more-than-one-parent} have
6848 become fixed, they should of course be available here too.
6849 \end{notate}
6851 \begin{notate}{On `add-visible-back-temporal-link'} \label{add-visible-back-temporal-link}
6852 This makes a link to the previous-browsed page appear in the Scholia
6853 Display. It runs within the scope of `scholia-display-extras' (Note
6854 \ref{scholia-display-extras}).
6856 It like we should potentially be able to change the strategy here, so
6857 as to add more information to the text properties and not actually
6858 create any corresponding article. I think this would require some
6859 adjustments to the way text properties are handled.
6860 \end{notate}
6862 \begin{lisp}
6863 (defun add-visible-back-temporal-link ()
6864 ;; this should be marked up to become a fake link (one that isn't
6865 ;; displayed in the main buffer)
6866 (when (sb-previous)
6867 (insert "\n\n"
6868 "Back (temporal): ")
6869 (let ((beg (point)))
6870 (insert (propertize
6871 (format "%s" (sb-previous)) 'face 'sch-reference-face))
6872 (scholium 'reference-to-previous-article
6874 `((,name-of-current-article
6875 (passage
6876 ,beg
6877 ,(point)))
6878 (,(sb-previous)))
6879 '(reference fake))
6880 (add-to-scholia-property-within-region
6882 (point)
6883 '(reference-to-previous-article 1 1)))))
6884 \end{lisp}
6886 \begin{notate}{On `add-visible-parent-and-sibling-links'} \label{add-visible-parent-and-sibling-links}
6887 This adds links to the parent and nearest siblings in the Scholia
6888 Display buffer. It runs within the scope of `scholia-display-extras'
6889 (Note \ref{scholia-display-extras}).
6890 \end{notate}
6892 \begin{lisp}
6893 (defun add-visible-parent-and-sibling-links ()
6894 ;; identify the link to the parent, if it exists.
6895 ;; (this assumes that there is only one parent)
6896 (let ((link-to-parent (car (member-if (lambda (link)
6897 (member 'parent (cdr link)))
6898 (scholium-about article)))))
6899 (when link-to-parent
6900 (let* ((parent (get-article (first link-to-parent)))
6901 (parent-data
6902 (scholium-text parent))
6903 (this-name-headed (member name-of-current-article
6904 parent-data))
6905 (next (cadr this-name-headed))
6906 (prev (car (last (butlast parent-data
6907 (length this-name-headed))))))
6908 (when parent
6909 (insert "\n\n"
6910 "Parent: ")
6911 (let ((beg (point)))
6912 (insert (propertize (format "%s" (scholium-name parent))
6913 'face 'sch-reference-face))
6914 (scholium 'reference-to-parent
6916 `((,name-of-current-article
6917 (passage
6918 ,beg
6919 ,(point)))
6920 (,(scholium-name parent)))
6921 '(reference fake))
6922 (add-to-scholia-property-within-region
6924 (point)
6925 '(reference-to-parent 1 1))))
6926 (when prev
6927 (insert "\n\n"
6928 "Back (in parent): ")
6929 (let ((beg (point)))
6930 (insert (propertize (format "%s" prev) 'face 'sch-reference-face))
6931 (scholium 'reference-to-previous-article-in-parent
6933 `((,name-of-current-article
6934 (passage
6935 ,beg
6936 ,(point)))
6937 (,prev))
6938 '(reference fake))
6939 (add-to-scholia-property-within-region
6941 (point)
6942 '(reference-to-previous-article-in-parent 1 1))))
6943 (when next
6944 (insert "\n\n"
6945 "Forward (in parent): ")
6946 (let ((beg (point)))
6947 (insert (propertize (format "%s" next)
6948 'face
6949 'sch-reference-face))
6950 (scholium 'reference-to-next-article-in-parent
6952 `((,name-of-current-article
6953 (passage
6954 ,beg
6955 ,(point)))
6956 (,next))
6957 '(reference fake))
6958 (add-to-scholia-property-within-region
6960 (point)
6961 '(reference-to-next-article-in-parent 1 1))))))))
6963 (add-hook 'scholia-display-extras-hook
6964 'add-visible-back-temporal-link)
6965 (add-hook 'scholia-display-extras-hook
6966 'add-visible-parent-and-sibling-links)
6967 \end{lisp}
6969 \begin{notate}{On `forward-in-parent'} \label{forward-in-parent}
6970 A quick command to get the label identified as this object's parent,
6971 and move to the next mentioned after this one in this label. (It
6972 would also be possible to follow the next reference in a page, i.e.,
6973 use a page like a label; but this function doesn't do that.)
6975 It would be nice to have this function select the ``next cousin'' (or
6976 other suitable relative) if we are out of siblings.
6978 We'll also want a quick command to hop \emph{to} an article's parent.
6979 \end{notate}
6981 \begin{lisp}
6982 (defun forward-in-parent ()
6983 (interactive))
6984 \end{lisp}
6986 \begin{notate}{On `backward-in-parent'} \label{backward-in-parent}
6987 Like `forward-in-parent' (Note \ref{forward-in-parent}) but moves
6988 backward instead.
6989 \end{notate}
6991 \begin{lisp}
6992 (defun backward-in-parent ()
6993 (interactive))
6994 \end{lisp}
6996 \section{Editing and deleting} \label{editing}
6998 \subsection{Initiating edits} \label{initiating-edits}
7000 \begin{notate}{How to initiate edits}
7001 Buffers are frequently non-read-only; if these buffers have been
7002 marked up with scholia, then they can be edited directly. The Main
7003 Article Display buffer (for scholia with no other or better home) may
7004 as well be non-read-only as well. The point being that to start
7005 editing the \inp{text} of an article, one just needs to begin. (In
7006 the current implementation, articles in the Scholia Display buffer
7007 need to be made current with `follow-scholium', or by some other
7008 means, but that is easy enough.)
7010 However, the other parts of an article (Note
7011 \ref{definition-of-scholium}) are not immediately editable without
7012 some intermediate step to call them up and expose them to the user.
7013 Since \inp{bookkeeping} data is maintained by the system itself, the
7014 only parts of articles that need special initial steps to edit are the
7015 \inp{name}, \inp{about}, and \inp{type} fields.
7016 \end{notate}
7018 \begin{notate}{Inserting text in the middle of a marked up region} \label{inserting-text-in-middle-of-marked-up-region}
7019 When someone inserts text into the middle of a marked up region, does
7020 the new text take on the markup properties of the surrounding text, or
7021 does it not, or can we make it an option, to possibly be exercised in
7022 different ways in different places? I assume we will want different
7023 behavior at different times. (Cf. Note
7024 \ref{splitting-text-properties}). The reference to consider is the
7025 ``Sticky Properties'' node from the Elisp manual\footnote{(info
7026 "(elisp)Sticky Properties")}.
7028 There they tell us that
7029 \begin{quotation}
7030 By default, a text property is rear-sticky but not front-sticky; thus,
7031 the default is to inherit all the properties of the preceding
7032 character, and nothing from the following character.
7033 \end{quotation}
7034 Furthermore,
7035 \begin{quotation}
7036 If a character's `rear-nonsticky' property is `t', then none of its
7037 properties are rear-sticky. If the `rear-nonsticky' property is a
7038 list, properties are rear-sticky \emph{unless} their names are in the
7039 list.
7040 \end{quotation}
7041 Thus, we have nothing to worry about in terms of front-stickiness, but
7042 we must maintain an appropriate rear-nonsticky list throughout the
7043 regions in which we want some of the properties to be non-sticky.
7045 Something like this (enhanced, of course) will work:
7046 \begin{idea}
7047 (progn (put-text-property (line-beginning-position) (line-end-position)
7048 'face 'italic)
7049 (put-text-property (line-beginning-position) (line-end-position)
7050 'rear-nonsticky '(face)))
7051 \end{idea}
7052 \end{notate}
7054 \subsection{Editing `about' data} \label{editing-about-data}
7056 \begin{notate}{The joys and sorrows of editing `about' data}
7057 As noted in \ref{consistency-editing}, changes to \inp{about} data can
7058 have broad ramifications. In addition to masking any explicit links
7059 that point at this data, we will have to change everything that uses
7060 link-id's.
7062 In particular, backlinks corresponding to the set of edited links will
7063 have to change. I think that this part at least can be accomplished
7064 by running `scholium-modified-about-hook' (cf. Note
7065 \ref{hooks-for-new-and-modified-scholia} and Note
7066 \ref{put-backlinks}).
7068 We'll have to decide whether it is worth our trouble to change markup
7069 (it would seem to be inavoidable; however, as a quick work-around,
7070 perhaps other renderings can simply be blanked out when \inp{about}
7071 data is being edited).
7072 \end{notate}
7074 \subsection{Finding revised `about' data by parsing text properties} \label{parsing}
7076 \begin{notate}{Mini-overview of parsing text properties}
7077 This section concerns the topic of finding changes to \inp{about} data
7078 of scholia that are induced by changes to the \inp{text} of an article
7079 that they are \inp{about}.
7080 \end{notate}
7082 \begin{notate}{Overview of parsing text-properties} \label{overview-of-parsing-text-properties}
7083 By finding the places in a marked-up buffer where the `scholia'
7084 property changes and examining its value before and after the change
7085 point, the beginning and end of each marked region can be found. (See
7086 the description of this property in Note \ref{the-scholia-property}.)
7088 More specifically: (1) we must find all the places where the `scholia'
7089 property changes; (2) then figure out what was new or what went away
7090 at each change point; (3) and update a list of beginnings and endings
7091 in the approximate form of an \inp{about} list. This is a first step
7092 in the lengthier process of committing edits (see Section
7093 \ref{committing}).
7094 \end{notate}
7096 \begin{notate}{Indicator functions} \label{indicator-functions}
7097 We can have marked regions that overlap to any depth; overlapping
7098 scholia can also have non-trivial non-overlapping regions.
7100 In a mathematical abstraction, we might see scholia like
7101 $\indicator{[0,3]}$, $\chi_{[1,10]}'$, $\chi_{[2,5]}''$,
7102 $\chi_{[8,9]}'''$ (as pictured in Figure
7103 \ref{Simulation-with-indicator-functions}). We could even have
7104 different regions from the same scholium overlap.
7106 It would be nice to be able to indicate arbitrary subsets of the
7107 \inp{text} that we're presented with. The actual set of available
7108 indicators is a $\sigma$-algebra, if I remember correctly.
7110 For LISP code, picking out arbitrary bits of list structure would be
7111 handy (see Note \ref{including-transcluding-and-lisp}).
7112 \end{notate}
7114 \begin{notate}{On `scholia-property-at-changepoints'}
7115 This returns a list of pairs; points where
7116 the `scholia' property changes paired with the value of the `scholia'
7117 property at those points.
7119 \begin{figure}
7120 \begin{center}
7121 %% in LaTeX, ascii art is a little bit trickier than usual
7122 {\tt
7123 \begin{tabular}{l}
7124 \ \ \ \ \ \ \ \ -- \\
7125 \ \ ------ \\
7126 \ ------------------ \\
7127 ------ \\
7128 1234567890
7129 \end{tabular}}
7130 \end{center}
7131 \caption{Markup simulated with indicator functions \label{Simulation-with-indicator-functions}}
7132 \end{figure}
7133 \end{notate}
7135 \begin{lisp}
7136 (defun scholia-property-at-changepoints ()
7137 (let ((next-change-point (point-min))
7138 change-points)
7139 (while next-change-point
7140 (setq change-points (cons (list next-change-point
7141 (get-text-property
7142 next-change-point
7143 'scholia))
7144 change-points))
7145 (setq next-change-point (next-single-property-change+predicate
7146 next-change-point
7147 'scholia
7148 'equal)))
7149 (when (not (null (get-text-property
7150 (caar change-points)
7151 'scholia)))
7152 (setq change-points (cons (point-max) change-points)))
7153 (reverse change-points)))
7154 \end{lisp}
7156 \begin{notate}{On `detect-scholia-structure'} \label{detect-scholia-structure}
7157 This function says which passages of the current article have been
7158 marked up with which scholia. Typically, this function will be run
7159 after editing, to recover the modified markup information and
7160 propagate it to attached scholia (see Section \ref{committing}).
7162 The way the function works is as follows. At each of the change
7163 points, we find the the annotations that have either just appeared or
7164 just disappeared, by using the `set-difference' function to compare
7165 the value of the `scholia' property at the \emph{upcoming} change
7166 point with the value at the \emph{current} one. We then sort the
7167 elements of this difference into ``opening'' and ``closing'' sets
7168 based on whether they are present at the \emph{upcoming} change point,
7169 or the \emph{current} one. In order to ensure that there is an
7170 adequate basis for comparison in all cases, exogenous points at
7171 ``$-\infty$'' and ``$\infty$'' are introduced, with no scholia
7172 attached to them.
7174 Every ``opening'' element corresponds to some as-yet-unseen marked-up
7175 region; when encountering such an item, we add a term to the return
7176 value that looks like ``(VALUE BEG)'' where VALUE and BEG are,
7177 respectively
7178 \begin{itemize}
7179 \item the value of the `scholia' property -- which will be the
7180 name of a scholium together with a unique link identifier, as
7181 described in Note \ref{the-scholia-property};
7182 \item and the point where this link starts to attach to the current
7183 article.
7184 \end{itemize}
7185 Similarly, every ``closing'' element corresponds to the end of some
7186 already-seen marked-up region. When encountering such elements, we
7187 modify the corresponding previously added term in the return value to
7188 read ``(VALUE BEG END)'', END here being the point where the link in
7189 question stops attaching to the current document.
7191 Note that since `scholia-property-at-changepoints' gives us the values
7192 in increasing order, new ``opening'' items are encountered and added
7193 to the list in increasing order as well. This property is important
7194 for later.
7195 \end{notate}
7197 \begin{lisp}
7198 (defun detect-scholia-structure ()
7199 (let ((begs-and-ends
7200 (cons '(-infinity nil)
7201 (append
7202 (scholia-property-at-changepoints)
7203 (list '(infinity nil)))))
7204 marked-regions)
7205 (while (> (length begs-and-ends) 1)
7206 (let ((difference (set-difference (second
7207 (first begs-and-ends))
7208 (second
7209 (second begs-and-ends))))
7210 opening
7211 closing)
7212 (when difference
7213 (dolist (elt difference)
7214 (if (member elt (second (second begs-and-ends)))
7215 (setq opening (cons elt opening))
7216 (setq closing (cons elt closing))))
7217 (dolist (elt opening)
7218 (setq marked-regions
7219 (add-to-or-start-list
7220 marked-regions
7221 `(,elt ,(first (second begs-and-ends))))))
7222 (dolist (elt closing)
7223 (let ((found (member-if (lambda (pass)
7224 (equal (first pass) elt))
7225 marked-regions)))
7226 (setcdr (cdr (car found))
7227 (list (first (second begs-and-ends)))))))
7228 (setq begs-and-ends (cdr begs-and-ends))))
7229 marked-regions))
7230 \end{lisp}
7232 \begin{notate}{New scholia added while editing}
7233 I don't \emph{think} that new scholia added while editing will need to
7234 be treated any differently during the reparsing process from scholia
7235 that were created before editing started. Scholium-creation should be
7236 a self-contained process that gets everything stored properly; the
7237 only special concern is that text properties would need to be added to
7238 the buffer that is being edited, but that's obvious enough.
7239 \end{notate}
7241 \begin{notate}{Finding changes in scholia about the whole article} \label{changes-in-scholia-about-whole-article}
7242 Presumably this data will be stored in a relevant metadata article,
7243 rather than in text properties (contrast Aaron's picture). We
7244 probably won't have to do reparsing to handle scholia like this,
7245 \emph{but we will have to do something}.
7246 \end{notate}
7248 \begin{notate}{Make `scholia' a variable?}
7249 It would be easy enough to make `scholia' as used above
7250 into a variable instead of hard code, so that we could read from
7251 another text property instead. Probably we would want to complement
7252 this with similar changes to the code that adds text properties!
7253 \end{notate}
7255 \subsection{Committing edits} \label{committing}
7257 \begin{notate}{Themes for committing}
7258 (1) Store stuff to metadata articles;
7259 (2) Prefer these for rendering purposes.
7260 \end{notate}
7262 \begin{notate}{Committing implications}
7263 Edits to any part of a scholium (in particular, to its \inp{name},
7264 \inp{text}, \inp{about}, or \inp{type} data) need to be saved and
7265 otherwise processed. Sometimes changes in one article will result in
7266 changes to other articles, e.g., \emph{changing \inp{about} data may
7267 lead to changes in backlinks}; and changes to \inp{text} may lead to
7268 changes in one or more attached scholium's \inp{about} data (Note
7269 \ref{set-updated-about-info}).
7270 \end{notate}
7272 \begin{notate}{Bookkeeping and version managing}
7273 When articles have been modified, \inp{bookkeeping} data needs to be
7274 updated. In particular, we are supposed save sufficient data to move
7275 back and forth between article versions. This is true of both
7276 \inp{text} data and the other data that make up articles (\inp{name}
7277 may be handled somewhat differently, but in general we need to store
7278 enough data to move between all versions of the article).
7279 \end{notate}
7281 \begin{notate}{Setting updated `about' information} \label{set-updated-about-info}
7282 The idea of preferring metadata articles when rendering has been
7283 discussed in the section on metadata articles (Section
7284 \ref{metadata-articles} and Note \ref{updating-link-extent} in
7285 particular), and is reflected in the way `mark-things-up' is written
7286 (Note \ref{mark-things-up}). For this all to work, it is necessary
7287 for `commit-edits' to store updated \inp{about} data when it runs.
7288 \end{notate}
7290 \begin{notate}{On `store-link-masks'} \label{store-link-masks}
7291 This function runs within the scope of `commit-edits', after
7292 `adjusted-markup' has been found by parsing (Note \ref{commit-edits}).
7293 Indeed, so far, this is the only significant default action of
7294 `commit-edits' (cf. Note \ref{set-updated-about-info}).
7296 The function compares the elements of `current-markup' (Note
7297 \ref{current-markup}) to the elements of `adjusted-markup'. When
7298 changes are present in the markup data, `store-link-masks' adds or
7299 changes masks.
7301 More precisely, for each element of `current-markup', we select
7302 from `adjusted-markup' those elements with the same link-id
7303 (or maybe mask-id). These are the `matching-regions' corresponding
7304 to that markup element. Unless there is only one matching region
7305 and this matching region happen to point to extend over exactly
7306 the range specified by the original link, we execute an operation
7307 on masks.
7309 This operation is to swap in a replacement mask, if the markup
7310 element was coming from a mask already, or to create a brand new
7311 mask otherwise. If we're doing a replacement, we look for the
7312 \emph{one} mask that corresponds to the link-id borne by the
7313 current markup element. We then substitute \emph{all} of the
7314 matching regions, for whatever was previously stored in this mask.
7316 Otherwise, we just create a new mask with the appropriate link-id,
7317 containing the relevant regions.
7318 \end{notate}
7320 \begin{lisp}
7321 (defun store-link-masks ()
7322 (dolist (link-ext current-markup)
7323 (let* ((matching-regions (remove-if
7324 (lambda (markup-item)
7325 (not (equal (car markup-item)
7326 (car link-ext))))
7327 adjusted-markup))
7328 (num-matching-regions (length matching-regions))
7329 (name-of-linking-article (if (eq (first
7330 (car link-ext)) 'mask)
7331 (first (second
7332 (first link-ext)))
7333 (first (first link-ext)))))
7334 (unless (and (eq num-matching-regions 1)
7335 (equal (cdr (first matching-regions))
7336 (cdr link-ext)))
7337 (if (eq (caar link-ext) 'mask)
7338 ;; swap in a different mask
7339 (let* ((masks
7340 (get-metadata-field 'masks
7341 name-of-linking-article))
7342 (current-mask-headed
7343 (member-if (lambda (item)
7344 (equal (second (car link-ext))
7345 (car item)))
7346 masks)))
7347 (setcdr (car current-mask-headed)
7348 (mapcar (lambda (ided-reg)
7349 (cdr ided-reg))
7350 matching-regions))
7351 (put-metadata-field 'masks
7352 masks
7353 name-of-linking-article))
7354 ;; create a new mask
7355 (let ((masks (or (get-metadata-field
7356 'masks
7357 name-of-linking-article)
7358 (list 'masks))))
7359 (put-metadata-field
7360 'masks
7361 (setcdr
7362 masks
7363 (add-to-or-start-list
7364 (cdr masks)
7365 `(,(car link-ext)
7366 ,@(mapcar (lambda (ided-reg) (cdr ided-reg))
7367 matching-regions))))
7368 name-of-linking-article)))))))
7369 \end{lisp}
7371 \begin{notate}{Adding new markup to rendered articles} \label{adding-new-markup-to-rendered-articles}
7372 Adding new markup to rendered articles
7373 will introduce a discrepancy
7374 between `adjusted-markup' and `current-markup', i.e., items
7375 will be found that weren't there before. This shouldn't,
7376 be a problem, because `store-link-masks' iterates through the
7377 members of `current-markup' looking for matches. So, anything
7378 completely new in `adjusted-markup' will be ignored by
7379 the `store-link-masks' phase of the commit process. This
7380 is relevant to Section \ref{derivative}, and any other code
7381 that modifies the markup of rendered articles.
7382 \end{notate}
7384 \begin{notate}{On `commit-edits-hook'} \label{commit-edits-hook}
7385 This is the single point of customization for the commit function,
7386 to be used in future sections. It runs within the scope of
7387 `commit-edits', after `adjusted-markup' has been found
7388 by parsing. Thus, functions that are added to this hook can
7389 take advantage of this knowledge about the current state of
7390 markup.
7391 \end{notate}
7393 \begin{lisp}
7394 (defvar commit-edits-hook nil)
7395 \end{lisp}
7397 \begin{notate}{On `after-committing-edits-hook'} \label{after-committing-edits-hook}
7398 This facilitates additional actions after the main committing
7399 routines are finished.
7400 \end{notate}
7402 \begin{lisp}
7403 (defvar after-committing-edits-hook nil)
7404 \end{lisp}
7406 \begin{notate}{Summary of idea behind `commit-edits'}
7407 When you edit the buffer, the text properties showing where scholia
7408 are attached move around. When you run `commit-edits', metadata
7409 indicating the new position of these regions is stored; it will be
7410 used subsequently so that the correct regions are highlighted. (These
7411 suggestions coming can later be incorporated into the scholia by their
7412 authors.) Furthermore, `commit-edits' stores a version of the article
7413 for subsequent browsing.
7414 \end{notate}
7416 \begin{notate}{On `commit-edits'} \label{commit-edits}
7417 Anything run by the `commit-edits-hook' that changes the text of the
7418 article being committed should store the desired value on
7419 `adjusted-text'. It is going to take a bit of thinking about how to
7420 make several functions (particularly functions having to do with
7421 derivatives) run properly, in serial. (But I'm pretty sure it can be
7422 done.)
7424 Note that when committing we currently make sure that exactly one
7425 newline is attached to the end of the page when the text is
7426 saved. This has a beneficial effect on exporting the scholium
7427 system (see \ref{export-scholium-system}).
7429 We may at some point want one or more commit functions that will store
7430 more different kinds of edits from more different places. For
7431 example, we'll want to be able to commit edits that take place in the
7432 Scholia Display buffer. Similarly for edits to `about' data, and so
7433 forth (see Note \ref{editing-about-data}).
7434 \end{notate}
7436 \begin{lisp}
7437 (defun commit-edits ()
7438 (interactive)
7439 (let* ((adjusted-markup (copy-tree (detect-scholia-structure)))
7440 (old-contents (get-article name-of-current-article))
7441 (adjusted-text (buffer-substring-no-properties (point-min)
7442 (point-max)))
7443 (old-text (scholium-text old-contents)))
7444 (store-link-masks)
7445 (run-hooks 'commit-edits-hook)
7446 ;; here is where the criterion for checking that some change has
7447 ;; actually been made would be inserted
7448 (when (not (equal adjusted-text old-text))
7449 (scholium name-of-current-article
7450 (with-temp-buffer (insert adjusted-text)
7451 (goto-char (point-max))
7452 (insert "\n")
7453 (delete-blank-lines)
7454 (buffer-substring-no-properties
7455 (point-min)
7456 (point-max)))
7457 ;; of course, for more advanced versions of
7458 ;; this code, these won't be static
7459 (scholium-about old-contents)
7460 (scholium-type old-contents)
7461 ;; this should be reformatted to store the old
7462 ;; version!
7463 (scholium-bookkeeping old-contents)))
7464 (run-hooks 'after-committing-edits-hook)))
7465 \end{lisp}
7467 \begin{notate}{After committing, redisplay article}
7468 Hopefully this won't cause any problems. The one concerning point I
7469 can think of might come up when committing fully rendered and
7470 identified compilations (Section \ref{quick-compilations}), but we
7471 haven't worked out the major details of that yet, so there's no reason
7472 to worry about this one minor one.
7473 \end{notate}
7475 \begin{lisp}
7476 (add-hook 'after-committing-edits-hook 'redisplay-article)
7477 \end{lisp}
7479 \begin{notate}{Shortcomings of the basic commit implementation}
7480 Old comments should continue to apply verbatim to the old version of
7481 the document -- and also, tentatively, to the new version. Maybe
7482 masks should contain information about which version of the article
7483 they apply to. A given link could have a collection of masks, each
7484 relevant to a different version of the article being linked to
7485 (perhaps recycling content when the masks are known to be the same).
7487 And, of course, commiting is going to have to store a version of the
7488 article on the \inp{bookkeeping} list (or equivalent; see Note
7489 \ref{vc-and-filesystem-support}). We will then want support for
7490 \emph{version browsing} -- hopefully the browsing functions can be
7491 made to ``just work'' on data coming in with an explicit version
7492 number.
7494 And, in addition, we should be updating backlinks as needed.
7496 (These items should be assessed to see how critical they are; it seems
7497 to me that we can probably work with things roughly as they are, if we
7498 aren't doing anything too wild. It would be interesting to document
7499 the process of coming to rely more heavily on the system as time goes
7500 by.)
7502 Another nice thing would be to make sure that there is a
7503 newline at the end of the committed text.
7504 \end{notate}
7506 \begin{notate}{Assigning masks after reparsing} \label{send-messages-to-redirected-scholia}
7507 We send a message to each of the scholia that have been redirected
7508 after editing has taken place (cf. Note \ref{masks}). In order to do
7509 this, we have to compare the new markup data with the old markup data
7510 to figure out what will change. We may want to keep a buffer-local
7511 record of the original markup data in order to figure out precisely
7512 what has changed. (I think for now we just assume that there is one
7513 rendered article at a time, so we only keep track of one set of old
7514 markup data. But don't quote me on that.)
7516 Alternatively, we could mask \emph{everything}, regardless of whether
7517 or not this data has actually changed, but this seems rather silly,
7518 and potentially very inefficient besides. So we don't do that.
7519 \end{notate}
7521 \begin{notate}{Similarity of deleting and committing} \label{similarity-of-deleting-and-committing}
7522 Note that deleting is probably going to be similar to committing, in
7523 terms of the way changes to \inp{about} data are reported and stored.
7524 (See Section \ref{deletion}.)
7525 \end{notate}
7527 \begin{notate}{Where to store committed edits}
7528 One thing I'm somewhat curious about is whether it is ever safe to
7529 assume that we can make changes to an attached scholium
7530 \emph{directly}, without waiting for its owner's input. It seems more
7531 likely that we would want to put the updated information on that
7532 scholium's \emph{metadata article}, which is its ``world-writable''
7533 space (see Note \ref{metadata-article-overview}). If we do this,
7534 that means that the routine we use to find a scholium's \inp{about}
7535 data when rendering a given article may have to look at the scholium's
7536 metadata article. (The case in which the same person owns both
7537 articles might be one case in which we would wish to make changes
7538 directly.)
7539 \end{notate}
7541 \begin{notate}{The role of metadata} \label{role-of-metadata}
7542 If we assume that changes aren't made directly, then the owner of the
7543 scholium whose metadata article has been changed will have the
7544 opportunity to accept or decline the suggested changes. Note that if
7545 the author doesn't accept the changes, then the rest of the world may
7546 still have the option to use \inp{about} data from the metadata
7547 article instead of from the article itself. Also note that even if a
7548 commentator retracts remarks for some updated version of the article,
7549 they may continue to apply to earlier versions.
7551 When a commentator accepts changes, most likely what will happen is
7552 that a new version of the scholium will be created, and the specific
7553 suggestions removed from its metadata article. However, if the
7554 suggestion is declined, most likely the suggestions will stay on the
7555 metadata article. (This situation seems a bit backwards.)
7556 Alternatively, if the suggestions are declined, the author might just
7557 delete them (if we make it so that anyone can make changes to the
7558 metadata article -- which might be reasonable).
7560 For more on this topic, see Section
7561 \ref{responding-to-incoming-metadata}.
7562 \end{notate}
7564 \begin{notate}{The possibility for conflicts in backpropagated `about' data} \label{conflicts-in-masks}
7565 The potential for conflicts in suggested changes coming from edits to
7566 various different articles exists, in theory, but I think it is
7567 dispatched by the fact that each region is drawn from exactly one
7568 article. So, as long as each link is kept up-to-date with respect to
7569 any changes in the one article that it applies to, there won't be any
7570 conflict.
7571 \end{notate}
7573 \begin{notate}{Conflicts in a distributed environment} \label{conflicts-in-a-distributed-environment}
7574 Of course it is the case that if the same article is being changed or
7575 even just talked about in several different places, or if it is a
7576 scholium that applies to several articles that reside in different
7577 repositories, many different sorts of conflicts could arise. The task
7578 of assimilating changes from various locations should be given at
7579 least partial support in code.
7580 \end{notate}
7582 \begin{notate}{Committing and reverting}
7583 Note that ``revert'' is in some weak sense an opposite action to
7584 ``commit''. (See also Note
7585 \ref{similarity-of-deleting-and-committing}.)
7586 \end{notate}
7588 \subsection{Editing en masse} \label{masse}
7590 \begin{notate}{Enhanced control panel}
7591 It might be good to add another column to the article listing control
7592 panel. Any changes to the article listing that take place in this
7593 section should be done somewhat delicately and artistically.
7594 Presumably this implies that the list of column-fields should be
7595 stored as a variable, so that it can be easily modified. Note that
7596 functions for mapping over lists of articles forms the theoretical
7597 basis of this section (see Note
7598 \ref{mapping-across-a-subcollection}).
7599 \end{notate}
7601 \begin{notate}{Adding metadata en masse}
7602 It isn't quite ``editing'', but equally important would
7603 be a way to apply a given scholium to a set of articles
7604 (both severally and not severally), or add type data to
7605 a set of articles that you own, or whatever.
7606 \end{notate}
7608 \begin{notate}{On `label-marked-articles'}
7609 Apply the specified \inp{label} to each marked article.
7610 New labels can be applied no problem.
7611 \end{notate}
7613 \begin{lisp}
7614 (defun label-marked-articles (label)
7615 (interactive (list
7616 (intern (let ((completion-ignore-case t))
7617 (completing-read
7618 "Label: "
7619 (label-to-list 'label))))))
7620 (let (article-names)
7621 (save-excursion
7622 (goto-line 2)
7623 (goto-char (line-beginning-position))
7624 (while (re-search-forward "^> ." nil t)
7625 (setq article-names
7626 (append article-names
7627 (list
7628 (get-text-property (point) 'name))))))
7629 (dolist (name article-names)
7630 (label-article name label))))
7631 \end{lisp}
7633 \subsection{Deletion} \label{deletion}
7635 \begin{notate}{Deleting articles} \label{deleting-articles}
7636 It is sometimes desirable to delete articles that are no longer worth
7637 looking at. We want to give the user this power, though in some cases
7638 it would be nice if the article wasn't really deleted and was instead
7639 just \emph{depreciated}.
7641 There is a somewhat complex operation that should be executed when an
7642 article is actual deleted (and/or, conversely, a somewhat complex
7643 system we should put in place to deal, at render time, with articles
7644 that have been deleted without sufficient follow-through). Some of
7645 the steps in the deletion process should be: (1) deleting backlinks;
7646 (2) unindexing the article from whatever labels the article has been
7647 indexed in.
7649 But right now, we just delete.
7650 \end{notate}
7652 \begin{notate}{Steps to be taken when deleting an article} \label{steps-when-deleting}
7653 If the article is a scholium attached to the current article,
7654 we should remove the associated text properties and overlays.
7656 Since in theory we can't modify the \inp{about} data that point
7657 at the deleted article, we might want to broadcast a signal to
7658 these articles that say that their referent has been deleted.
7659 One way to do this would be to replace the article with a
7660 ``Deleted Article'' stub, and probably add it to a ``deleted''
7661 label.
7663 Of course, as with other issues having to do with \emph{propagation}
7664 things are somewhat different if all the articles are owned
7665 by the same person (or otherwise have conventions associated
7666 with them whereby they can be kept in sync without problems).
7667 \end{notate}
7669 \begin{notate}{Set current article to `nil'}
7670 If the current article is deleted, then the `name-of-current-article'
7671 variable should probably be set to nil. (Either that, or something
7672 from the temporal browser should be used to set the variable to the
7673 last-browsed page.)
7674 \end{notate}
7676 \begin{lisp}
7677 (defvar delete-article-hook nil)
7679 (defun delete-article (name)
7680 (interactive (list (read-article-name)))
7681 (let ((article (get-article name)))
7682 (if article
7683 (progn
7684 (remhash name article-table)
7685 (when (equal name name-of-current-article)
7686 (setq name-of-current-article nil))
7687 (run-hooks 'delete-article-hook))
7688 (error "No article by that name found"))))
7689 \end{lisp}
7691 \begin{notate}{Deal with effects on temporal browser}
7692 It is a little weird to revised history to make it look like deleted
7693 pages \emph{never existed}. Seriously Orwellian. For now, that's
7694 exactly what we do.
7695 \end{notate}
7697 \begin{notate}{On `remove-appearances-in-history'}
7698 This function will run inside the scope of `delete-article'.
7699 \end{notate}
7701 \begin{lisp}
7702 (defun remove-appearances-in-history ()
7703 (setq sb-history (delete name sb-history)))
7705 (add-hook 'delete-article-hook 'remove-appearances-in-history)
7706 \end{lisp}
7708 \begin{notate}{Deal with effects on articles that deleted article was attached to}
7709 Presumably articles that the deleted article linked to will have to
7710 have their backlinks adjusted. That is to say, it would be somewhat
7711 odd to have backlinks to an article that doesn't exist.
7712 \end{notate}
7714 \begin{notate}{On `delete-scholium-associated-with-current-marked-region'}
7715 Provides a quick way to delete the scholium attached to region
7716 containing point. If more than one scholium is so attached,
7717 we bring up a menu to select items for deletion.
7719 This function assumes that the `scholia' property is simply
7720 comprised of a list of the names of attached scholia; I'm
7721 not so sure that this is an accurate assumption (if not,
7722 then we should be able to easily extract such a list from
7723 the actual `scholia' property).
7725 This is just one of several functions that would benefit from
7726 the addition of progressive markup modifications.
7727 \end{notate}
7729 \begin{lisp}
7730 (defun delete-scholium-associated-with-current-marked-region ()
7731 (interactive)
7732 (let ((linked-scholia (scholia-named-at-point)))
7733 (cond
7734 ((eq (length linked-scholia) 0)
7735 (message "No scholium attached here."))
7736 ((eq (length linked-scholia) 1)
7737 (delete-article (car linked-scholia)))
7739 (list-articles linked-scholia)
7740 (message
7741 "Inspect articles and select items for deletion with \"d\".")))))
7742 \end{lisp}
7744 \begin{notate}{Deletion in various strengths}
7745 Probably there should be several different kinds of
7746 deletion (like in X windows, there is kill, destroy, minimize, wipe
7747 out to the fifth generation, etc.; also, compare the several
7748 different ``strengths'' derivative articles come in).
7749 \end{notate}
7751 \subsection{Responding to incoming metadata} \label{responding-to-incoming-metadata}
7753 \begin{notate}{How to deal with metadata}
7754 This section gives support for article owners dealing with incoming
7755 metadata coming from editing events. An important example: scholia
7756 may see suggested changes to their \inp{about} data when the
7757 article(s) that they are about change). Authors might want to
7758 incorporate such incoming changes into their document, or obliterate
7759 them, or revise them. Perhaps a scholium author will want their
7760 comments to apply to the version of the article it commented on, but
7761 not to the revised version. Or perhaps a scholium author would like
7762 to drop their content all together (to the extent that this is
7763 possible). We'll do what we can to accomodate these various actions
7764 in this section.
7765 \end{notate}
7767 \subsection{Editing labels} \label{editing-labels}
7769 \begin{notate}{To edit labels}
7770 If you're going to edit a label, you'd like to do things like insert
7771 new articles, delete old articles, rearrange the order of entries, and
7772 so on. Preliminary support for this sort of thing is given in this
7773 section.
7774 \end{notate}
7776 \begin{notate}{On `article-menu-insert-new-article'}
7777 This function lets you add new articles to a recently browsed label.
7779 For now, we assume that we really are adding a \emph{new} article
7780 (and not some existing one); and that this new article will
7781 take the quotidian form offered by `make-scholium' (Note
7782 \ref{make-scholium}). These assumptions may be relaxed later.
7784 The function one of `label-article' and `label-article-insert-before'
7785 to add the label to the new article (Note \ref{label-article}, Note
7786 \ref{label-article-insert-before}).
7788 (When creating this new article, I hope that enough ancillary metadata
7789 , \inp{type} and so on, is added to allow it to be recognized as part
7790 of the relevant hierarchy later.)
7791 \end{notate}
7793 \begin{lisp}
7794 (defun article-menu-insert-new-article ()
7795 (interactive)
7796 (if currently-displayed-label
7797 (let ((new-entry (read-string "New entry: "))
7798 (old-entry (save-excursion
7799 (goto-char (line-beginning-position))
7800 (search-forward-regexp "[. >] ." nil t)
7801 (setq name-of-current-article
7802 (get-text-property (point) 'name)))))
7803 (setq new-scholium-name new-entry)
7804 (let ((line (line-number-at-pos)))
7805 (if old-entry
7806 (label-article-insert-before
7807 new-entry old-entry currently-displayed-label)
7808 (label-article new-entry currently-displayed-label))
7809 (display-label currently-displayed-label)
7810 (goto-line line))
7811 (make-scholium))
7812 (message "Listing doesn't represent a label.")))
7814 (define-key article-menu-map "i" 'article-menu-insert-new-article)
7815 \end{lisp}
7817 \begin{notate}{Committing edits to labels} \label{commit-label}
7818 So far, the editing steps we do with labels are automatically
7819 entered into the backend, so, at this point, we don't need a
7820 `commit-label'. If it turns out that we want one, then these
7821 routines will have to be rewritten somewhat, and `commit-edits'
7822 will have to have `commit-label' hooked into it.
7823 \end{notate}
7825 \subsection{Further notes on editing and deleting}
7827 \begin{notate}{Reparsing and propagating after editing} \label{reparsing-after-editing}
7828 Editing an article is one of the main reasons we'd ever need to do
7829 reparsing. When text moves around, scholia are likely to be attached
7830 to different regions. This means we need to change the \inp{about}
7831 elements of attached articles for the collection to stay coherent.
7832 Proper reparsing behavior is necessary for various functions to behave
7833 properly; see for example Note \ref{moving-with-reparsing}. We
7834 probably will want to add the appropriate reparsing function to the
7835 corresponding after-editing/before-saving-changes hook.
7836 \end{notate}
7838 \begin{notate}{Changing names}
7839 One simple ``edit'' would be changing the name of an article; doing
7840 this of course requires the new name to replace the old name in every
7841 reference to the article.
7842 \end{notate}
7844 \begin{notate}{Changes to an article affect attached articles}
7845 However, changes to the \emph{text} of a given article may affect any
7846 scholia that are \emph{about} that article. (To say nothing of how
7847 the semantic contents of the change might affect these attached
7848 scholia, the regions may be wrong.) One approach to take would be to
7849 attempt to propagate the changed buffer positions to all attached
7850 scholia. Of course, we can't necessarily assume that the owner of the
7851 attached scholia will accept these propagated changes.
7852 \end{notate}
7854 \begin{notate}{We shall adopt a versioned model} \label{we-adopt-a-versioned-model}
7855 These considerations suggest that we should go with the ``versioned''
7856 diachronic model. According to this model, changes can be propagated,
7857 but on a tentative basis. If another user doesn't accept your
7858 changes, they will still have a perfectly good scholium attached to a
7859 previous version of your article.
7860 \end{notate}
7862 \begin{notate}{Moving between versions}
7863 It would probably be handy to have this use existing browser code,
7864 e.g. from the local browsing section (Section \ref{local}).
7865 \end{notate}
7867 \begin{notate}{Different ownership models can do different things}
7868 When permissions aren't a concern, we can set the system up so that
7869 propagated changes are automatically accepted. In addition, we can
7870 set up versioning to resolve at different levels of detail depending
7871 on the application.
7872 \end{notate}
7874 \begin{notate}{Changes outside the system}
7875 One further consideration is the fact that articles may change outside
7876 of the scholium system (e.g. a file may be edited, a remotely-hosted
7877 web page may change, or a process may be killed). We assume that when
7878 a change like this is noticed, the scholium system will create a new
7879 version of the article \emph{automatically} and propagate appropriate
7880 changes to other documents.
7881 \end{notate}
7883 \begin{notate}{How to do automatic updates}
7884 Noticing changes to files is a bit of a challenge; not insurmountable,
7885 but it does mean that we'll need an internal representation of the
7886 file's contents (i.e. one that we assume is not subject to change in
7887 the same way that the file is!). As it stands, the system doesn't
7888 include this sort of version management apparatus. In order to mend
7889 things, whenever an article is created (or edited), a backup copy
7890 should be stored that can serve as a reference. At least, I guess
7891 this is how version management software works. Presumably it isn't
7892 hard to add this sort of feature, but before plunging ahead, I think
7893 it would be worth looking into the algorithms and protocols used by
7894 extant version management tools.
7895 \end{notate}
7897 \begin{notate}{When should auto-accept work?}
7898 Although auto-accept is a nice-sounding thing, it may be best to
7899 always have changes approved by a person, since changes to the text
7900 could completely change its meaning -- and threaten to make attached
7901 scholia ridiculous. Maybe auto-accept is most useful when \emph{one}
7902 person is editing the document, but even then, there may be times when
7903 content changes so much that the attached scholium would become
7904 ridiculous or meaningless. In this case, maybe auto-accept is good,
7905 but the user should be able to roll back propagated changes easily?
7907 Keeping track of the genesis of a given scholium is important. Maybe
7908 this procedural info will be marked up itself sometimes? Certainly
7909 there can be extra user-supplied info, outside of the bookkeeping
7910 info, that describes relationships between documents.
7911 \end{notate}
7913 \begin{notate}{Changes to metadata in a semantically programmed environment}
7914 We assume that changing \inp{type} and \inp{about} data also require
7915 changing the article version.
7916 \end{notate}
7918 \begin{notate}{Using bookkeeping information to track versions}
7919 As if it wasn't obvious, the \inp{bookkeeping} information will be used to
7920 keep track of different article versions. (Presumably including diffs
7921 between versions or what have you: it would be good to hook the GNU
7922 diff tools into this system. See also the comment about storing the
7923 ``current'' version of articles in full, to check against changes from
7924 the outside.)
7925 \end{notate}
7927 \section{Derivative works} \label{derivative}
7929 \subsection{Introduction to clusions} \label{intro-to-derivatives}
7931 \begin{notate}{Derivative works in the scholium system} \label{derivative-works-in-the-scholium-system}
7932 Section \ref{rendering} focuses on providing useful views \emph{into}
7933 the document. The matter of assembling \emph{new articles} which
7934 derive from other articles drawn from the document is essentially a
7935 separate problem; we will tackle this problem in this section. (Other
7936 sorts of derivative or derivative-like works, such as collections and
7937 indices are given their primary treatment elsewhere.)
7938 \end{notate}
7940 \begin{notate}{Different kinds of derivatives} \label{different-kinds-of-derivatives}
7941 \emph{Inclusion} is probably the most straightforward way to assemble
7942 an an article that derives from another article. Material from a
7943 certain version of the source article is simply inserted into the
7944 current article. Inclusion is treated in Section \ref{inclusion}.
7945 \emph{Transclusion} is similar to inclusion, except that instead of
7946 simply inserting source text as it is right now, transclusion causes
7947 the source to be tracked as it changes, and its most up-to-date
7948 version to appear automatically in the derivative work when it's
7949 rendered. Transclusion is treated in Section \ref{transclusion}.
7950 \emph{Identification} is like a two-way version of transclusion:
7951 instead of the source material being inherited by the derivative
7952 article, under identification, the source is shared between several
7953 articles. Thus, changes in one place will be mirror in each of the
7954 other places. This is developed in Section \ref{identification}.
7955 \end{notate}
7957 \begin{notate}{Clusions} \label{clusions}
7958 We refer to specific instructions specifying an inclusion,
7959 transclusion, or identification as a \emph{clusion}. (By analogy to
7960 the morphisms of category theory.) In this lingo, we could also refer
7961 to identification as \emph{biclusion}.
7963 Both identification and transclusion are represented as links inside
7964 the \inp{text} field of an article, and this property is definitional
7965 for clusions.
7967 Identification, on the other hand, is currently implemented as a live,
7968 one-time operation, and so it isn't strictly an example. However,
7969 once we have a proper versioning system working, it would be fairly
7970 easy to do inclusion as a proper clusion like the others (by making it
7971 point at a specific version of a document from which to draw text) --
7972 assuming that is what is desired. It may be that the user wants to
7973 simply quote from the other document, and doesn't want to do clusion
7974 maintenance. We'll have to give some thought to what way of operating
7975 is most desirable here.
7977 I haven't thought of any other major classes of clusions (at least,
7978 not yet), but just to point out that any clusion can be composed with
7979 straightforward text operations (e.g. reversing the characters in a
7980 cluded region) to obtain another clusion.
7982 Mainatining clusions is part of a broader problem of maintaining
7983 consistency conditions, see Section \ref{consistency}.
7984 \end{notate}
7986 \begin{notate}{Allowable sources} \label{allowable-sources}
7987 Compare Note \ref{types-of-text}, which talks about the different
7988 allowable kinds of \inp{text}, but note that, one should be able to
7989 clude things other than text. The set of objects that can be cluded
7990 is same as the set of objects that a scholium can be \inp{about},
7991 i.e., anything a link can point at.
7992 \end{notate}
7994 \begin{notate}{Derivatives and versioning}
7995 In order to get the relevant functions for building derivatives set up
7996 properly, we really should have version management in place.
7997 \end{notate}
7999 \begin{notate}{List processing as a prototypical example} \label{including-transcluding-and-lisp}
8000 The ``{\tt ,@}'' from LISP comes to mind when thinking about
8001 transcluding, whereas shared list structure is like identification.
8002 It would be interesting to spell the relationship out in detail.
8004 One further thought on the subject is that we may sometimes want to
8005 transclude symbols and s-exps of LISP code -- which brings the
8006 discussion full circle pretty quickly.
8007 \end{notate}
8009 \begin{notate}{Boundaryless formulations} \label{boundaryless-formulations}
8010 The simplest cases to deal with appear to be those in which no
8011 boundary is mentioned. For example, cluding the whole of some article
8012 $A$ into another article $B$. In practice, sometimes we can stick to
8013 a boundaryless treatment; other times, boundaries are unavoidable.
8014 \end{notate}
8016 \begin{notate}{Clusion algorithms}
8017 It would probably be good to put an overview of things like
8018 \ref{the-transclusion-algorithm} here, so that the subsequent
8019 discussion of markup makes sense. (We could talk about the easy
8020 work-around for building this document, and contrast it with the more
8021 intensive operations that go on in the *Compilation* buffer (cf. Note
8022 \ref{making-a-compilation}).
8023 \end{notate}
8025 \begin{notate}{Splitting text properties} \label{splitting-text-properties}
8026 Text inserted in the middle of a quotation does not derive from the
8027 same source as the quoted text. Therefore, it typically should not
8028 take on the `derives-from' markup of the surrounding text. For a
8029 discussion of inserting within a marked up region in general (i.e.,
8030 not just in the cases having to do with derivatives), see Note
8031 \ref{inserting-text-in-middle-of-marked-up-region}.
8032 \end{notate}
8034 \begin{notate}{Splitting clusions}
8035 Notice that edits in either the source or the recipient
8036 article can cause a clusion to split, as illustrated in
8037 Figure \ref{Two-ways-to-cause-clusions-to-split}.
8039 \begin{figure}
8040 \begin{center}
8041 \begin{tabular}{c}
8042 \begin{tabular}{ccc}
8043 $A$ &$\rightarrow$& $B$ \\
8044 \verb|xxabcd| & & \verb|yyabcd| \\
8045 \verb|efgxxx| & & \verb|efgyyy| \\
8046 \end{tabular} \\
8047 \ \\
8049 \hline \\
8051 \begin{tabular}{ccc}
8052 $A'$ &$\rightarrow(\times 2)$& $B'$ \\
8053 \verb|xxabcd| & & \verb|yyabcd| \\
8054 \verb|xxxefg| & & \verb|efgyyy| \\
8055 \end{tabular} \\
8057 \emph{or} \\
8058 \ \\
8059 \begin{tabular}{ccc}
8060 $A'$ &$\rightarrow(\times 2)$& $B'$ \\
8061 \verb|xxabcd| & & \verb|yyabcd| \\
8062 \verb|efgxxx| & & \verb|yyyefg| \\
8063 \end{tabular}
8064 \end{tabular}
8065 \end{center}
8066 \caption{Edits in either $A$ or $B$ can cause a clusion to split
8067 \label{Two-ways-to-cause-clusions-to-split}}
8068 \end{figure}
8069 \end{notate}
8071 \begin{notate}{Masking clusions} \label{masking-clusions}
8072 We want to mask clusions in much the same way we mask links (Note
8073 \ref{masking-links}). Indeed, clusions \emph{are} essentially links,
8074 by definition (Note \ref{clusions}).
8075 \end{notate}
8077 \begin{notate}{Format of text with derivatives} \label{format-of-text-with-derivatives}
8078 The format of the \inp{text} field for articles with derivatives is as
8079 follows:
8080 \begin{idea}
8081 (twd <string | clusion> ...)
8082 \end{idea}
8083 Each clusion is a link with the corresponding instruction consed
8084 onto the front of it (cf. Note \ref{links}). The three instructions
8085 are `transclude', `identify', and `include'.
8087 For example,
8088 \begin{idea}
8089 (twd "This Note can be used as part of an example.\n"
8090 (transclude "Format of text with derivatives"))
8091 \end{idea}
8093 \begin{idea}
8094 (twd "Part of this Note can be used as part of an example.\n"
8095 (transclude "Format of text with derivatives"
8096 (passage 1 25)))
8097 \end{idea}
8099 There is a small break in transparency here; presumably this won't be
8100 a problem (Note \ref{principle-of-transparency}).
8101 \end{notate}
8103 \begin{notate}{Transclusion and freedom} \label{transclusion-and-freedom}
8104 The right to make and circulate \emph{derivative works} is important
8105 (i.e., when it is allowed!). One easy sort of derivative is a
8106 compilation of all of the sub-objects that have a given property. For
8107 example, one could put together a collection of all the first
8108 paragraphs drawn from the various sections of an article, or all the
8109 paragraphs that have been marked as ``needs revision'', or
8110 ``theoretically interesting'', etc. Transclusion makes it easy to
8111 build simple, useful, derivatives of this sort, and keep them up to
8112 date as the master document changes. (Sometimes one would want to use
8113 somewhat special instructions, e.g. in order to collect only the
8114 \emph{new} items matching an otherwise-global search criterion.)
8115 \end{notate}
8117 \begin{notate}{The dependence of the various derivatives on `commit-edits'} \label{derivatives-and-committing}
8118 I think we may have to do a commit after running `transclude-article',
8119 since it involves changing the \inp{text} field. By contrast, running
8120 `include-article' causes new scholia to be stored automatically, but
8121 we left committing the text field to the user. So, I'm not sure; if
8122 there is a way to do transclusion without requiring a commit
8123 automatically, that might be kind of nice.
8125 Note also that each of the different derivative styles will have
8126 things to look for whenever they commit \emph{again}. (E.g. articles
8127 with inclusions should be inspected to see if perhaps all of the
8128 included text has been deleted.)
8129 \end{notate}
8131 \begin{notate}{Derivatives outside of the scholium system}
8132 We leave it up to the user to write a suitable function for quoting
8133 text from scholium system objects to non-scholium system objects (if
8134 the user has any of these!).
8135 \end{notate}
8137 \begin{notate}{Technical difficulties with text properties} \label{difficulties-with-text-properties}
8138 The fundamental difficulty with text properties seems to be that using
8139 them comes at a non-trivial cost. So we don't use them for everything
8140 (cf. Note \ref{alternative-to-identification}).
8142 When doing transclusion, rather than using a uniform text property, we
8143 need a text property that gives a unique ID to each character within
8144 the marked up region (Figure
8145 \ref{Rearrangement-not-detected-using-uniform-text-properties}, Note
8146 \ref{transclusion-markup-design}).
8148 I've been assuming that \emph{typical} text properties designating the
8149 association of a region with a scholium will be ``sticky'' -- if
8150 someone adds to a marked-up region, the added text will bear the new
8151 markup. At some point, we might have a non-sticky option. However,
8152 the text properties associated with transclusions should always be
8153 non-sticky, since text added in the middle of a quoted passage needs
8154 to be treated as an ``island'' in the middle of the transclusion
8155 (which actually gets split in two).
8157 The problem arises in the fact that Emacs makes it hard and/or ugly to
8158 use an individual text property for each transclusion (see Note
8159 \ref{many-scholium-properties}). The relevant experiment took place
8160 in CVS versions 41 through 43; version 44 was then identical to
8161 version 41.
8163 The point is, that I've been maintaining all of the data about scholia
8164 on precisely one text property, which of course takes on different
8165 values as needed. However, the ``stickiness'' of each text property
8166 is controlled individually, and I can't continue to use this trick.
8168 I could, I suppose, use one sticky and one non-sticky text property,
8169 but I think that there may be a better approach involving some work on
8170 the text property system itself. This will need some more
8171 investigation.
8172 \end{notate}
8174 \begin{notate}{Treating clusions} \label{treating-clusions}
8175 The following subsections provide commands for \emph{building clusions
8176 interactively}, and for \emph{rendering them properly}.
8177 \end{notate}
8179 \subsection{Transclusion} \label{transclusion}
8181 \begin{notate}{On `transclude-article'} \label{transclude-article}
8182 First we check to see whether the article contains
8183 transclusions already, and if not, we put the text field
8184 into the format used for text with transclusions
8185 (see Note \ref{format-of-text-with-derivatives}).
8187 Next, we divide the text of the article in two; everything prior to
8188 point, and everything after point. (We have to divide the
8189 \emph{rendered} text, fairly clearly; since there might be more than
8190 one different rendering, we hope that the different possible divisions
8191 are consistent, or at least that we know how to do all of the
8192 divisions.)
8194 Of course, we also need to be able to specify the objects that are to
8195 be transcluded!
8196 \end{notate}
8198 \begin{lisp}
8199 ;; totally not working yet!
8200 (defun transclude-article (article)
8201 (interactive (list (read-article-name)))
8202 (let ((current (get-article name-of-current-article))
8203 newtext)
8204 ;; it really doesn't make sense to use something like this here --
8205 ;; we only deal with the internal format at commit time.
8206 (unless (and (listp current)
8207 (eq (car current) 'twd))
8208 (setq newtext `(twd
8209 ,(scholium-text current))))
8210 (let ((beg (point)))
8211 (insert (sch-plain-text (get-article article)))
8212 ;; this condition isn't really strong enough
8213 (when name-of-current-article
8214 (scholium
8215 `(derives-from ,name-of-current-article ,article ,(genref))
8217 `((passage (,name-of-current-article
8218 ,beg
8219 ,(point))))
8220 'derives-from
8221 'system)))))
8222 \end{lisp}
8224 \begin{notate}{Transclusion markup design} \label{transclusion-markup-design}
8225 The idea is that when some object $T$ is transcluded into the current
8226 buffer, $\mathrm{im}(T)$ is marked up in the following way. Character
8227 $i$ in this image is given a text property that says ``This is
8228 character $i$ of $n$ contiguous characters that have been transcluded
8229 from the object $T$.'' Then, when parsing, if these text properties
8230 show up in new places (e.g. non-contiguously) or if some of the
8231 numbers fail to show up at all, we'll know to initiate new
8232 transclusions or to change the definition of the current one being
8233 scanned.
8235 The reason for doing things this way is similar to the issue discussed
8236 in the ``Not Intervals'' node of the Elisp manual\footnote{(info
8237 "(elisp)Not Intervals")}. If the image of a transclusion was simply
8238 marked up with a property that said ``This is the image of the object
8239 $T$ under transclusion,'' then elements of the region that bears this
8240 text property could be rearranged without anything registering at the
8241 system level (Figure
8242 \ref{Rearrangement-not-detected-using-uniform-text-properties}). This
8243 would pretty much be a disaster.
8245 The idea here is that \emph{we should be able to edit texts coming
8246 from transclusion} and continue to have the transclusion basically
8247 work. In Note \ref{splitting-text-properties}, we decided that text
8248 inserted into a quotation should not take on the ``derives-from''
8249 property that the surrounding text bears. Thus, if a transcluded
8250 region is broken up, or pieces of it are deleted, we assume that new
8251 transclusions are being requested by the user.
8253 These remarks apply to the representation of transclusions in rendered
8254 documents; the internal representation is discussed in Note
8255 \ref{format-of-text-with-derivatives}.
8257 \begin{figure}
8258 \begin{center}
8259 \begin{tabular}{ccc}
8260 \verb|-----#| & & \verb|-----#| \\
8261 \verb|----##| & & \verb|-#--##| \\
8262 \verb|---###| &$\rightarrow$& \verb|---###| \\
8263 \verb|--####| & & \verb|--##-#| \\
8264 \verb|-#####| & & \verb|-#####|
8265 \end{tabular}
8266 \end{center}
8267 \caption{Rearrangement isn't detected using uniform text properties
8268 \label{Rearrangement-not-detected-using-uniform-text-properties}}
8269 \end{figure}
8270 \end{notate}
8272 \begin{notate}{Changing boundaries in source documents} \label{changing-boundaries-in-source-documents}
8273 In Note \ref{transclusion-markup-design}, we talked about adapting
8274 transclusion boundaries to changes in the derivative document.
8275 However, it should be noted that boundaries may shift in source
8276 documents as well: if the object being transcluded is ``the region
8277 between character position 10 and character position 250 from article
8278 $A$'' and a lengthy header is inserted, the idea behind the
8279 transclusion may be completely swept away. The way to be safest here
8280 is to specify objects without referring to their boundaries, e.g.
8281 ``Article $A$'' should be safe.
8283 \emph{There may be a way of maintaining the boundaries recorded on the
8284 transclusions themselves in such a way that edits to the source
8285 article are reflected in updated information in the transclusion;
8286 i.e., if text is inserted into the region that is being transcluded,
8287 the boundaries could grow, for example. But doing this seems tricky
8288 (at least modestly tricker than maintaining backlinks, for example),
8289 and I think I will hold off on doing anything like this until I get
8290 some clue that it is actually feasible to do it right.}
8291 \end{notate}
8293 \begin{notate}{The transclusion algorithm} \label{the-transclusion-algorithm}
8294 (1) The first thing is to run a function to select an object
8295 to transclude.
8297 (2) Then we render it to plain text and insert that text in the
8298 current article. Appropriate text properties indicating that it is a
8299 transclusion are added next. (If instead of adding a new
8300 transclusion, we simply wish to render an article that includes
8301 transclusions, we must render each transcluded item in this way.)
8303 (3) We let the user go wild.
8305 (4) If things have changed at commit time, we need to put new
8306 transclusion instructions together. This new information replaces the
8307 old. And, in any event, the rendered transclusions are converted to
8308 an internal format for storage (Note \ref{format-of-text-with-derivatives}).
8309 \end{notate}
8311 \begin{notate}{Simple selection makes for expediency} \label{simple-selection-for-transclusion}
8312 In light of the comments in Note
8313 \ref{changing-boundaries-in-source-documents}, for the time being we
8314 choose the simple method of only allowing the transclusion of whole
8315 articles. There don't appear to be any major theoretical obstructions
8316 to the transclusion of passages, but let's start with something that
8317 will clearly be manageable. (See Note
8318 \ref{principle-of-minimality}.)
8319 \end{notate}
8321 \begin{notate}{Derivative predicates for transclusions}
8322 Some sort of `derives-from' predicate may have to be maintained for
8323 transclusions, although here such a `derives-from' predicate might be
8324 deduced from the transclusion \inp{text} directly. (This is similar
8325 the approach we took with inclusions.)
8326 \end{notate}
8328 \subsection{Inclusion} \label{inclusion}
8330 \begin{notate}{On `include-article'} \label{include-article}
8331 It is simple enough to find an article and insert its text at point
8332 (compare `insert-buffer').
8334 %% We then need to add `derives-from' and `derives-to' properties (note
8335 %% similarity to backlinking; indeed, we reuse `put-backlinks', relying
8336 %% on the general way in which it was written; see Note
8337 %% \ref{put-backlinks}).
8338 \end{notate}
8340 \begin{lisp}
8341 (defun include-article (article)
8342 (interactive (list (read-article-name)))
8343 (let ((beg (point)))
8344 (insert (sch-plain-text (get-article article)))
8345 ;; this condition isn't really strong enough
8346 (when name-of-current-article
8347 (scholium
8348 `(derives-from ,name-of-current-article ,article ,(genref))
8350 `((passage (,name-of-current-article
8351 ,beg
8352 ,(point))))
8353 'derives-from
8354 'system))))
8355 \end{lisp}
8357 \begin{notate}{By default, don't print `derives-from' scholia}
8358 Typically we don't need to see `derives-from' scholia, although it
8359 could be handy to write a special display mode in which these scholia
8360 are printed (and probably special semantics for how they are
8361 displayed).
8362 \end{notate}
8364 \begin{lisp}
8365 (add-to-list 'non-printing-types 'derives-from)
8366 \end{lisp}
8368 \begin{notate}{Deleting `derives-from' properties}
8369 If upon reparsing, if no sections are actually marked up with a
8370 `derives-from' property that was previously recorded, it can be
8371 assumed that the text that was quoted from that particular source
8372 article has been deleted. In which case, odds are that the
8373 formerly-derivative document doesn't derive from that source any
8374 longer.
8375 \end{notate}
8377 \begin{notate}{Add `include-article-formatting-minimally'}
8378 It might be helpful to have a function that would do everything
8379 that the previous version does, but without marking the text up,
8380 or perhaps just running it through `format'. But I'm going
8381 to hold off on this until the use cases seem clearer to me.
8382 \end{notate}
8384 \begin{notate}{Record version number of included article}
8385 Since inclusions are static, we should probably make note of the
8386 specific version of the source article that the recipient derives
8387 from.
8388 \end{notate}
8390 \begin{notate}{Including passages}
8391 It might be useful to support optional ``beg'' and ``end'' arguments
8392 that would make it possible to quote only a substring of the
8393 \inp{article} that is being included. This seems most likely to be
8394 useful in a setting in which we select the passage to include
8395 interactively. (Cf. Note \ref{simple-selection-for-transclusion}.)
8396 \end{notate}
8398 \subsection{Identification} \label{identification}
8400 \begin{notate}{Identification from a design perspective}
8401 Basically, identification is ``like transclusion for editing'': we
8402 have direct write access to the original, as well as read access.
8403 Identification is more powerful than transclusion; and, obviously, one
8404 can only objects that one has permission to modify can be edited
8405 through identification.
8407 Unlike inclusion and transclusion, identified copies should be marked
8408 up with uniform, sticky, text properties. (The user
8409 should be careful that text from the current buffer that wasn't
8410 intended to be part of the identified copy doesn't get stuck
8411 to the identification by mistake!)
8412 \end{notate}
8414 \begin{notate}{The identification algorithm} \label{the-identification-algorithm}
8415 The object that we're identifying with should be inserted and marked
8416 up with an `identifies-with' text property at render time. Any
8417 markup of this text (e.g. processing of transclusions or
8418 identifications within the text) should be carried out just as if
8419 the source was being edited directly. At commit time, text bearing
8420 the `identifies-with' property should be compared with the object
8421 it derives from. If it has been changed, a new version of that
8422 object should be committed. As for the derivative article, an
8423 internal representation similar to the one described in Note
8424 \ref{format-of-text-with-derivatives} should be stored.
8425 \end{notate}
8427 \begin{notate}{Precedent for identification} \label{precedent-for-identification}
8428 The emacs package ``all.el'' is abstractly
8429 similar\footnote{{\tt http://ftp.gnu.org/savannah/files/auctex/attic/auctex/all.el}}, as
8430 is the idea of shared list structure (Note
8431 \ref{including-transcluding-and-lisp}).
8432 \end{notate}
8434 \begin{notate}{Identification use case} \label{identification-use-case}
8435 Just for instance, one could use this style of transclusion to render
8436 two articles into the same buffer and cut and paste portions of each
8437 into the other, and have the changes mapped back appropriately.
8438 \end{notate}
8440 \begin{notate}{On `insert-identification-at-point'} \label{insert-identification-at-point}
8441 This is similar to Note \ref{include-article}. For now,
8442 I'm just going to write it so that you can do identification
8443 with other articles; later, more general objects will be allowed
8444 (Note \ref{allowable-sources}).
8446 We don't actually need to create any scholia,
8447 but we can use the scholia property. It should
8448 be exactly the same when we render articles that already had
8449 identifications recorded internally.
8450 \end{notate}
8452 \begin{lisp}
8453 (defun insert-identification-at-point (article-name)
8454 (interactive (list (read-article-name)))
8455 (let ((beg (point)))
8456 (insert (sch-plain-text article-name))
8457 (add-to-scholia-property-within-region
8459 (point)
8460 ;; there aren't any links, so there's no proper linkid
8461 `(identifies-with ,article-name))))
8462 \end{lisp}
8464 \begin{notate}{On `propagate-changes-to-identification-source'}
8465 This runs within the context of
8466 `store-updates-from-identification-images' (when it runs).
8467 Its purpose is to copy changes from the recipient article
8468 in an identification to the source article.
8469 \end{notate}
8471 \begin{lisp}
8472 (defun propagate-changes-to-identification-source ()
8473 (when (not (equal (buffer-substring-no-properties
8474 (second (car identifications))
8475 (third (car identifications)))
8476 (sch-plain-text
8477 (second (caar identifications)))))
8478 (let ((source (get-article (second (caar identifications)))))
8479 ;; compare `commit-edits'. When we actually do
8480 ;; document versions, this should update the version
8481 ;; number and any other metadata about how this
8482 ;; version was created that we get interested in.
8483 (scholium (second (caar identifications))
8484 ;; this is bad, since it is storing
8485 ;; the rendered text, whereas we should of course
8486 ;; be storing the formatted-for-internal-storage
8487 ;; text. But I suppose this is OK for testing
8488 ;; purposes (wherein we'll only have one level
8489 ;; of identification).
8490 (buffer-substring-no-properties
8491 (second (car identifications))
8492 (third (car identifications)))
8493 (scholium-about old-contents)
8494 (scholium-type old-contents)
8495 (scholium-bookkeeping old-contents)))))
8496 \end{lisp}
8498 \begin{notate}{On `store-updates-from-identification-images'}
8499 This function will run within the scope of `commit-edits' via the
8500 `commit-edits-hook' (see Note \ref{commit-edits-hook}).
8501 We must first identify the identifications (as it were), which we
8502 do by examining the contents of the `adjusted-markup' list.
8503 Then, once these are found, we form a suitable internal
8504 representation.
8506 Everything \emph{between} identifications should get stored
8507 as plain text, whereas the identifications themselves should
8508 be stored as tags.
8510 In addition to adjusting the internal representation of
8511 the article with the identification commands, we should
8512 adjust the text of the source articles, if necessary.
8513 (For simplicity's sake, we could just store updated text
8514 unconditionally for now.)
8516 Concerning the use of `buffer-substring-no-properties':
8517 zapping the properties is questionable, if
8518 we're planning to commit these various derivative
8519 properties serially. Will have to think about this later.
8520 I think that since this thing is being used to build
8521 internal representations, zapping text properties
8522 might actually be OK. But I'm not sure.
8524 For clarification on the use of `adjusted-text', see comments on
8525 `commit-edits'.
8527 Note that the only relevant option besides ``less'' is ``equal''
8528 in the `if' here.
8529 \end{notate}
8531 \begin{lisp}
8532 (defun store-updates-from-identification-images ()
8533 (let ((identifications (remove-if
8534 (lambda (elt)
8535 (not (eq (caar elt) 'identifies-with)))
8536 adjusted-markup))
8537 (pt 1)
8538 formatted-contents)
8539 (while identifications
8540 (if (< pt (second (car identifications)))
8541 (setq formatted-contents
8542 (append
8543 formatted-contents
8544 (list (buffer-substring-no-properties
8545 pt (second (car identifications)))
8546 `(ident ,(second (caar identifications)))))
8547 pt (third (car identifications)))
8548 (setq formatted-contents
8549 (append
8550 formatted-contents
8551 (list `(ident ,(second (caar identifications)))))
8552 pt (third (car identifications))))
8553 ; (propagate-changes-to-identification-source)
8554 (setq identifications (cdr identifications)))
8555 (when formatted-contents
8556 (when (< pt (point-max))
8557 (setq formatted-contents
8558 (append
8559 formatted-contents
8560 (list (buffer-substring-no-properties
8561 pt (point-max))))))
8562 (setq adjusted-text (list 'twd formatted-contents)))))
8564 (add-hook 'commit-edits-hook 'store-updates-from-identification-images)
8565 \end{lisp}
8567 \begin{notate}{Working identifications into the rendering pathway}
8568 We'll need to modify rendering to look at the ``ident'' objects
8569 in the document's representation, and mark these up as identifications.
8571 The way identifications and transclusions are expanded will be
8572 similar. (See section \ref{rendering-derivatives} for more on this.)
8573 \end{notate}
8575 \begin{notate}{Visible identification markup}
8576 It would be handy to optionally have overlays showing which regions
8577 are marked up as identifications, and also to have scholia that say
8578 what they are identified to. (This seems like a good example of a
8579 situation in which it would be be best if the scholia only showed up
8580 when the regions they applied to appeared onscreen.)
8581 \end{notate}
8583 \begin{notate}{Cutting and pasting identifications in multi-user environment}
8584 One should be careful that passages that have been marked up as
8585 identifications, which are copied and pasted into other articles which
8586 don't have the same permission-set associated with them, are no longer
8587 treated as identifications. Perhaps some identifying information
8588 (`name-of-current-article' being a likely candidate) can be added to
8589 the text property added by `insert-identification-at-point', and some
8590 additional checks put into the commit phase.
8591 \end{notate}
8593 \subsection{Rendering articles containing derivative portions} \label{rendering-derivatives}
8595 \begin{notate}{Cluded parts} \label{cluded-parts}
8596 These variables will be modified by `unwind-derivatives' to contain a
8597 list of the transcluded sections of a rendered document.
8598 Specifically, the items on the list are of the form
8599 \begin{idea}
8600 (<object> <beg> <end>)
8601 \end{idea}
8602 where `object' is a link to the thing being transcluded,
8603 and `beg' and `end' represent the beginning and end positions
8604 of the image of the object under this particular clusion, in
8605 the rendered version of the cluding article.
8607 This information will subsequently be used as part of the markup
8608 routine, where it will allow us to add appropriate text properties
8609 indicating cluded regions.
8611 (It may be advantageous to assume that we can always use a
8612 \emph{cached} version of the article we're cluding. This could be a
8613 help when the article itself is derivative.)
8614 \end{notate}
8616 \begin{lisp}
8617 (defvar transcluded-parts nil)
8618 (defvar identified-parts nil)
8619 (defvar included-parts nil)
8620 \end{lisp}
8622 \begin{notate}{On `unwind-derivatives'} \label{unwind-derivatives}
8623 This will run within the scope of `sch-plain-text', and make recursive
8624 calls to `sch-plain-text' as needed, to turn cluded texts into strings
8625 suitable for display. Specifically, a simple test has been added to
8626 `sch-plain-text-hook' that causes `unwind-derivatives' to run whenever
8627 rendering an article whose \inp{text} field is a list that begins with
8628 the token `twd' (see Note
8629 \ref{adding-unwind-derivatives-to-rendering-pathway}).
8631 The boundaries of the cluded regions are recorded for subsequent
8632 use, as described in Note \ref{cluded-parts}.
8634 The contents of the `` *Unwinding Derivatives*'' buffer needs to be
8635 cleared out before this function first runs for it to return the
8636 correct string. (Um, is this all going to work out properly if we
8637 enter into the fully recursive run of `unwind-derivatives'?) That is
8638 accomplished by modifications to `scholia-display-pre-update-hook';
8639 see Note \ref{prep-for-rendering-text-with-derivatives}.
8641 The need for (extensive) recursion in this function could be done away
8642 with if we cached a \emph{rendered} version of every article that used
8643 clusions somewhere where it could be found by other articles that
8644 clude from it.
8646 However, if we are going to have things like references from cluded
8647 documents appear in the assembled document, or (in general) if we want
8648 to have access to the scholia attached to the cluded regions (Note
8649 \ref{fancy-derivatives}), we'll either have to pre-render the
8650 derivative components, or come up with some scheme for mapping the
8651 positions of markup associated with these things into suitable
8652 positions in the assembled document.
8654 Note that at present markup will be added by
8655 `add-inclusion-and-transclusion-markup' (Note
8656 \ref{add-inclusion-and-transclusion-markup}).
8657 \end{notate}
8659 \begin{lisp}
8660 (defun unwind-derivatives ()
8661 (set-buffer (get-buffer-create " *Unwinding Derivatives*"))
8662 (dolist (elt (cdr text))
8663 (if (stringp elt)
8664 (insert elt)
8665 (let (object)
8666 (cond
8667 ((eq (car elt) 'transclude)
8668 (setq object (cdr elt))
8669 (setq transcluded-parts (cons `(,object ,(point))
8670 transcluded-parts)))
8671 ((eq (car elt) 'identify)
8672 (setq object (cdr elt))
8673 (setq identified-parts (cons `(,object ,(point))
8674 identified-parts)))
8676 (setq object elt)))
8677 (insert (sch-plain-text object))
8678 (cond
8679 ((eq (car elt) 'transclude)
8680 (setcdr (cdar transcluded-parts) `(,(point))))
8681 ((eq (car elt) 'ident)
8682 (setcdr (cdar identified-parts) `(,(point))))))))
8683 (setq ret (buffer-string)))
8684 \end{lisp}
8686 \begin{notate}{Preparation for rendering text with derivative components} \label{prep-for-rendering-text-with-derivatives}
8687 We need to zap `transcluded-parts', `identified-parts' and the
8688 contents of the buffer in which derivatives are to be unwound before
8689 `unwinding-derivatives' runs.
8690 \end{notate}
8692 \begin{lisp}
8693 (defun prep-for-rendering-text-with-derivative-components ()
8694 (setq transcluded-parts nil
8695 identified-parts nil
8696 included-parts nil)
8697 (save-excursion
8698 (set-buffer (get-buffer-create
8699 " *Unwinding Derivatives*"))
8700 (erase-buffer)))
8702 (add-hook 'scholia-display-pre-update-hook
8703 'prep-for-rendering-text-with-derivative-components)
8704 \end{lisp}
8706 \begin{notate}{Adding `unwind-derivatives' to the rendering pathway} \label{adding-unwind-derivatives-to-rendering-pathway}
8707 We make a call to `unwind-derivatives' in `sch-plain-text' when the
8708 appropriate criterion is satisifed (see Note
8709 \ref{sch-plain-text-hook}). The relevant criterion is that we are
8710 rendering an object (i.e., something that gives us an article) whose
8711 \inp{text} field is a list that begins with the token `twd'.
8713 (The complex wording here has to do with the matter that we sometimes
8714 render objects that aren't articles, e.g. a link to a certain passage.
8715 We will have to make sure that the criterion used here is correct for
8716 those cases as well as the easy case of rendering a whole article.
8717 See Note \ref{sch-plain-text} for details.)
8718 \end{notate}
8720 \begin{lisp}
8721 (add-hook 'sch-plain-text-hook
8722 '(lambda ()
8723 (when (and (listp text) (eq (car text) 'twd))
8724 (unwind-derivatives))))
8725 \end{lisp}
8727 \begin{notate}{On `add-inclusion-and-transclusion-markup'} \label{add-inclusion-and-transclusion-markup}
8728 For identifications, this should add the same sort of faked-up markup
8729 that we added with `insert-identification-at-point' (Note
8730 \ref{insert-identification-at-point}).
8732 It might be kind of cute to put some ``corners'' in, showing
8733 where the included text begins and ends (see Note \ref{monochrome}).
8735 These modifications to `mark-things-up' appear to be desired
8736 unconditionally (unlike e.g. the modifications to `sch-plain-text' we
8737 just saw in Note
8738 \ref{adding-unwind-derivatives-to-rendering-pathway}). So we just put
8739 `add-inclusion-and-transclusion-markup' directly on the
8740 `mark-things-up-hook' (cf. Note \ref{mark-things-up-hook}).
8741 \end{notate}
8743 \begin{lisp}
8744 (defun add-inclusion-and-transclusion-markup ()
8745 (save-excursion
8746 (set-buffer-to-rendering-target-buffer)
8747 (dolist (elt identified-parts)
8748 (add-to-scholia-property-within-region
8749 (second elt)
8750 (third elt)
8751 `(identifies-with ,(first elt))))
8752 ;; this may end up having to be considerably more complicated
8753 (dolist (elt transcluded-parts)
8754 (add-to-scholia-property-within-region
8755 (second elt)
8756 (third elt)
8757 `(transclusion-of ,(first elt))))))
8759 (add-hook 'mark-things-up-hook 'add-inclusion-and-transclusion-markup)
8760 \end{lisp}
8762 \begin{notate}{Should identifications be unwound recursively?}
8763 I think they won't need to be; if someone asks to identify a region
8764 with some other region that also contains identification, then you
8765 might expect that we'd need to follow through to identify the
8766 indicated portion of the new article with that other earlier source.
8767 That's probably the right way to do things; however, I suppose we
8768 could do something simpler in the mean time, since if we don't write
8769 documents that depend on documents with identifications in them, the
8770 case we've been discussing won't come up! Besides, it would probably
8771 be instructive to have on hand a non-recursive function that does a
8772 similar job to the function written for transclusions.
8774 (Note that labels can sometimes be used to limit complexity of certain
8775 operations, see Note \ref{cost-of-maintaining-labels}.
8776 \end{notate}
8778 \subsection{Expanded and collapsed views} \label{expanded-and-collapsed}
8780 \begin{notate}{Expanded and collapsed views of derivative articles}
8781 There should probably be at least two different views into an article
8782 that makes use of any of the derivative-making tools we've discussed
8783 in this section: one that shows all of the rendered text, and another
8784 which just shows \emph{tokens} standing in for the rendered text. See
8785 Note \ref{transcluding-and-outlines}, as well as Note
8786 \ref{rendered-and-source-views}. Collapsed views are essentially
8787 ``graphical'' representations of formats like the one listed in
8788 Note \ref{format-of-text-with-derivatives}. In order to make these views
8789 available to the user, we'll want to provide `expand-derivatives'
8790 and `collapse-derivatives' commands, as well as, probably, individual
8791 commands for individual derivative items and each of the three
8792 derivative types.
8793 \end{notate}
8795 \begin{notate}{View is initially expanded}
8796 New derivative pieces are inserted in their expanded
8797 form (see, e.g., Note \ref{insert-identification-at-point}).
8798 \end{notate}
8800 \begin{notate}{Collapsing and expanding individual derivative items}
8801 We could set things up to render everything as collapsed or
8802 expanded all at once, but another option is to have a function
8803 that collapses or expands individual items.
8804 \end{notate}
8806 \begin{notate}{Identification through nontrivial maps} \label{identification-through-nontrivial-maps}
8807 In some cases it would be useful to have identifications
8808 go through non-trivial maps, for example, to transform
8809 a rendered piece of \LaTeX\ text into the standard source
8810 form. In addition, it might be nice to store metadata about
8811 Notes in some other place than the note's immediate neighborhood.
8812 \end{notate}
8814 \begin{notate}{Alternative to identification for simple literate programming applications} \label{alternative-to-identification}
8815 It may also be the case that we don't really need to do
8816 identifications to get the ability to import and export
8817 code from the scholium system. As long as everything
8818 is appearing in Notes, we should be able to edit things
8819 in an outline fashion and then export that to the \LaTeX\
8820 document.
8821 \end{notate}
8823 \subsection{Quick compilations and other listing tricks} \label{quick-compilations}
8825 \begin{notate}{Uses for compilations}
8826 What is presented in this section likely to just be a stop-gap measure
8827 until more general and powerful mechanisms for managing derivatives
8828 are available. But nevertheless, the basic ideas seem useful. For
8829 example, when viewing a certain article that is a member of a certain
8830 label, it might be handy to view everything in the label all at once
8831 in a compilation. And so on and so forth for various compiled views
8832 into a document.
8833 \end{notate}
8835 \begin{notate}{On `find-names-in-listing'}
8836 This can be used to find the names of listed articles.
8837 \end{notate}
8839 \begin{lisp}
8840 (defun find-names-in-listing (just-marked)
8841 (let ((names (list t)))
8842 (save-excursion
8843 (set-buffer (get-buffer-create "*Generic List*"))
8844 (goto-char (point-min))
8845 (while (and (not (eobp))
8846 (if just-marked
8847 (search-forward-regexp "^>" nil t)
8849 (let* ((next-change (next-single-property-change
8850 (point) 'name))
8851 (prop (when next-change
8852 (get-text-property next-change 'name))))
8853 (if (not next-change)
8854 (goto-char (point-max))
8855 (goto-char next-change)
8856 (when prop
8857 (nconc names (list prop)))))))
8858 (cdr names)))
8859 \end{lisp}
8861 \begin{notate}{Making a compilation from a listing of articles} \label{making-a-compilation}
8862 In Note \ref{bits-and-pieces}, we talk about making all the articles
8863 that match a given criterion into a new article. A quick way to
8864 get this functionality to the user is to turn an article listing
8865 into a compilation.
8867 The version here is very preliminary; eventually we'll be putting in
8868 identifications or something like that to make the various pieces of
8869 the compilation ``hot''.
8871 It be nice to have various display options, either features that
8872 screen certain kinds of content in or out at render time
8873 (e.g. printing of attached code snippets could be optionally be made
8874 automatic), or that add actionable features to the display (e.g. to
8875 enable the user to expand and collapse cluded articles, or to select from a cluded label).
8877 We present a couple of variants here.
8878 \end{notate}
8880 \begin{lisp}
8881 (defun listing-to-compilation (just-marked-items)
8882 (interactive "P")
8883 (let ((names (find-names-in-listing just-marked-items)))
8884 (pop-to-buffer (get-buffer-create "*Compilation*"))
8885 (erase-buffer)
8886 (dolist (name names)
8887 (let ((article (get-article name)))
8888 (insert (upcase
8889 (propertize (format "%s" (scholium-name article))
8890 'face 'italic))
8891 "\n"
8892 (format "%s" (scholium-text article))
8893 "\n")))
8894 (goto-char (point-min))))
8896 (defun listing-to-compilation-1 (just-marked-items)
8897 (interactive "P")
8898 (let ((names (find-names-in-listing just-marked-items)))
8899 (pop-to-buffer (get-buffer-create "*Compilation*"))
8900 (erase-buffer)
8901 (dolist (name names)
8902 (let ((article (get-article name)))
8903 (insert "\\begin{notate}{"
8904 (propertize (format "%s" (scholium-name article))
8905 'face 'italic)
8907 "\n"
8908 (format "%s" (scholium-text article))
8909 "\\end{notate}"
8910 "\n\n")
8911 (dolist (scholium (mapcar (lambda (backlink)
8912 (get-article (car backlink)))
8913 (get-backlinks name)))
8914 (when (typedata-includes (scholium-type scholium) 'code)
8915 (insert "\\b" "egin{lisp}\n"
8916 (scholium-text scholium)
8917 "\\e" "nd{lisp}\n\n")))))
8918 (goto-char (point-min))))
8919 \end{lisp}
8921 \begin{notate}{Finding code continuations with backlinks} \label{finding-code-continuations}
8922 Establishing the existence of attached code snippets in
8923 `listing-to-compilation-1' (Note \ref{making-a-compilation}) is
8924 currently done in a way that doesn't take full advantage of the
8925 backlink-to-link correspondence we've put together. This sort of
8926 thing was one reason I thought we might want to use typed backlinks;
8927 but eventually I decided that simply putting backlinks in direct
8928 correspondence with links would be enough, see Note
8929 \ref{implementation-of-backlinks}.
8930 \end{notate}
8932 \begin{notate}{Additional compilation tricks}
8933 Code snippets aren't the only ``bonus features'' we might like to have
8934 appear in a compilation (cf. Note \ref{making-a-compilation}); for
8935 example, we might want to make an article appear together with the
8936 articles that immediately precede and follow it in some linear order.
8937 (This makes the compilation a bit more like browsing a printed
8938 document.)
8940 It would also be handy to have an option for exporting a fully
8941 \LaTeX -ready version of a compilation (compare Note
8942 \ref{selectively-populate-existing-outline}).
8944 Another fun trick that would be fairly cute, when this is all working
8945 quite a bit better, would be to have links that run internally within
8946 the compilation show up in a different color from links that point
8947 outside of the compilation. (We'll want to develop some code for
8948 making the display jump to just the right point when following an
8949 internal link, or any link that points to a specific portion of a
8950 given article.) One might want to view one of these intra-linked
8951 articles in place in the compilation, or perhaps instead on its own,
8952 using the normal single-article display.
8954 The sequence of things displayed in the compilation buffer is the sort
8955 of thing that might benefit from having its own history list; see Note
8956 \ref{thematic-histories}.
8957 \end{notate}
8959 \begin{notate}{Selectively populate existing outline} \label{selectively-populate-existing-outline}
8960 It would be kind of interesting to combine `listing-to-compilation'
8961 with `export-scholium-system' (Note \ref{export-scholium-system})
8962 in such a way as to add some particular subset of the
8963 Notes into the section hierarchy.
8964 \end{notate}
8966 \begin{notate}{On `listing-to-label'}
8967 It can be handy to turn an arbitrary listing into
8968 a more permanent label.
8969 \end{notate}
8971 \begin{lisp}
8972 (defun listing-to-label (label-name)
8973 (interactive "MLabel: ")
8974 (let ((names (find-names-in-listing)))
8975 (scholium label-name
8976 (cdr names)
8978 'label
8979 (sch-book))))
8980 \end{lisp}
8982 \subsection{Further notes on derivative works}
8984 \begin{notate}{Derivatives and copyright}
8985 Recall that for copyright purpose, it is \emph{expression} that is
8986 supposed to be examined when deciding whether a given work derives
8987 from some other work. This somewhat elusive quality is going to be
8988 harder to capture than the property of being a derivative via direct
8989 quotation and subsequent revision.
8990 \end{notate}
8992 \begin{notate}{Pedigrees} \label{pedigrees}
8993 When adding metadata to show what articles a given article derives
8994 from, we probably only want to bother with the parent, not with
8995 ancestors from earlier generations. More extensive information about
8996 an article's pedigree can be found by chasing backlinks, as needed.
8997 \end{notate}
8999 \begin{notate}{Aggressive management of derivatives} \label{aggressive-dop}
9000 A more ``aggressive'' solution to recording information about
9001 derivative works would be to mark up rendered articles with a text
9002 property that identifies them; this way, whenever the text is
9003 cut-and-pasted to a new buffer, the text property will be carried
9004 along, and the source of the text can be identified and noted
9005 when the recipient article is reparsed and committed.
9006 \end{notate}
9008 \begin{notate}{Fancy derivatives} \label{fancy-derivatives}
9009 It may be useful at times to carry over certain scholia attached to
9010 the region that is being quoted. There are probably a number of
9011 variations that people would be interested in trying.
9012 \end{notate}
9014 \begin{notate}{Eventual improved support for virtual collections?} \label{improved-support-for-virtual-collections}
9015 In Note \ref{derivative-works-in-the-scholium-system} we briefly
9016 contrasted derivative articles with collections and indices. It seems
9017 likely that we can come up with tools that will make it easier to
9018 build useful indices; subcollections (Section \ref{subcollections})
9019 seem to capture the basic idea, but there is room to grow there.
9020 \end{notate}
9022 \begin{notate}{Derivative articles and forking} \label{derivative-articles-and-forking}
9023 One obvious way to fork an article is simple -- to include it in full
9024 and then begin edits there. The ability to do this gives users quite
9025 a bit of freedom; however, it is worth noting that it can frequently
9026 be to a user's benefit to get their changes inserted in (or around)
9027 the original source, instead of placing them in a separate derivative
9028 version. (This relates to Section \ref{philosophy}.)
9029 \end{notate}
9031 \begin{notate}{Tracking changes in parents}
9032 Transcluding will make it so that changes to the parent are
9033 immediately reflected in the child. This is not so with inclusions;
9034 however, owners of articles that use inclusion may still want to be
9035 \emph{updated} when the parent changes. See Section \ref{bidi}.
9036 \end{notate}
9038 \begin{notate}{Tracking changes in children}
9039 Nevertheless, there are certainly times when it is beneficial or
9040 expedient to create a modified version. To cater to users in this
9041 situation, we could also set up a derivative-tracking device, who's
9042 function would be to update the original author about the fate and
9043 progress of any derived versions. See Section \ref{bidi}.
9044 \end{notate}
9046 \begin{notate}{Overviews} \label{overviews}
9047 It would be nice to include markup associating an overview with the
9048 section of the document that was being overviewed.
9050 \emph{Editing (or mixing) down} is essentially similar thing done in a
9051 different spirit. Whereas I'm imagining that the edited-down version
9052 would replace the old version, the overview would likely exist in
9053 parallel with the original.
9054 \end{notate}
9056 \begin{notate}{Transclusion with modifications}
9057 In addition to the overviews of Note \ref{overviews}, we could be
9058 interested in other sorts of ``transclusion with modifications''. For
9059 example, if the overview is created by transcluding only the first
9060 paragraph from every chapter, other modified versions could be created
9061 by replacing \emph{foo} by \emph{bar} everywhere.
9062 \end{notate}
9064 \begin{notate}{Transclusion (typically) induces a linear structure} \label{transclusion-induces-linear-structure}
9065 If an article is built out of other transcluded articles, then it
9066 should be possible to abstract an \emph{order}, so that one can say
9067 ``next article'' or ``previous article'' and have these things make
9068 sense. But of course, this order can easily be broken, say by
9069 allowing there to be two ``next articles'' (compare \emph{Literary
9070 Machines}). Also note that nested transclusions (typically) induce
9071 a tree structure.
9072 \end{notate}
9074 \begin{notate}{Transclusion-like actionable derivatives}
9075 In order to keep the first example of a scholium given in section
9076 \ref{examples}, ``Remark on Scholium Definition'', up to date, it
9077 would be nice not to have to keep changing the numbers that identify
9078 the the beginning and end of the region being indicated by hand. This
9079 problem could be solved by putting a scholium in place of each number
9080 that renders as the appropriate number whenever the article is
9081 rendered. A standard scholium \inp{about} the region in question
9082 would be maintained by reparsing (Section \ref{parsing}), but the
9083 actual numbers that designate the beginning and end of this region
9084 will move around. Designing the actionable scholium that would
9085 accomplish the job here will take a bit of doing.
9086 \end{notate}
9088 \begin{notate}{Indivisible read-only text for collapsed labels}
9089 Perhaps collapsed text (Note \ref{transcluding-and-outlines}) should
9090 have a special read-only property (alternatively, changes to such text
9091 would constitute suggested changes to the \inp{name} of the article
9092 that was transcluded; see Note \ref{identification-use-case}).
9093 \end{notate}
9095 \begin{notate}{Scholia Display as transclusion}
9096 Although it isn't technically put together that way (at least, not
9097 now), one could think of the Scholia Display as being an article that
9098 is put together by transcluding all of the scholia attached to the
9099 current main article.
9100 \end{notate}
9102 \begin{notate}{Rendering deleted objects} \label{rendering-deleted-objects}
9103 This is a general problem that affects both rendering straightforward
9104 articles which happen to be transcluded and rendering articles with
9105 transclusions that point at articles that have been deleted.
9106 Presumably, some kind of ``404 File not found'' error will be
9107 displayed at an appropriate point in the text.
9108 \end{notate}
9110 \begin{notate}{Building transcluded articles by reparsing}
9111 Particularly if transcluded portions of a document are not directly
9112 editable, it might make sense to build ``text with transclusions'' by
9113 first assembling the content of a buffer containing transclusions, and
9114 then parsing the text properties. If the transcluded portions were
9115 directly editable, we could get into a somewhat tricky situation
9116 (e.g. should shearing three characters off of the end of the image of
9117 some transcluded text also change the transclusion command so that
9118 those characters are not copied over in the future? -- probably,
9119 although there are probably better ways of editing transclusion
9120 specifics).
9122 This is essentially what I've decided to do; see Note Transclusion
9123 from a design perspective.
9124 \end{notate}
9126 \begin{notate}{Rendering text with derivative pieces to specific places}
9127 Right now, text that includes transclusions is set up to only render
9128 to the ``Main Article Display'' buffer (because the \inp{text} field
9129 is not a buffer). We could set things up so that articles whose text
9130 contains transclusions could be associated with specific buffers where
9131 the rendered text would appear. This would require some changes to
9132 `scholia-overwhelm-display' (see Note
9133 \ref{scholia-overwhelm-display}).
9134 \end{notate}
9136 \section{Saving and restoring} \label{saving-and-restoring}
9138 \begin{notate}{Why saving?}
9139 Having created several different scholia, you may wish to save your
9140 work, to read back in later, or to send to a collaborator.
9141 \end{notate}
9143 \begin{notate}{Reverting}
9144 The idea of \emph{reverting} to an earlier revision relates to the
9145 previous section, as well as, vaguely, to the notion of
9146 \emph{restoring} a saved article. It isn't clear which section it
9147 should go in, since it isn't actually any of these things! It seems
9148 like a somewhat likely candidate to go into the previous section
9149 instead of this one.
9150 \end{notate}
9152 \begin{notate}{Restoring and managing state}
9153 Various details (e.g. an index counting new articles that have been
9154 added to the system) may need to be maintained between sessions.
9155 \end{notate}
9157 \begin{notate}{Saving buffers to files}
9158 When saving/quitting, articles that come from buffers may then get
9159 associated with files (assuming that the buffers end up getting saved
9160 to a file). Presumably we should \emph{offer} to save buffers to
9161 files; alternatively, we could save them in some internal format that
9162 the scholium system knows how to restore (reminds me of Emacs
9163 filesets; see also Note \ref{excess-of-read-scholia-file}).
9164 \end{notate}
9166 \begin{notate}{Saving special scholia}
9167 We should presumably offer the option of just saving only \emph{new}
9168 or \emph{modified} scholia, or those that are connected with the
9169 current buffer, or those that have a certain \inp{type}, etc., rather
9170 than saving the whole library. In some cases, the collection to be
9171 will presumably only be found by predicate matching; other times, we
9172 will be able to maintain an index of the subcollection to be saved
9173 (e.g. we can keep track of all the articles that have been modified
9174 since the last save).
9175 \end{notate}
9177 \begin{notate}{Autosave}
9178 We might consider making some environment variable that would cause
9179 things to be saved to disk automatically.
9180 \end{notate}
9182 \begin{lisp}
9183 (defun save-all-scholia (filename)
9184 (interactive (list
9185 (read-file-name "Filename: ")))
9186 (save-window-excursion
9187 (gather-scholia)
9188 (write-file filename)
9189 (kill-buffer (current-buffer))))
9190 \end{lisp}
9192 \begin{notate}{On `gather-scholia'}
9193 It might be a good idea for this function to take an optional
9194 predicate or label, and gather only scholia that match that predicate.
9195 We could easily cause the gathering function to run only within a
9196 certain context as well.
9198 This function doesn't really have anything to do with saving,
9199 logically speaking, so perhaps it shouldn't go in this section.
9200 \end{notate}
9202 \begin{lisp}
9203 (defun gather-scholia ()
9204 (interactive)
9205 (set-buffer (get-buffer-create "*Scholia*"))
9206 (delete-region (point-min) (point-max))
9207 (maphash (lambda (name val)
9208 (write-scholium (cons name val)))
9209 article-table)
9210 (display-buffer "*Scholia*"))
9211 \end{lisp}
9213 \begin{notate}{Improving the design of `write-scholium'}
9214 One could probably make these things print a bit nicer, e.g. to make
9215 everything fit within 80 columns, but this seems to be good enough for
9216 the time being.
9217 \end{notate}
9219 \begin{lisp}
9220 (defun write-scholium (article)
9221 (let ((nl "\n "))
9222 (insert
9223 (concat "(scholium " (maybe-quoted-format (scholium-name article))
9224 nl (maybe-quoted-format (scholium-text article))
9225 nl (maybe-quoted-format (scholium-about article))
9226 nl (format "'%S" (scholium-type article))
9227 nl (format "'%S" (scholium-bookkeeping article))
9228 ")\n\n"))))
9230 (defun maybe-quoted-format (obj)
9231 (if (and (not (null obj))
9232 (or (atom obj) (consp obj)))
9233 (format "'%S" obj)
9234 (format "%S" obj)))
9235 \end{lisp}
9237 \begin{notate}{Design of `read-scholia-file'}
9238 This reads and evaluates all of the scholia that have been written out
9239 into the file stored at \inp{filepath}.
9240 \end{notate}
9242 \begin{lisp}
9243 (defun read-scholia-file (filepath)
9244 (interactive "fFile: ")
9245 (find-file-literally filepath)
9246 (read-scholia-buffer)
9247 (kill-buffer (current-buffer)))
9249 (defun read-scholia-buffer ()
9250 (while (condition-case nil
9251 (eval (read (current-buffer)))
9252 (error nil))))
9253 \end{lisp}
9255 \begin{notate}{Apparently excessive generality of `read-scholia-file'} \label{excess-of-read-scholia-file}
9256 This system would actually read any elisp file (er, I'm not sure it
9257 would deal well with comments). There are built-in functions that
9258 accomplish the same thing (`load-file' and `eval-buffer' come to
9259 mind). The idea here was that we might want to do something somewhat
9260 more complicated than simply evaluating the code found in the file.
9261 That may still happen.
9262 \end{notate}
9264 \begin{lisp}
9265 (defvar search-directory-for-scholia t)
9267 (add-hook 'find-file-hook 'search-directory-for-scholia)
9269 (defun search-directory-for-scholia ()
9270 (list-directory default-directory t)
9271 (let ((sch-file
9272 (replace-regexp-in-string "\\..*" ".sch" (buffer-file-name))))
9273 (when (search-forward sch-file nil t)
9274 (read-scholia-file sch-file)
9275 (display-scholia-about-current-buffer)))
9276 (kill-buffer "*Directory*"))
9277 \end{lisp}
9279 \section{Distributed authorship} \label{distributed}
9281 \begin{notate}{Introducing distributed authoriship}
9282 Thus far, there has only been one author. But on a multi-user system,
9283 several different authors would be adding text to the system. It is
9284 fairly trivial to set up a system-wide list of directories to browse
9285 for articles, enabling users of a shared filesystem to co-author a
9286 digital library together. We can do something very similar when the
9287 authors are not physically co-located, by using CVS or GNU Arch to
9288 collect the contributions of the various authors.
9289 \end{notate}
9291 \begin{notate}{Masters}
9292 Do we need to have one ``master'' copy of each article in the system,
9293 or can downstream users consider the version that they downloaded to
9294 be the de-facto master copy? Probably the Arch documentation has
9295 something to say about this.
9296 \end{notate}
9298 \begin{notate}{Differences between the system here and the typical diff-based model}
9299 I'm not completely sure what the advantages of the system here will be
9300 over the typical diff- and email-based system for maintaining code.
9301 One difference is that information will be relayed using a ``pull''
9302 rather than a ``push'' model (see Note \ref{draw}). Other aspects of
9303 the system may simply be more convenient ways of doing things that
9304 people already do; for example, loading and unloading sets of patches.
9305 (I'm sure there is already plenty of software for doing this
9306 conveniently.) On this note, compare
9307 filesets\footnote{{\tt http://www.nongnu.org/qualta/FilesetsDoc.html}};
9308 contributed data coming from any given source would likely be loaded
9309 into a special subcollection.
9310 \end{notate}
9312 \begin{notate}{Relationship of namespaces to distributed authorship}
9313 One might consider reading articles from each distinct article source
9314 into its own namespace. On the other hand, it would be possible
9315 to simply tag the articles with some \inp{bookkeeping} information
9316 to show where they had come from. The same complexity issues arise
9317 here as in other (possible) applications of the namespace principle.
9318 \end{notate}
9320 \begin{notate}{Merging articles with name conflicts}
9321 From time to time, authors will create scholia about similar things
9322 (e.g. Emacs functions) and someone will want to merge the results. We
9323 should make it straightforward to do this. (It may be that the best
9324 way to merge is to just use namespaces and always display the articles
9325 together.)
9326 \end{notate}
9328 \begin{notate}{Scalability of search}
9329 In general, some work will have to be done to keep search spaces
9330 fairly small, but an opt-in model for spaces to search will help with
9331 that (compare RSS). The algorithms associated with a \emph{global}
9332 version of this system (like Xanadu) would be pretty intensive. We'll
9333 have to think more about this if a deployed system ever gets big.
9334 \end{notate}
9336 \begin{notate}{Draw} \label{draw}
9337 People should subscribe or not depending on their preferences. Free
9338 software, if nothing else, teaches us to \emph{look at the demand
9339 side!}
9341 In distributed implementations, we typically won't \emph{send} updates
9342 as much as make them available for pickup. We certainly could send
9343 some sort of notification saying that new content is available. On
9344 the other hand, there's no particular reason \emph{not} to send
9345 content directly in some implementations. (For more on the topic of
9346 making updates available, see Note
9347 \ref{send-messages-to-redirected-scholia}.)
9348 \end{notate}
9350 \begin{notate}{FAIF not FAIB, and DRM}
9351 To think about this another way: the Xanadu system is FAIF but not
9352 FAIB. The idea was to charge people on a pay-per-view (or
9353 pay-per-use) basis, with some fraction of royalties going back to each
9354 of the authors whose work made up part of the delivered text. (It
9355 would be interesting to try to connect -- or to dissociate -- this
9356 model from current DRM ideas.)
9357 \end{notate}
9359 \begin{notate}{The p2p connection}
9360 Assembling a document from various disparate sources in the database,
9361 reminds me of something that comes up in p2p filesharing, namely the
9362 way in which documents can be assembled from partial data drawn from
9363 various nodes. How should one go about the process of assembling the
9364 document from the sources available? We will need to think and learn
9365 more about the algorithms that would need to be employed in a system
9366 like the one described here, including its potential uses in
9367 distributed content systems.
9368 \end{notate}
9370 \begin{notate}{Increasingly expensive local operations}
9371 Assembling massive amounts of information, e.g., sorting the scholia
9372 about a given document, is going to be somewhat computationally
9373 intense ($n \log n$, right?). If we ever got into situations in which
9374 there were thousands of scholia about any given article, we might want
9375 to avoid doing sorting (perhaps by storing the scholia in sorted order
9376 some place or other). Also, by default, we should avoid sorting any
9377 scholia we don't need to display (e.g. frequently, actionable
9378 scholia), because sorting them is just a waste of time.
9379 \end{notate}
9381 \begin{notate}{Reasons things might not bubble up too bad}
9382 My \emph{guess} is that even a very popular article won't have a whole
9383 lot of printing scholia attached to it. A number of people will want
9384 to make comments, sure, but others will prefer to make derived
9385 versions, or comments on the 1st generation of comments.
9386 \end{notate}
9388 \begin{notate}{Are names always available?}
9389 I'm not sure whether an article would ever appear that had been marked
9390 up with names or namespaces that we don't have access to. Maybe.
9391 This seems more likely to be an issue in
9392 real life when we're dealing with distributed documents, but it could
9393 potentially be an issue whenever there are multiple namespaces
9394 (or even one poorly maintained namespace; compare Note \ref{rendering-deleted-objects} --
9395 sometimes articles will be deleted).
9396 \end{notate}
9398 \begin{notate}{Accepting updated `about' information} \label{accepting-updated-about-info}
9399 Why would an author want to incorporate updated \inp{about}
9400 information into the original article? One reason is simply to check
9401 that this information is accurate. By allowing users to set updated
9402 \inp{about} data automatically when editing a scholium's target, a
9403 degree of flexibility is built into the system that would be
9404 impossible (and, indeed, probably wouldn't make sense) otherwise.
9405 But when one's work is being interpreted in a new way, and, indeed,
9406 in a new context, it may be worthwhile to check that you agree with
9407 this interpretation.
9408 \end{notate}
9410 \subsection{Bidirectional updates} \label{bidi}
9412 \begin{notate}{Setup for bidirectional updating}
9413 We'll assume that one of the authors is using the scholium system, and
9414 the other isn't. (The other possible cases have either been covered
9415 or are not part of our mandate.)
9417 In order to make bidirectional updating work when some of the editing
9418 is going on outside of the scholium-based system, we would need to be
9419 able to read a stream of diffs coming from the other system and decide
9420 how to incorporate the modifications. And we also need to be able to
9421 provide them with a stream of diffs that they can use however they see
9422 fit. We'll certainly have to think more about how to do this!
9423 \end{notate}
9425 \begin{notate}{Using simulation to do bidirectional updating} \label{simulation-for-bidi}
9426 It seems to me that the most useful approach for someone working
9427 within the scholium system and trying to do bidi updates with a
9428 non-scholium system would be to run a simulated version of the
9429 non-scholium system inside the scholium system.
9430 \end{notate}
9432 \begin{notate}{The simplest case}
9433 The simplest case of bidirectional updating is \emph{identification},
9434 which is treated in Section \ref{identification}. Even this case has
9435 some complexity to it in the distributed case; updates coming from
9436 multiple authors presumably need to be formatted into branching
9437 derivative versions. (Actually, this is an $n$-directional updating
9438 problem; Arch has had some things to say about this, but we can
9439 probably say more.)
9440 \end{notate}
9442 \subsection{Interoperability} \label{interoperability}
9444 \begin{notate}{Exporting} \label{exporting}
9445 It should be possible to reduce metadata and so on to some format that
9446 would work with external programs (e.g. database programs). I'm not
9447 at all sure how the use of text properties would be replaced in other
9448 programs, but I think that, in theory, the things we save (Section
9449 \ref{saving-and-restoring}) should be sufficient and readable for any
9450 other interested program. I'd be interested to know the thoughts of
9451 others on building other interfaces to the scholium system.
9452 \end{notate}
9454 \subsection{A simple scheme for multiuser cooperation} \label{multiuser-cooperation}
9456 \begin{notate}{Crosscut by users and dates}
9457 A simple scheme for facilitating interactions between several users is
9458 as follows. Each user gets a directory to call their own. Each users
9459 scholia for the day are stored in a file in this directory. To catch
9460 up with the activities of all users, one simply loads all of the files
9461 that have appeared since the last load date.
9463 To implement this scheme, we need a method for populating the
9464 data-store and another for scanning it to determine which files to
9465 load.
9467 We'll assume that only the scholia that bear a certain label (say ``to
9468 publish'') will be published, and that once they have been published,
9469 this label is wiped out (maybe it is set to ``last published''). In
9470 general, the ``to publish'' set could be determined by some somewhat
9471 complicated algorithm, not just by looking at a label.
9473 Also, we should presumably maintain all of the imported scholia in a
9474 namespace (most likely, certainly some subcollection) in order to keep
9475 them straight. (For a first draft, we could just import everything to
9476 the main article table, given that namespaces don't completely work
9477 yet.)
9479 Presumably we should start by building the infrastructure in our CVS
9480 directory. (Some more general formulation that allows collaboration
9481 between different people writing to disparate locations online would
9482 be good to have eventually; to support this we'll want some sort of
9483 protocol, maybe something like RSS.)
9484 \end{notate}
9486 \begin{notate}{Networked blotters}
9487 Keeping one another up to date on the important features of daily
9488 goings on is an important use of the multiuser system. The notion
9489 that each user would maintain some sort of ``blotter'', possibly
9490 incorporating some auto-generated content, which others can read to
9491 stay in the loop.
9492 \end{notate}
9494 \begin{notate}{Strategic usefulness of building and using collaboration tools early on} \label{collaborate-early}
9495 While we could ask people to work on other things first (and to some
9496 extent it will be necessary for people to work on other things all
9497 along the way) it seems likely that using powerful collaboration tools
9498 will help people get things done on other projects or subprojects.
9499 When many people can share differing views on a topic, the discussions
9500 of this topic will develop a richness that wouldn't be so likely to
9501 develop otherwise. A system that can take into account many views in
9502 a coherent and useful way is going to be a powerful system. (It would
9503 be good to do some research on the differing abilities of various
9504 extant systems to accomplish this.)
9506 Collaboration is a challenging thing to deal with. You have greenhorn
9507 or yahoo types who want to charge off and do things on their own (I'm
9508 often one of them), and in the mean time, you don't always have a
9509 central point for collaboration on some topic where you might hope one
9510 would be. It isn't always clear when you have a certain vision
9511 whether there are others out there who would share that vision or not.
9512 Partly, that's because when you have a vision it isn't always
9513 completely clear what that vision is; but these things interact.
9514 \end{notate}
9516 \section{Bindings and environment variables} \label{bindings}
9518 \begin{notate}{Room to improve on bindings}
9519 This is just an attempt to make something usable, but it is probably
9520 nowhere near close to optimal. One thing that would be nice would be
9521 to have some prefix for browsing relative to all scholia versus
9522 some other prefix for browsing relative to only the current scholium.
9523 Thus, you could cycle between regions for the current scholium or
9524 regions for all scholia (or go to the first region or whatever)
9525 depending on what prefix you specified -- but the final keystroke
9526 (``f'' for forward or whatever) would be the same. Perhaps we
9527 could substitute in the first register (as opposed to the second)
9528 for changing the general style of browsing (e.g. from scholia to
9529 temporal or whatever), but keep second and third pretty much the
9530 same. It would be good to spell out the analogies in a somewhat
9531 detailed table.
9532 \end{notate}
9534 \begin{lisp}
9535 (mapc
9536 (lambda (elt) (global-set-key (eval (car elt)) (eval (cdr elt))))
9537 '(([?\C-\;] . (make-keymap))
9538 ([?\C-\;?m] . (make-sparse-keymap))
9539 ([?\C-\;?d] . (make-sparse-keymap))
9540 ([?\C-\;?o] . (make-sparse-keymap))
9541 ([?\C-\;?s] . (make-sparse-keymap))
9543 ((kbd "C-; c") . 'commit-edits)
9544 ((kbd "C-; g") . 'gather-scholia)
9545 ((kbd "C-; f") . 'follow-reference-or-scholium)
9546 ((kbd "C-; n") . 'name-of-current-scholium)
9547 ((kbd "C-; r") . 'save-all-scholia)
9549 ((kbd "C-; v n") . 'back-to-normal)
9550 ((kbd "C-; v o") . 'back-to-other-view)
9552 ((kbd "C-; b b") . 'sb-back)
9553 ((kbd "C-; b f") . 'sb-forward)
9555 ((kbd "C-; l a") . 'article-menu-list-all-articles)
9556 ((kbd "C-; l l") . 'article-menu-list-labels)
9557 ((kbd "C-; l m") . 'article-menu-list-articles-matching-regexp)
9558 ((kbd "C-; l d") . 'article-menu-list-metadata-articles)
9559 ((kbd "C-; l p") . 'article-menu-list-plain-articles)
9561 ((kbd "C-; m a") . 'make-scholium-about-current-article)
9562 ((kbd "C-; m b") . 'make-scholium-about-current-buffer)
9563 ((kbd "C-; m l") . 'make-scholium-about-current-line)
9564 ((kbd "C-; m n") . 'make-new-undirected-article)
9565 ((kbd "C-; m i") . 'make-current-buffer-into-article)
9566 ((kbd "C-; m p") . 'make-scholium-about-part-of-current-article)
9567 ((kbd "C-; m P") .
9568 'make-scholium-about-several-parts-of-current-article)
9569 ((kbd "C-; m s") . 'make-scholium-about-current-scholium)
9571 ((kbd "C-; d a") . 'display-article)
9572 ((kbd "C-; d b") . 'display-scholia-about-current-buffer)
9573 ((kbd "C-; d l") . 'display-article-listing)
9574 ((kbd "C-; d p") .
9575 'display-an-article-that-current-article-is-about)
9576 ((kbd "C-; d c") .
9577 'display-an-article-that-current-scholium-is-about)
9578 ((kbd "C-; d r") . 'redisplay-article)
9580 ((kbd "C-; o y") . 'sch-turn-main-article-overlays-on)
9581 ((kbd "C-; o n") . 'sch-turn-main-article-overlays-off)
9583 ((kbd "C-; s n") .
9584 'scroll-article-display-to-next-region-for-current-scholium)
9585 ((kbd "C-; s p") .
9586 'scroll-article-display-to-previous-region-for-current-scholium)
9587 ((kbd "C-; s b") . 'move-to-previous-region-with-scholium)
9588 ((kbd "C-; s f") . 'move-to-next-region-with-scholium)
9589 ((quote [S-tab]) . 'move-to-next-region-with-scholium)
9590 ((kbd "C-; s a") . 'move-to-first-region-for-current-scholium)))
9591 \end{lisp}
9593 \begin{notate}{Style of code for bindings}
9594 I've heard that using `eval' is typically bad style,
9595 but something had to be done to make these bindings work.
9596 What would have been better in terms of coding style?
9597 \end{notate}
9599 \begin{notate}{Environment variables} \label{environment-variables}
9600 It would be handy to be able to have things set up so that e.g. every
9601 buffer is automatically an article, too. Various innovations along
9602 these lines should be added here.
9603 \end{notate}
9605 \begin{notate}{Automatically loading scholia}
9606 Along the lines of Note \ref{environment-variables}, this section
9607 would be a good place to put a variable that would cause scholia to be
9608 loaded for all buffers (which I think says slightly more, or anyway
9609 something slightly different from, the statement that every buffer
9610 would automatically \emph{be} an article). Note that whenever loading
9611 scholia for a given buffer, there may be several different places to
9612 look to find those scholia: in the article table, but also in local
9613 ``.sch'' files, or other places.
9614 \end{notate}
9616 \section{Experiments} \label{experiments}
9618 \begin{notate}{Experiments to try}
9619 This section should describe our experiments modeling different CBPP
9620 systems that are out there in the world -- and coming up with new ones
9621 that we like better.
9623 In this section, we can describe some separate packages that provide
9624 more interesting or advanced display features, for example. Also
9625 maybe some packages that do things with code (e.g. interactive
9626 text-based games). Wiki portage would be one basic thing to try.
9627 Finally, of course, it would presumably be useful to get the HDM
9628 codebase into the scholium system.
9630 \begin{itemize}
9631 \item Importing a wiki and getting the scholium system set up
9632 to do wiki-like things.
9633 \item Using the scholium system to write a play, novel, screenplay, or
9634 an interactive fiction type of game (actionable scholia would
9635 probably be part of just about any game). Hipster the
9636 Gathering\footnote{{\tt
9637 http://planetx.cc.vt.edu/AsteroidMeta/Hipster\_the\_Gathering}}
9638 would presumably be an easy game to code up. My forays into ``fine
9639 literature'' with the Penmaster's Apprentice saga could also be
9640 typed up. These things are currently interesting examples of
9641 physical scholia (see Section \ref{more-physical-scholia}).
9642 \item Using the scholium system to maintain a text-based forum
9643 or set of fora, as found on PM or slashdot.
9644 \item Using the scholium system to manage an evolving codebase,
9645 e.g. HDM content, say APM and APM-$\Xi$, or this document itself
9646 (making the system interoperable with \LaTeX\ would be important).
9647 \item Using the scholium system to manage TODO lists (like we used to
9648 do with TODL etc.).
9649 \item Port GCIDE to Emacs and give instant access to definitions from
9650 within the browser. Make GCIDE scholiumific (supplying semantically
9651 close definitions or whatever?).
9652 \item do something like mmm-mode but using scholia about the buffer
9653 instead of begin/end regexps?
9654 \item Make a semantic network describing relationships between words
9655 and use it for writing poetry.
9656 \item make a system for exporting to other formats (see Note
9657 \ref{rendered-and-source-views})
9658 \item Write text-generation software that will provide different ways
9659 of viewing the network's structure.
9660 \end{itemize}
9661 \end{notate}
9663 \begin{notate}{Cross-referencing in \LaTeX} \label{cross-refs-in-latex}
9664 Note that the system of labels and references in \LaTeX\ allow you to
9665 make ``hypertextual'' linear documents. This system could perhaps be
9666 extended (maybe by exploiting the scholium system). It would be cool
9667 to be able to cross-reference the relevant label in some other
9668 document and have a suitable reference show up here. This is a
9669 scholium-like thing: how to make it work in \LaTeX? (Maybe
9670 \verb|\pmxref| should be able to refer to anything that has a
9671 \verb|\label| about it. Perhaps this would work already.) This also
9672 relates to the topic of Namespaces, see Section \ref{subcollections}.
9673 \end{notate}
9675 \begin{notate}{A comprehensive regression suite}
9676 This would be a fairly simple experiment, which would nevertheless
9677 be very helpful for programming the system. Namely, create
9678 a short program that tries to do everything that you can do with
9679 the system.
9680 \end{notate}
9682 \begin{notate}{Go moves}
9683 It would be nice to have a browsable database of Go moves and games
9684 with user annotations: presumably the already-existing Go resources
9685 online include things like this. If the scholium system can help
9686 improve upon these resources, that would be cool. For example,
9687 perhaps gnugo's move book could be simultaneously an instruction
9688 manual for human users.
9689 \end{notate}
9691 \begin{notate}{Games built of scholia}
9692 Note that the relationships of people to rooms (containment), people
9693 to their backpacks (carrying), and so forth -- the basic elements of
9694 text-based games -- are all interpretable as scholia-based. The
9695 ``fantasy'' tie-in of these sorts of games works reasonably well with
9696 the name Arxana. If we're going to push development along this route,
9697 it would be good to do some reading on MUD-like systems.
9698 \end{notate}
9700 \begin{notate}{Stress testing the system}
9701 It would probably be worth doing some empirical tests to see what
9702 happens in a library full of a bunch of junk. How long does it take
9703 to find and display the one relevant scholium? How much are things
9704 helped by storing articles in namespaces?
9705 \end{notate}
9707 \begin{notate}{Scholia about functions}
9708 This function, or something like it, seems especially important if
9709 we're going to use the scholium system to manage code. Every time we
9710 create a function, for example, it would be good to create a scholium
9711 attached to that function (perhaps a scholium object whose \inp{name}
9712 is the function's symbol name, though there could be the need to
9713 disambiguate between the function and variable versions of the same
9714 symbol) with a ``defined-in-buffer'' link \inp{about} the buffer in
9715 which the given function definition is found; Emacs already has
9716 functionality like this in its help subsystem. This could be done by
9717 explicit command or just on-the-fly by some appropriately-constructed
9718 automatic function.
9720 In addition, one could create scholia that say, for instance, which
9721 functions that function calls. Then, later, one could assemble a
9722 who-calls or who-is-called listing about a given function, for the
9723 user to browse. Although this can be done easily enough already
9724 (there is a who-calls.el), it is my sense that this approach would
9725 save on search. Browsing code at the ``who calls'' level seems
9726 potentially interesting; it would be worth investigating the prior art
9727 here more.
9728 \end{notate}
9730 \begin{notate}{Barkov's ``Hamlet''} \label{barkovs-hamlet}
9731 The system could be used to handily create different versions of a
9732 play, e.g., to write a version of ``Hamlet'' manifesting the view that
9733 actually Horatio is the
9734 prince\footnote{{\tt http://www.geocities.com/shakesp\_marlowe/index.html}} or to
9735 splice in ``Rosencrantz and Guildenstern are Dead'' by Stoppard or
9736 ``King of Shreds and Patches'' by Elrord or whatever (assuming that
9737 doing so was legally copacetic; for personal use of course it would
9738 be). Similarly, our treatment could describe theories about how the
9739 play relates to things outside the play, or (being even more meta),
9740 how the \emph{interpretation} of the play relates to the presentation,
9741 or (still more), where the interpretation comes from, and how I think
9742 \emph{my} interpretation of these various things gets involved.
9743 \end{notate}
9745 \begin{notate}{Using scholia on PlanetMath}
9746 Since articles in the encyclopedia are supposed to describe known
9747 math, they aren't really the right place to describe new insights,
9748 even if these new insights occur while reading that article. (In
9749 theory such insights could be discussed in the attached forum along
9750 with basic questions or whatever; but a catch-all forum or collection
9751 of catch-all fora and postings without metadata may not be the most
9752 conducive to research-oriented work.) My thought is, why not have an
9753 attached discussion not in the encyclopedia for talking about some
9754 particular advanced question. This area can itself use encyclopedia
9755 definitions as scholia to help orient casual readers. This way,
9756 treatments of established and ``live'' mathematics can develop
9757 together.
9758 \end{notate}
9760 \begin{notate}{Implement a web browser that works with the scholium system} \label{nero2}
9761 Maybe I'll write this before long? It seems like the sort of thing
9762 that could be very helpful; search through scholia on web pages you've
9763 browsed (and also download everything you browse and save it to
9764 disk, so that you can search through the web pages themselves too).
9766 Through this sort of approach, you might imagine the web (or portions
9767 thereof) being ``embedded'' in a more advanced hypertext system, at
9768 least for some users. Something similar can be done for working with
9769 Project Gutenberg\footnote{{\tt http://www.promo.net/pg}} or any
9770 collection of computer-readable text.
9771 \end{notate}
9773 \begin{notate}{Use the scholium system to assist in literature review} \label{literature-review}
9774 There are a number of different literatures that are relevant to the
9775 scholium system. From artificial intelligence, we have things like KM
9776 or SNePS that are available as free software, and which can
9777 accordingly be reviewed \emph{in their entirety}. Or, at least in as
9778 much of their entirety as seems useful. It may be desirable to
9779 simulate or at least partially simulate these systems (which is partly
9780 what the \emph{preliminary} literature review is supposed to
9781 determine, by looking at the basic theory of these systems).
9783 In hypertext, there are systems like No\"osphere which can be treated
9784 similarly. Indeed, I am planning a meetup with No\"osphere's author,
9785 Aaron Krowne, for purposes of mutual exchange over and potential
9786 cross-breeding between these two systems.
9788 There are no doubt many other interesting literature things to study
9789 out there. Deciding which ones will be most profitable to look at is
9790 an interesting challenge.
9791 \end{notate}
9793 \begin{notate}{Backlink tricks} \label{backlink-tricks}
9794 One obvious thing to do with backlinks is to compute the
9795 most-linked-to article, or, even better, to rank articles by their
9796 popularity according to in-links. This can be done by mapping a very
9797 simple function over the \inp{metadata} label (or the ranking could be
9798 maintained on the fly).
9799 \end{notate}
9801 \subsection{Some extremely simple example to show people what's going on}
9803 \begin{notate}{Simplest example}
9804 It would be handy to create a very simple example of a buffer
9805 together with scholia.
9806 \end{notate}
9808 \begin{notate}{Next-simplest example}
9809 After that, it would be handy to make an example of a properly
9810 scholia-based document (showing some richer graph structure).
9811 \end{notate}
9813 \begin{notate}{Various other simple examples?}
9814 And while we're at it, maybe later a simple example of transclusion or
9815 identification or whatever.
9816 \end{notate}
9818 \subsection{Use the scholium system to maintain a library of projects} \label{library}
9820 \begin{notate}{Managing several projects}
9821 We'll do several different experiments, some of which will involve
9822 corpora that are (at least essentially) distinct. One high-level
9823 object to point at the ``main pages'' of these various projects might
9824 come in handy. There could be a number of other more advanced
9825 library-like features to add later.
9826 \end{notate}
9828 \begin{notate}{Managing workflow}
9829 In addition to simply presenting output of these projects, it would be
9830 helpful to have the system set up to manage workflow (tasks and so
9831 on). For now, see \ref{appendix-cal}.
9832 \end{notate}
9834 \begin{notate}{Library of major works}
9835 We have an overall structure for the digital library as a whole worked
9836 out already (Section \ref{digital-library}), but not yet a specific
9837 list of major works. It is convenient to have an index of these (just
9838 like, later, it will be convenient to have many different indices of
9839 different kinds of documents with different features). So, we create
9840 a virtual library to index these works in. (Once this is set up
9841 properly, of course the imported version of the scholium system itself
9842 will be included.)
9843 \end{notate}
9845 \begin{lisp}
9846 (scholium 'major-articles nil nil 'label 'system)
9847 \end{lisp}
9849 \subsection{Use the scholium system to do literate programming} \label{literate}
9851 \begin{notate}{Importing LaTeX docs} \label{importing-latex-docs}
9852 Note that importing a \LaTeX\ document (this one, in particular)
9853 wouldn't be so different from importing a wiki (see Section
9854 \ref{wiki}).
9856 One of the issues is how we're going to represent cross references
9857 (see Note \ref{cross-refs-in-latex}). In compiled \LaTeX, they
9858 typically appear as a number, whereas in source they appear as a tag.
9859 In the scholium system, reference markup should presumably be used,
9860 and I also suppose that we may as well use the name of the article
9861 being referred to directly. So, for example, this article would
9862 be linked to by text that read ``see `Importing LaTeX docs'.''
9863 This is similar to the way references appear in Texinfo.
9865 Outside references (footnotes) could be rendered in a different
9866 color (Note \ref{fancy-references}), and made browsable within
9867 the scholium system (Note \ref{nero2}).
9869 On the implementation: `end' might be followed by a lisp expression
9870 that should be attached to the note, but this should be fun for a
9871 trial run.
9873 The format of the scholia representing the notes is kind of weird. We
9874 shouldn't have junk in the text field of the article. It would
9875 probably make more sense for items of type "note" to be rendered
9876 specially (if one wished) and maybe to store the tag as a part of a
9877 formatted text field, or, more likely, part of the \emph{type} data.
9879 I think I'd be relatively comfortable adding identification
9880 properties to the regions of the larger document, to get
9881 them to inherit from the individual pieces. Later we could
9882 parse the section structure.
9884 It would, generally speaking, be a good idea if lower levels
9885 in the hierarchy were \inp{about} their parents in such a way
9886 that we could easily move ``up''.
9887 \end{notate}
9889 \begin{lisp}
9890 (add-hook 'scholia-display-post-update-hook 'text-mode)
9892 (add-to-list 'modified-type-labels '(note . note) t)
9893 (add-to-list 'modified-type-labels '(section . section) t)
9894 (add-to-list 'modified-type-labels '(subsection . subsection) t)
9895 (add-to-list 'modified-type-labels '(subsubsection . subsubsection) t)
9896 \end{lisp}
9898 \begin{notate}{On `map-label'} \label{map-label}
9899 This gives you a way to apply a \inp{function} to every article that
9900 bears a given \inp{label}.
9901 \end{notate}
9903 \begin{lisp}
9904 (defun map-label (function label)
9905 (mapc function (scholium-text (get-article label))))
9906 \end{lisp}
9908 \begin{notate}{Example of mapping across a label} \label{mapping-across-a-subcollection}
9909 Notice that we use `map-label' (Note \ref{map-label}) in the APM-$\Xi$
9910 importing routine, to convert once-processed content to a more useful
9911 format. See Note \ref{chunk-out-apmxi-definitions}.
9912 \end{notate}
9914 \begin{notate}{On `swap-out-latex-references'}
9915 Does the opposite of `swap-in-latex-references' (Note
9916 \ref{swap-in-latex-references}): that is, this
9917 function makes \verb|\ref| tags
9918 in the text look like hyperlinks.
9919 \end{notate}
9921 \begin{lisp}
9922 (defun swap-out-latex-references ()
9923 (let ((tags-alist (scholium-text (get-article
9924 'Tag-to-Name-converter))))
9925 (map-label (lambda (name)
9926 (with-temp-buffer
9927 (let ((article (get-article name)))
9928 (insert (scholium-text article))
9929 (goto-char (point-min))
9930 (while (re-search-forward
9931 ;; I don't think we use "xrefs" any more.
9932 "\\\\\\(x\\)?ref{\\([^}]+\\)}" nil t)
9933 (let ((target (cdr
9934 (assoc (match-string 2)
9935 tags-alist))))
9936 (when target
9937 (replace-match target t t)
9938 (let ((name-of-current-article name))
9939 (make-reference-in-current-article
9940 (match-beginning 0)
9941 (+ (match-beginning 0) (length target))
9942 target)))))
9943 ;; we don't want these references to be fake
9944 (scholium name
9945 (buffer-substring-no-properties
9946 (point-min)
9947 (point-max))
9948 (scholium-about article)
9949 '(note)))))
9950 'note)))
9951 \end{lisp}
9953 \begin{notate}{On `import-scholium-system'} \label{import-scholium-system}
9954 For now, this is just `import-sections', but it would be good if we
9955 could do something about sections that contain neither subsections nor
9956 notes, for example, the preface. Other nice features (e.g. creating
9957 ``function type'' scholia for functions, as in Note
9958 \ref{elisp-function-type}) should be added too, eventually. Sometimes
9959 work arounds can be applied for the time being.
9961 \emph{Hint: I've found that for now one has to `(clrhash
9962 article-table)' before running this function for things to work
9963 properly. I intend to address this issue soon.}
9965 (We might want to make this article use some kind of identification
9966 routine; alternatively, make it work with a ``large structure'' map of
9967 the document's contents.)
9968 \end{notate}
9970 \begin{lisp}
9971 (defun import-scholium-system ()
9972 (interactive)
9973 (import-sections)
9974 ; (label-article 'section 'major-articles)
9975 (swap-out-latex-references))
9976 \end{lisp}
9978 \begin{notate}{Shorthand for editing the text of a scholium}
9979 It would certainly be nice to have some short-hand
9980 from the "editing" section to make it so that we didn't
9981 have to use the `scholium' function every time we wanted
9982 to edit some article.
9983 \end{notate}
9985 \begin{notate}{Autobacklink to label} \label{autobacklink-to-label}
9986 Also, it would be nice if the mere inclusion of ``section'' in the
9987 ``major-articles'' label meant that there would be a ``parent''
9988 (back)link from ``section'' to ``major-articles'' (see Note
9989 \ref{import-scholium-system} for the source of this example).
9991 Such backlinks would let you navigate from things that bear a certain
9992 label to the label itself and thence to the peers within that label.
9993 (This certainly seems like a good idea!)
9994 \end{notate}
9996 \begin{notate}{On `import-sections'}
9997 For each section, import any notes and any subsections.
9999 I'm going to try to get this to import front- and back-matter (before
10000 the first section and after the last note, respectively). This will
10001 make it easier to typeset everything with one command.
10002 \end{notate}
10004 \begin{lisp}
10005 (defun import-sections ()
10006 (save-excursion
10007 (set-buffer "sbdm4cbpp.tex")
10008 (goto-char (point-min))
10009 (search-forward-regexp "^\\\\section{Prelude}")
10010 (goto-char (match-beginning 0))
10011 (scholium "Scholium system frontmatter"
10012 (buffer-substring-no-properties (point-min) (point))
10014 '(note))
10015 (while (re-search-forward
10016 (concat
10017 "^\\\\section\\*?{\\([^}\n]*\\)}"
10018 "\\( +\\\\label{\\)?"
10019 "\\([^}\n]*\\)?")
10020 nil t)
10021 (let* ((name (match-string-no-properties 1))
10022 (tag (match-string-no-properties 3))
10023 (section-end (save-excursion
10024 (search-forward-regexp
10025 "^\\\\section{.*" nil t)))
10026 (notes-end (or (save-excursion
10027 (search-forward-regexp
10028 "^\\\\subsection{.*"
10029 section-end t))
10030 section-end))
10031 (notes (let ((current-parent name))
10032 (import-notes)))
10033 (subsections (let ((current-parent name))
10034 (import-subsections))))
10035 (when (not (equal tag ""))
10036 (scholium 'Tag-to-Name-converter
10037 (add-to-or-start-list
10038 (scholium-text (get-article
10039 'Tag-to-Name-converter))
10040 `(,tag . ,name))))
10041 (scholium name
10042 `(,@notes
10043 ,@subsections)
10044 '((section parent))
10045 '(section label))))
10046 (goto-char (point-max))
10047 (search-backward-regexp "^\\\\clearpage")
10048 (scholium "Scholium system backmatter"
10049 (buffer-substring-no-properties (point) (point-max))
10051 '(note))))
10052 \end{lisp}
10054 \begin{notate}{On `import-subsections'}
10055 For each subsection, import any notes and any subsubsections.
10056 notes are imported if they appear before the first subsubsection,
10057 if there is one, or before the end of the subsection, otherwise,
10058 or before the end of the section, if this is the last subsection
10059 \end{notate}
10061 \begin{lisp}
10062 (defun import-subsections ()
10063 (let (subsections)
10064 (while (re-search-forward
10065 (concat
10066 "^\\\\subsection{\\([^}\n]*\\)}"
10067 "\\( +\\\\label{\\)?"
10068 "\\([^}\n]*\\)?")
10069 section-end t)
10070 (let* ((name (match-string-no-properties 1))
10071 (tag (match-string-no-properties 3))
10072 (subsection-end (or (save-excursion
10073 (search-forward-regexp
10074 "^\\\\subsection{.*"
10075 section-end t))
10076 section-end))
10077 (notes-end (or (save-excursion
10078 (search-forward-regexp
10079 "^\\\\subsubsection{.*"
10080 subsection-end t))
10081 subsection-end
10082 section-end))
10083 (notes (let ((current-parent name))
10084 (import-notes)))
10085 (subsubsections (let ((current-parent name))
10086 (import-subsubsections))))
10087 (when (not (equal tag ""))
10088 (scholium 'Tag-to-Name-converter
10089 (add-to-or-start-list
10090 (scholium-text (get-article
10091 'Tag-to-Name-converter))
10092 `(,tag . ,name))))
10093 (scholium name
10094 `(,@notes
10095 ,@subsubsections)
10096 `((,current-parent parent))
10097 '(subsection label))
10098 (setq subsections
10099 (append subsections (list name)))))
10100 subsections))
10101 \end{lisp}
10103 \begin{notate}{On `import-subsubsections'}
10104 For each subsubsection, import any notes that appear before
10105 the end of the subsubsection (if this is the last subsection,
10106 then before the end of the subsection, etc.).
10107 \end{notate}
10109 \begin{lisp}
10110 (defun import-subsubsections ()
10111 (let (subsubsections)
10112 (while (re-search-forward
10113 (concat
10114 "^\\\\subsubsection{\\([^}\n]*\\)}"
10115 "\\( +\\\\label{\\)?"
10116 "\\([^}\n]*\\)?")
10117 subsection-end t)
10118 (let* ((name (match-string-no-properties 1))
10119 (tag (match-string-no-properties 3))
10120 (notes-end (or (save-excursion
10121 (search-forward-regexp
10122 "^\\\\subsubsection{.*"
10123 subsection-end t))
10124 subsection-end
10125 section-end))
10126 (notes (let ((current-parent name))
10127 (import-notes))))
10128 (when (not (equal tag ""))
10129 (scholium 'Tag-to-Name-converter
10130 (add-to-or-start-list
10131 (scholium-text (get-article
10132 'Tag-to-Name-converter))
10133 `(,tag . ,name))))
10134 (scholium name
10135 notes
10136 `((,current-parent parent))
10137 `(subsubsection label))
10138 (setq subsubsections
10139 (append subsubsections (list name)))))
10140 subsubsections))
10141 \end{lisp}
10143 \begin{notate}{On `import-notes'}
10144 This imports the notes at the current level in the
10145 section hierarchy.
10146 \end{notate}
10148 \begin{lisp}
10149 (defun import-notes ()
10150 (let (notes)
10151 (while
10152 (re-search-forward (concat "\\\\begin{notate}"
10153 "{\\([^}\n]*\\)}"
10154 "\\( +\\\\label{\\)?"
10155 "\\([^}\n]*\\)?")
10156 notes-end t)
10157 (let* ((name (match-string-no-properties 1))
10158 (tag (match-string-no-properties 3))
10159 (beg (progn (next-line 1)
10160 (line-beginning-position)))
10161 ;; no need to bound the search for the end, because we
10162 ;; assume that every "notate" environment is actually
10163 ;; closed
10164 (end (progn (search-forward-regexp
10165 "\\\\end{notate}")
10166 (match-beginning 0))))
10167 (when (not (equal tag ""))
10168 (scholium 'Tag-to-Name-converter
10169 (add-to-or-start-list
10170 (scholium-text (get-article
10171 'Tag-to-Name-converter))
10172 `(,tag . ,name))))
10173 (scholium name
10174 (buffer-substring-no-properties beg end)
10175 `((,current-parent parent))
10176 '(note))
10177 (setq notes
10178 (append notes (list name)))
10179 (import-code-continuations)))
10180 notes))
10181 \end{lisp}
10183 \begin{notate}{On `import-code-continuations'}
10184 This runs within the scope of `import-notes', to turn any Lisp chunks
10185 that follow a given Note into scholia attached to that note. (This
10186 won't import the one stand-alone ``verbatim'' environment used in the
10187 code; we could change this function, or include the environment inside
10188 of a Note. Or we could just put the literate programming code into
10189 another file. Minor issue. Also, figure environments would be left
10190 out, except for a small trick, namely including them within
10191 surrounding Notes.) Notice that previous versions of these articles
10192 shouldn't exist at import time, or Lisp sections will be doubled.
10194 The code continuations and the code descriptions wind up being
10195 mutually about one another, which is kind of cute.
10196 \end{notate}
10198 \begin{lisp}
10199 (defun import-code-continuations ()
10200 ;; ugly formatting = latex overrides!
10201 (while (looking-at (concat "\n\n\\\\b" "egin{lisp}"))
10202 (scholium `(code-continuation ,name)
10203 (let ((old-text (scholium-text
10204 (get-article
10205 `(code-continuation ,name))))
10206 (new-text (buffer-substring-no-properties
10207 (progn (next-line 3)
10208 (line-beginning-position))
10209 (progn (search-forward-regexp
10210 (concat "\\\\e" "nd{lisp}"))
10211 (match-beginning 0)))))
10212 (if old-text
10213 (concat old-text "\n" new-text)
10214 new-text))
10215 `(((article ,name)))
10216 'code)
10217 ;; this should add an appropriate link to the article
10218 ;; that this is a code-continuation of.
10219 (let ((article-to-edit (get-article name)))
10220 (scholium (scholium-name article-to-edit)
10221 (scholium-text article-to-edit)
10222 (add-to-or-start-list
10223 (scholium-about article-to-edit)
10224 `(code-continuation (code-continuation ,name)))
10225 (scholium-bookkeeping article-to-edit)))))
10226 \end{lisp}
10228 \begin{notate}{A theoretical issue with code continuations}
10229 I like to think of the notes as being scholia
10230 attached to the code, rather than the code as scholia attached
10231 to the notes. But the way the importing routine is set up,
10232 this relationship is reversed.
10233 \end{notate}
10235 \begin{notate}{Rendering code continuations}
10236 If we know what kind of code is stored in the code continuation
10237 articles, we may want to render it in the appropriate mode. (The use
10238 of connection coloration is disruptive to this kind of display, so
10239 we'd want to use some other mechanism for showing associations, if
10240 these need to be shown. See Note \ref{color-and-style}.)
10241 \end{notate}
10243 \begin{notate}{Identification of notes is slow}
10244 I tried identifying each note with its source region by running
10245 \begin{idea}
10246 (add-to-scholia-property-within-region
10249 `(identifies-with ,name))
10250 \end{idea}
10251 towards the end of `import-notes', but it slowed everything down.
10253 We may be able to get something similar by other means
10254 anyway (Note \ref{alternative-to-identification}).
10255 \end{notate}
10257 \begin{lisp}
10258 (defun browse-scholium-system ()
10259 (interactive)
10260 (import-scholium-system)
10261 (display-article 'section)
10262 (message "You've successfully imported the system!"))
10263 \end{lisp}
10265 \begin{notate}{Finding all articles with code continuations} \label{with-code}
10266 Cf. Note \ref{article-menu-list-articles-matching-predicate}.
10267 \begin{idea}
10268 (article-menu-list-articles-matching-predicate
10269 (lambda (name)
10270 (let ((article (get-article name)))
10271 (and (member-if (lambda (link)
10272 (typedata-includes (cdr link)
10273 'code-continuation))
10274 (scholium-about article))
10275 (typedata-includes (scholium-type article)
10276 'note)))))
10277 \end{idea}
10278 You can then run `listing-to-compilation' to get a new document that
10279 drops all the interstitial chit chat found in this one.
10280 \end{notate}
10282 \begin{notate}{Finding all articles without code continuations} \label{without-code}
10283 For our friends from the liberal arts,
10284 \begin{idea}
10285 (article-menu-list-articles-matching-predicate
10286 (lambda (name)
10287 (let ((article (get-article name)))
10288 (and (not (member-if (lambda (link)
10289 (typedata-includes (cdr link)
10290 'code-continuation))
10291 (scholium-about article)))
10292 (typedata-includes (scholium-type article)
10293 'note)))))
10294 \end{idea}
10296 (Curiously enough, this document currently seems pretty balanced in
10297 that the code plus immediately important documentation takes up just
10298 about the same amount of space as the philosophical musings. Well,
10299 almost as much. And of course those verbatim environments are long.)
10300 \end{notate}
10302 \begin{notate}{Finding all articles with emphasized parenthetical remarks}
10303 Cf. Note \ref{article-menu-list-articles-matching-regexp}. These are
10304 the articles that contain side remarks that should eventually be turned
10305 into scholia.
10306 \begin{idea}
10307 (progn (article-menu-list-articles-matching-regexp "\\\\emph{(")
10308 (listing-to-label "Comments"))
10309 \end{idea}
10310 \end{notate}
10312 \begin{notate}{Exporting LaTeX docs} \label{exporting-latex-docs}
10313 This should give an inverse to importing
10314 \LaTeX\ documents (Note \ref{importing-latex-docs}).
10315 Exporting in one go is a cheap alternative to live updating via
10316 identifications (Section \ref{identification}). Either would
10317 work, but exporting seems a little easier to get going quickly.
10318 (Incidentally, exporting is similar to producing a compilation;
10319 see Section \ref{quick-compilations}.)
10320 \end{notate}
10322 \begin{notate}{On `export-scholium-system'} \label{export-scholium-system}
10323 We use a similar sort of "recursive" style to that used in the import.
10324 First, loop through the sections. These must of course be exported in
10325 their own limited fashion. Then, for each, examine the contents. The
10326 items contained in each section are either subsections or notes. If
10327 the item really is a subsection, then do something similar to what we
10328 did with sections; otherwise, it is a note and we simply export it.
10329 The items at the penultimate level are either subsubsections or notes;
10330 and finally, in the end, the items are all notes.
10332 Note that getting the ``Tag-to-Name-converter'' each time it
10333 is used in the child functions is really sort of excessive,
10334 since it could be found once in the parent. However, things seem
10335 to run fast enough.
10336 \end{notate}
10338 \begin{lisp}
10339 (defun export-scholium-system ()
10340 (set-buffer (get-buffer-create "*Export*"))
10341 (erase-buffer)
10342 (insert (scholium-text (get-article "Scholium system frontmatter")))
10343 (dolist (sect (scholium-text (get-article 'section)))
10344 (export-section sect)
10345 (let ((contents (scholium-text (get-article sect))))
10346 (dolist (item contents)
10347 (let ((current-item (get-article item)))
10348 (if (typedata-includes (scholium-type current-item)
10349 'subsection)
10350 (export-subsection (scholium-name current-item))
10351 (export-note current-item))))))
10352 (insert (scholium-text (get-article "Scholium system backmatter"))))
10353 \end{lisp}
10355 \begin{notate}{Child functions} \label{child-functions}
10356 Notice the sort of interesting use of the words ``child'' and
10357 ``parent'' in Note \ref{export-scholium-system}; this is what comes
10358 of working on section listings most of the day. No reason that I can
10359 think of not to view code this way. Eventually we may want to parse
10360 Lisp functions and annotate them with hierarchies representing this
10361 sort of information.
10362 \end{notate}
10364 \begin{notate}{Stable import/export}
10365 The text, import, and export routines are all adapted to each other
10366 well enough to make it so that the text is stable under importing and
10367 subsequent exporting. We'll have to do more extensive testing to be
10368 sure that it is also behaving properly with regard to intervening
10369 editing operations, but things are currently looking pretty good in
10370 this regard. (But be careful, and back up your work!)
10371 \end{notate}
10373 \begin{notate}{On `export-note'} \label{export-note}
10374 This is for exporting notes. When the note has a code
10375 continuation it also exports that code.
10377 To really work, this is going to have to replace references with
10378 \verb|\refs| and \verb|\refs|. Hopefully we're storing the relevant
10379 information somewhere easily accessible at import time? We should at
10380 very least be able to do the opposite of what is done with
10381 `swap-out-latex-references'.
10383 We essentially need to render the article to know
10384 what the relevant references are (and where they are).
10385 This suggests to me that if we don't want to disrupt the
10386 user's experience of the rendered articles appearing in
10387 the standard display, we should be able to ``beam'' a
10388 rendering to some other buffer and then pick it up from
10389 there. Also, if some references have been generated
10390 that don't correspond to items with tags, we'll have to
10391 accomodate that.
10392 \end{notate}
10394 \begin{lisp}
10395 (defun export-note (note)
10396 (set-buffer (get-buffer "*Export*"))
10397 (let* ((name (scholium-name note))
10398 (tag (car (rassoc name (scholium-text
10399 (get-article
10400 'Tag-to-Name-converter))))))
10401 (insert "\\begin{notate}{" name "}"
10402 (if tag
10403 (concat " \\label{" tag "}\n")
10404 "\n")
10405 (swap-in-latex-references note)
10406 "\\end{notate}\n\n")
10407 (dolist (scholium (mapcar (lambda (backlink)
10408 (get-article (car backlink)))
10409 (get-backlinks name)))
10410 ;; we were missing one function from a list of two in my last
10411 ;; test of exporting, should look into this.
10412 (when (typedata-includes (scholium-type scholium) 'code)
10413 (insert "\\b" "egin{lisp}\n"
10414 (scholium-text scholium)
10415 "\\e" "nd{lisp}\n\n")))))
10416 \end{lisp}
10418 \begin{notate}{On `swap-in-latex-references'} \label{swap-in-latex-references}
10419 Maybe it would be easier if each of the references had
10420 the name of the tag stored locally? This doesn't
10421 seem like it would actually help. The point I guess
10422 is that we don't want to detect the scholia structure
10423 all at once, but rather, zip through and make changes
10424 to each item we encounter, in order. I.e., the endpoints
10425 of the regions that we'll be modifying are always in
10426 transition.
10428 `move-to-next-region-with-scholium' will have to be set up to
10429 return `nil' if there is no next scholium. It would also be
10430 nice if this returned the boundaries of the region to which the
10431 scholium is attached, when there is a scholium, since we're
10432 going to want to do a replacement of the text in that region.
10433 (If it proves more reasonable to use a different function for
10434 this purpose, that would be fine, but this is roughly what it
10435 should do.) Note that `move-to-next-region-with-scholium'
10436 currently works in terms of overlays, which isn't really
10437 right.
10439 After we find the scholia at the start and end of the marked region,
10440 we could check a complicated condition to see if there is a reference
10441 at the beginning and another copy of the same reference at the end.
10442 But for the time being we aren't going to work with this general case
10443 of overlapping references, and we'll just assume one reference per
10444 marked region and get on with things.
10445 \end{notate}
10447 \begin{lisp}
10448 (defun swap-in-latex-references (note)
10449 (save-excursion
10450 (let ((tags-alist (scholium-text (get-article
10451 'Tag-to-Name-converter))))
10452 (display-article (scholium-name note))
10453 (set-buffer (get-buffer "Main Article Display"))
10454 (let ((next-region (move-to-next-region-with-scholium)))
10455 (while next-region
10456 (let ((scholium-property-at-start
10457 (get-text-property (first next-region) 'scholia))
10458 (scholium-property-at-end
10459 (get-text-property (second next-region) 'scholia)))
10460 (let* ((scholium-id (first scholium-property-at-start))
10461 (scholium-name (first scholium-id))
10462 (possible-reference (get-article scholium-name)))
10463 (when (typedata-includes
10464 (scholium-type possible-reference)
10465 'reference)
10466 (let ((scholium-tag
10467 (car (rassoc (reference-to-article
10468 possible-reference)
10469 tags-alist))))
10470 (if scholium-tag
10471 (progn (delete-region (first next-region)
10472 (second next-region))
10473 (goto-char (first next-region))
10474 (insert "\\ref{" scholium-tag "}"))
10475 (let ((new-tag (replace-regexp-in-string
10476 " " "-"
10477 (buffer-substring-no-properties
10478 (first next-region)
10479 (second next-region)))))
10480 (delete-region (first next-region)
10481 (second next-region))
10482 (goto-char (first next-region))
10483 (insert "\\ref{" new-tag "}"))))))
10484 (setq next-region (move-to-next-region-with-scholium)))))
10485 (buffer-substring-no-properties (point-min)
10486 (point-max)))))
10488 (defun export-section (section-name)
10489 (set-buffer (get-buffer "*Export*"))
10490 (let* ((tag (car (rassoc section-name (scholium-text
10491 (get-article
10492 'Tag-to-Name-converter))))))
10493 (insert "\\section{" section-name "}"
10494 (if tag
10495 (concat " \\label{" tag "}\n\n")
10496 "\n\n"))))
10498 (defun export-subsection (subsection-name)
10499 (set-buffer (get-buffer "*Export*"))
10500 (let* ((tag (car (rassoc subsection-name (scholium-text
10501 (get-article
10502 'Tag-to-Name-converter))))))
10503 (insert "\\subsection{" subsection-name "}"
10504 (if tag
10505 (concat " \\label{" tag "}\n\n")
10506 "\n\n")))
10507 (let ((contents (scholium-text current-item)))
10508 (dolist (item contents)
10509 (let ((current-item (get-article item)))
10510 (if (typedata-includes (scholium-type current-item)
10511 'subsubsection)
10512 (export-subsubsection (scholium-name current-item))
10513 (export-note current-item))))))
10515 (defun export-subsubsection (subsubsection-name)
10516 (set-buffer (get-buffer "*Export*"))
10517 (let* ((tag (car (rassoc subsubsection-name (scholium-text
10518 (get-article
10519 'Tag-to-Name-converter))))))
10520 (insert "\\subsubsection{" subsubsection-name "}"
10521 (if tag
10522 (concat " \\label{" tag "}\n\n")
10523 "\n\n")))
10524 (let ((contents (scholium-text current-item)))
10526 (dolist (item contents)
10527 (let ((current-item (get-article item)))
10528 (export-note current-item)))))
10529 \end{lisp}
10531 \begin{notate}{Name conflicts}
10532 As we talked about vis a vis namespaces (Note
10533 \ref{labels-and-namespaces}), it would be nice if
10534 we could deal with multiple different things having
10535 the same name, say a Section and a Note, or two
10536 Notes in different sections. A disambiguation page
10537 could be created whenever the ambiguity needed to be
10538 paid attention to.
10539 \end{notate}
10541 \begin{notate}{Revise to support ``function'' type articles} \label{elisp-function-type}
10542 Instead of referring to Notes that describe functions, sometimes
10543 we may prefer to refer to ``function'' articles, which will
10544 include the function and the note that describes it.
10545 \end{notate}
10547 \begin{notate}{Group functions sharing scope}
10548 Objects with type functions could have ``runs
10549 within the scope of this function'' slots. This would facilitate
10550 propagating changes in notation.
10551 \end{notate}
10553 \begin{notate}{Other features for function articles}
10554 As top-level objects, functions could be fitted
10555 out with their own fora and FAQ's. They could be
10556 displayed with the appropriate mode turned on
10557 by default.
10559 A short document containing only the functions that
10560 one had been working on recently could be created easily;
10561 see Note \ref{making-a-compilation} and Note \ref{recent-referents}.
10562 \end{notate}
10564 \subsection{On-the-fly scholium creation} \label{otf}
10566 \begin{notate}{Why on-the-fly?}
10567 This section is about creating scholia automatically. For example,
10568 every time I type ``scholium system'', maybe something happens -- for
10569 instance, maybe the text gets marked up with a reference to some other
10570 object describing the scholium system. This is sort of like what
10571 happens in No\"osphere, though there, auto-linking happens when the
10572 document is rendered.
10574 Another similar thing is the auto-indexing feature present in Apple
10575 Computer, Inc.'s latest OS, wherein content is automatically indexed
10576 as it is being created. We could do something fairly similar with the
10577 scholium system (and some of this indexed information could be shared
10578 with other collaborators whenever there are multiple people using the
10579 scholium system together).
10581 Another example use would be to display interesting feedback about
10582 things you had just typed -- maybe related definitions or phrases,
10583 or some other cool stuff. Doing this on an automatic on the fly
10584 basis is a minor simplification (from the user's point of view)
10585 over doing it only when the user issues an explicit command.
10587 Obviously you don't want to search every editspace. For example,
10588 displaying a \emph{definition} as a scholium means that you would
10589 probably just want to search the dictionary namespace. This is
10590 \emph{not} the same as creating a scholium, indeed, the dictionary may
10591 not ``really'' contain scholia at all; you can use the structure of
10592 the dictionary to easily retrieve information that you would like to
10593 superimpose on the current document. (This is a somewhat traditional
10594 sounding digital libraries sort of thing.)
10595 \end{notate}
10597 \begin{notate}{Compare flyspell}
10598 Some good ideas might be available in the flyspell package for Emacs.
10599 \end{notate}
10601 \begin{notate}{Automatically adding files to the article list}
10602 We can also set things up so that visited files are added to the
10603 article list automatically, etc.
10604 \end{notate}
10606 \begin{notate}{Lexical autolinking}
10607 One major application of this system would be to create
10608 No\"osphere-like autolinking. Thus, part of this ``experiment'' is to
10609 reimplement autolinking in this model. Note, that once you have
10610 implemented linking within the model, then autolinking should probably
10611 be ``easy'' to add by reimplementing the No\"osphere algorithm. One
10612 advantage of doing things this way is that links appear at edit time
10613 rather than render time (presumably anyway), which means that they can
10614 be tinkered with right away as needed.
10616 I wonder if the autolinker could be used to make an index of terms
10617 automatically, too? Seems likely.
10618 \end{notate}
10620 \subsection{Simulating a wiki with the scholium system} \label{wiki}
10622 \begin{notate}{Build scholia by first adding markup and then parsing}
10623 The idea in this section is to assemble a collection of scholia that
10624 simulate the page-reference markup found in a wiki. The strategy we
10625 use is to read the wiki page and add \emph{text properties} to the
10626 ``alt text'' indicating the link targets. We then parse the buffer
10627 and create scholia about the regions that bear text properties. The
10628 reason for going through this two-step process is that the position of
10629 text in the buffer will be shifting around as we get rid of wiki
10630 markup, so it is convenient to add scholium system markup in a format
10631 that in invariant under such shifting. To the extent that we need to
10632 specify \inp{type} data, we overload the \inp{name} data that we use
10633 for initial markup. For example, ``(external-page <page-name>
10634 <URL>)'' is the format we'd choose as the \inp{name} of scholia
10635 representing references to external pages.
10636 \end{notate}
10638 \begin{notate}{On `mark-up-wiki-with-reference-scholia'}
10639 Find things in double brackets, possibly with an intervening ``|'',
10640 making sure to find the minimal double bracket pair. What
10641 \emph{should} happen (though the current draft is a bit different) is:
10642 a reference scholium should be created for each reference, and stuck into the
10643 article list in some appropriate place (presumably the namespace
10644 associated with the article in question, more specifically, on some
10645 specific reference subspace of that space). \emph{Then} when someone goes
10646 to render the document in question, we grab the references out of their
10647 storage facility and mark up the document with text properties.
10648 (The current implementation is really just a regexp check...)
10649 \end{notate}
10651 \begin{lisp}
10652 (defun mark-up-wiki-with-reference-scholia ()
10653 (save-excursion
10654 (goto-char (point-min))
10655 (while (re-search-forward
10656 ;; we could probably get all types of reference in
10657 ;; one regexp. I'm not sure why the old
10658 ;; version for grabbing external references was deleted,
10659 ;; but it is featured in the Sept 4 printout.
10660 "\\[\\[\\([^]|\n]+\\)\\(|\\)?\\([^]]+?\\)?]]" nil t)
10661 (replace-match (propertize (or (match-string 3)
10662 (match-string 1))
10663 'scholia
10664 "Reference")))))
10665 \end{lisp}
10667 \begin{notate}{Recent changes and recent referents} \label{recent-referents}
10668 It would be handy to have some code that would list the articles that
10669 have had new scholia written about them. This would help a user (e.g.
10670 the author of the articles under discussion) see what people are
10671 talking about. Some additional semantics could be provided, to list
10672 recent modified versions, which are similar to document changes, but
10673 arguably more relevant in a system with object ownership. Actual
10674 changes should be listed too.
10675 \end{notate}
10677 \begin{notate}{Handling references}
10678 (1) Do special markup;
10679 (2) What is the format of a reference precisely?;
10680 (3) Do they have backlinks?;
10681 (4) Notice that they will probably need to have a special markup
10682 property associated with them (instead of the typical `scholia'
10683 property);
10684 (5) Note that we might want to record all the references associated with
10685 a given buffer on its metadata article, as well as on the full list
10686 of articles and a `reference' label (unless we were to just make a reference
10687 namespace).
10688 \end{notate}
10690 \begin{notate}{Strikethrough}
10691 One of the most important things you can do with a wiki
10692 is to delete things that other people have written.
10693 Showing ``deletion'' as a sort of scholium would be
10694 a handy feature for a wiki modeling experiment.
10695 \end{notate}
10697 \begin{notate}{Delete/insert patches}
10698 Note that patches that delete or insert changes are something like
10699 ``quoted'' changes to files; i.e., as opposed to the ``direct''
10700 changes that occur when editing.
10701 \end{notate}
10703 \subsection{Using the scholium system to do AI stuff} \label{AI-stuff}
10705 \begin{notate}{Take an example from a known system}
10706 It would be a good idea to find at least one example from a ``standard
10707 AI'' system (KM's chemistry-problem solving, for example) and import
10708 and otherwise emulate it in the system here. We'll have to look
10709 around for a good example.
10710 \end{notate}
10712 \subsection{Using the scholium system for HDM things} \label{HDM-things}
10714 \begin{notate}{What is HDM and how does it relate to the scholium system?}
10715 The HDM (expanded: Hyperreal Dictionary of Mathematics) project is
10716 about \emph{taking the world's mathematical knowledge, and getting it
10717 into a format that is as useful as possible.}
10719 The key point to make here is that HDM will be a free culture artifact
10720 containing lots and lots of mathematical information (definitions,
10721 theorems, proofs, expositions, examples, and excursions, etc.) that
10722 will need to be organized for use by both individual humans and
10723 networks of machines. The scholium system is part of the HDM project
10724 because of these organizational needs -- \emph{and} (in particular) it
10725 is being designed in such a way that it should be able to satisfy the
10726 ``AI needs'' of the project.
10728 The revolution will be computerized -- and it will be total.
10729 \end{notate}
10731 \begin{notate}{Application of the scholium principle for HDM}
10732 We should talk about encoding different types of objects in the system
10733 and showing their relationships using typed links; also about
10734 assembling reports via transclusion, and so on and so forth. We
10735 should also show how this system can be used as a stand-in for more
10736 ``traditional'' KRR systems (SNePs, KM), and how reasoning modules can
10737 be implemented for the system. But this is pretty advanced stuff, and
10738 it is going to be a little while until we get to it.
10740 In the mean time, we have various fun things (a little music and even
10741 less Go), and we can think about the relationships to Dirk Gently and
10742 so on and so forth.
10743 \end{notate}
10745 \begin{notate}{Template utilities as an example}
10746 Ray was working on a set of template utilities that could be encoded
10747 as a scholium-based document.
10748 \end{notate}
10750 \begin{notate}{Overview of Arxana as an example}
10751 It might be nice to create a simplified version of the current
10752 document that would deal with the core functions and ideas only. This
10753 would presumably help people learn how to work with the system.
10754 \end{notate}
10756 \subsubsection{Managing the contents of a mathematical dictionary}
10758 \begin{notate}{Importing the APM-$Xi$}
10759 See \ref{import-apmxi} (currently the main function in this section,
10760 although we may come up with some additional functions later on).
10761 Actually, we should probably also import the APM, however, I'm not
10762 completely sure I can get copyright waivers for the APM's content. I
10763 hope so; I should investigate that. If I can get written permission,
10764 then I suppose we should put APM into the HDM's archive along with
10765 APM-$\Xi$.
10766 \end{notate}
10768 \begin{notate}{Large-scale structure of APM and APM-$\Xi$}
10769 We have some words and phrases. These phrases come up in the APM in
10770 various places. Each phrase has a list of problems that it is
10771 associated with. It also has a list of definitions that it is
10772 associated with. For APM, we would want the relevant definitions to
10773 appear as attached scholia. For APM-$\Xi$, we presumably want a
10774 namespace for each phrase, into which we put each of the definitions
10775 as its own article, together with the specially-designated list of
10776 associated problems. Here it seems like we have the opportunity to
10777 use links with different types. (Maybe we would just attach the list
10778 of associated problems to the namespace as a whole.) To parse the
10779 document this far, the first thing to do is to break it into sections,
10780 then parse each of these sections into lists of problems.
10781 \end{notate}
10783 \begin{notate}{Types for the APM-$\Xi$}
10784 We keep track of the sections, entries, and stubs that belong to
10785 APM-$\Xi$ as special types.
10786 \end{notate}
10788 \begin{lisp}
10789 (add-to-list 'modified-type-labels '(apmxi-section . apmxi-section) t)
10790 (add-to-list 'modified-type-labels '(apmxi-entry . apmxi-entry) t)
10791 (add-to-list 'modified-type-labels '(apmxi-stub . apmxi-stub) t)
10792 \end{lisp}
10794 \begin{notate}{On `make-apmxi-sections-into-articles'}
10795 This function makes every section in the APM-$\Xi$ into its own
10796 article. The list of these articles is recorded on the article
10797 `apmxi-section'.
10798 \end{notate}
10800 \begin{lisp}
10801 (defun make-apmxi-sections-into-articles ()
10802 (save-window-excursion
10803 (find-file "../p2/Xi.tex")
10804 (goto-char (point-min))
10805 (while (re-search-forward "^\\\\section{{ \\(.+\\)}} " nil t)
10806 (let ((article-name (match-string-no-properties 1))
10807 (beg (point))
10808 (end (save-excursion (search-forward "\\section" nil t)
10809 (match-beginning 0))))
10810 (when end
10811 (scholium article-name
10812 (buffer-substring-no-properties beg end)
10814 'apmxi-section))))))
10815 \end{lisp}
10817 \begin{notate}{On `chunk-out-apmxi-definitions'} \label{chunk-out-apmxi-definitions}
10818 Apparently some of the terms in APM-$\Xi$ were defined in multiple
10819 sections. At least, \emph{stubs} appear in multiple places. This
10820 should presumably create multiple definitions when multiple
10821 definitions are given, or get rid of stub-like definitions, or
10822 something.
10824 Note that the way this is set up, even sections that contain only
10825 stubs can also contain references to the real articles, when they
10826 exist -- this means that the real articles may appear in several
10827 listings, which I think is as it should be.
10828 \end{notate}
10830 \begin{lisp}
10831 (defun chunk-out-apmxi-definitions ()
10832 (map-label (lambda (name)
10833 (with-temp-buffer
10834 ;; this ensures that sexps are defined properly
10835 (latex-mode)
10836 (let ((topic (get-article name))
10837 contents)
10838 (insert (scholium-text topic))
10839 (goto-char (point-min))
10840 (while (re-search-forward "^(" nil t)
10841 (let* ((beg (match-beginning 0))
10842 (title-beg (match-end 0))
10843 (title-end (progn (goto-char beg)
10844 (forward-sexp)
10845 (1- (point))))
10846 (stub-p (looking-at " *$"))
10847 (title (buffer-substring-no-properties
10848 title-beg
10849 title-end))
10850 (end (save-excursion
10851 (search-forward-regexp "^$")))
10852 (possible-previous (get-article title)))
10853 (when (or (not possible-previous)
10854 (typedata-includes (scholium-type
10855 possible-previous)
10856 'apmxi-stub))
10857 (scholium title
10858 (buffer-substring-no-properties
10860 end)
10861 `((,name parent))
10862 (if stub-p
10863 '(apmxi-stub apmxi-entry)
10864 'apmxi-entry)))
10865 (setq contents (cons title contents))))
10866 (scholium name
10867 contents
10869 '(apmxi-section label)))))
10870 'apmxi-section))
10871 \end{lisp}
10873 \begin{notate}{On `import-apmxi'} \label{import-apmxi}
10874 This function puts into play all of the other functions developed
10875 above, to fully process the APM-$\Xi$ and get it nicely situated in
10876 the scholium system.
10877 \end{notate}
10879 \begin{lisp}
10880 (defun import-apmxi ()
10881 (make-apmxi-sections-into-articles)
10882 (chunk-out-apmxi-definitions))
10883 \end{lisp}
10885 \begin{notate}{Special reference types} \label{special-reference-types}
10886 In the mathematics domain, would be handy to have ``related to'',
10887 ``depends on'', ``proof of'' and ``prerequisite for understanding''
10888 reference sub-types. It is easy enough to create a subtype -- just
10889 add the secondary category to the \inp{type} variable along with the
10890 ``reference'' datum. Special types of references are one of the key
10891 semantic network-like features of the scholium system (see also Note
10892 \ref{type-creation}). Maybe the reference-creating facility should
10893 provide an optional second argument for specifying reference sub-type.
10894 \end{notate}
10896 \begin{notate}{Selecting all APM-$\Xi$ stubs}
10897 If you want to look at a list of all stubs in the APM-$\Xi$, run this code:
10898 \begin{idea}
10899 (article-menu-list-articles-matching-predicate
10900 (lambda (name)
10901 (when (typedata-includes (scholium-type (get-article name))
10902 'apmxi-stub)
10903 t)))
10904 \end{idea}
10905 (See Note \ref{article-menu-list-articles-matching-predicate}.)
10906 \end{notate}
10908 \begin{notate}{Screening out APM-$\Xi$ stubs} \label{apmxi-stub-processing}
10909 If you want to screen \emph{out} the stubs in the APM-$\Xi$, run
10910 \begin{idea}
10911 (display-difference-of-labels 'apmxi-entry 'apmxi-stub)
10912 \end{idea}
10913 (see Note \ref{display-difference-of-labels}). Of course,
10914 eventually we're going to want to do some more processing
10915 to make the stubs into useful things.
10916 \end{notate}
10918 \subsubsection{Facilitate collaboration between HDM authors}
10920 \begin{notate}{Use a simple scheme}
10921 The collaboration scheme is described in Section
10922 \ref{multiuser-cooperation}. I might try to make that version
10923 ``general'' and in this section implement some ``specifics''.
10924 \end{notate}
10926 \subsection{Model a physical space and its contents} \label{space-model}
10927 \begin{notate}{Holtzermann Kitchen Companion}
10928 I've been thinking that it would be handy to have a full inventory
10929 of the kitchen I share. The inventory, or model, really, could be
10930 shared with the kitchen-mates and it could help us remember where
10931 things go and what needs to happen around the place. More generally,
10932 the idea would be: to help improve communication about goings on in
10933 this shared space.
10934 \end{notate}
10936 \begin{notate}{Typelock} \label{typelock}
10937 In order to talk about the contents of cupboards versus the
10938 refrigerator, for example, the user should be able to specify
10939 a bunch of `(contains A B)' relationships. Both `contains'
10940 and `A' will stay fixed for reasonably long periods of time.
10942 In addition, probably everything that is created in this experiment
10943 should have a {\tt kitchen-element} type (and label). Thus,
10944 we want some sort of typelock at the level of object creation
10945 and link creation. (Indeed, we could probably set things
10946 up so that the links didn't need to be specially-typed, but
10947 rather were just part of some specially-typed scholia.)
10949 A sort of segue away from the main topic: it could be handy
10950 to optionally display all of the `contains' items using the listing
10951 mechanism instead of the standard scholia display.
10952 \end{notate}
10954 \begin{notate}{Case for namespaces}
10955 % Let it not be said that this document contains everything but the
10956 % kitchen sink. Here is the sink.
10957 Both the sink cabinet and the doorless cupboard contain a ``drawerful
10958 of assorted utensils''. Of course, these aren't \emph{the same}
10959 drawers (nor are they the same utensils). We find the same sort of
10960 thing in earlier imports of the scholium system, in which several
10961 sections had ``Further notes'' subsections. As a work-around, all of
10962 these were given distinct names, but subsequently, especially when
10963 working with complexes of formulaic scholia (Note \ref{formulaic}),
10964 that behavior wouldn't be desirable.
10965 \end{notate}
10967 \subsection{Make more physical scholia} \label{more-physical-scholia}
10969 \begin{notate}{Extended rendering}
10970 The scholium-based document idea can be extended outside of the
10971 computer. The examples that are produced this way can help illuminate
10972 and inspire out work. See Note \ref{physical-scholium-system}.
10973 \end{notate}
10975 \begin{notate}{Math paper as gallery tour} \label{math-paper-as-gallery-tour}
10976 We could put pictures from a math paper on the walls of a gallery,
10977 with the space divided up in such a way as to have each wing
10978 correspond to a section of the paper.
10979 \end{notate}
10981 \begin{notate}{Scholia on architectural space}
10982 A generalization of Note \ref{math-paper-as-gallery-tour} is to put
10983 together spaces that incorporate scholia into their surfaces
10984 (graffiti, chalkboards), or into their basic design. Memory spaces
10985 (mnemonic architectures) are spaces with double (or more) meanings,
10986 i.e., multiple sets of scholia on the same space.
10987 \end{notate}
10989 \begin{notate}{The HPDA}
10990 This is a somewhat famous example (among a certain geek crowd) example
10991 of a scholium-based document system. I invented a game that goes
10992 along with it.
10993 \end{notate}
10995 \begin{notate}{Printing things out}
10996 Questions as to the impact and relevance of putting things on paper
10997 continue.
10998 \end{notate}
11000 \begin{notate}{Node-based systems}
11001 Systems like freemind\footnote{{\tt
11002 https://sourceforge.net/projects/freemind }} aren't exactly
11003 ``physical'' in the sense of something you can handle, but they
11004 provide a different sort of view into a document, and views are
11005 physical things. (It seems to that freemind itself only provides
11006 hierarchical views, which isn't particularly pleasant for us. I know
11007 that the KM people had a tool that looked good for more complicated
11008 views, but I'm also pretty sure they didn't want to release this tool
11009 to the public.) Some sort of nice graphical tool could be used to
11010 make a schematic of the scholium system that people might find useful.
11011 \end{notate}
11013 \begin{notate}{Outline management}
11014 In Table \ref{scheme-for-outline-managemnent}, we illustrate
11015 line-numbers 1--5 at left, items a--e at right, together with labels
11016 $\alpha$--$\epsilon$. We envision this outline changing over time,
11017 and references such as \verb|\itemref{|$\alpha$\verb|}| consistently
11018 producing the correct line number. I think \LaTeX\ can already handle
11019 this sort of thing, I just forget how you do it.
11020 \begin{table}
11021 \begin{center}
11022 \begin{tabular}{ll}
11023 1 & a ($\alpha$) \\
11024 2 & \quad b ($\beta$) \\
11025 3 & c ($\gamma$) \\
11026 4 & \quad d ($\delta$) \\
11027 5 & \quad \quad e ($\epsilon$)
11028 \end{tabular}
11029 \end{center}
11030 \caption{A scheme for outline management \label{scheme-for-outline-managemnent}}
11031 \end{table}
11032 \end{notate}
11034 \begin{notate}{Offline usefulness} \label{online-usefulness}
11035 Printed documents are only useful offline; the question as to whether
11036 they are more useful offline than a non-networked computer remains.
11037 Sometimes they will have a certain pragmatic edge, e.g., they allow
11038 one to avoid lugging the computer from place to place. On the other
11039 hand, one typically then must type up one's handwritten comments.
11041 (The problem of integrating interesting documents into Arxana is
11042 present whether or not these documents are physical.)
11043 \end{notate}
11045 \begin{notate}{Getting jobs done in different ways}
11046 Many of the things we talk about in Arxana (and in the HDM project in
11047 general) have to do with finding new ways to get jobs done which we
11048 already can get done in some other way. The hope is that the new ways
11049 of working will allow us to be more efficient or have more fun or that
11050 they will otherwise be beneficial. (It isn't completely clear that
11051 you really do get the same job done if you do it in a different way.)
11052 \end{notate}
11054 \section{Philosophy of the scholium system} \label{philosophy}
11056 \begin{notate}{Code} \label{code}
11057 The concerns mentioned in Note \ref{the-philosophy} are closely
11058 related to the questions and ideas of ``Code and Other Laws of
11059 Cyberspace''\footnote{{\tt http://codebook.jot.com/WikiHome}}.
11060 Cf. Note \ref{consistency-why}.
11062 I'd be interested to know whether pass-by-reference as a basis for
11063 document exchange doesn't provide a final solution to the copyright
11064 problem. OK, almost final; you still need some high-tech system for
11065 managing the references and finally retrieving and operating on
11066 content.
11067 \end{notate}
11069 \begin{notate}{An observation} \label{observation-on-cyberspace}
11070 There is a lot of room in cyberspace.
11071 \end{notate}
11073 \begin{notate}{Definitions of freedom}
11074 In Note \ref{inspirations}, I talk about the importance of user
11075 freedom. I should go into this more. For now, I'll just say that for
11076 me ``user freedom'' in some sense includes the notion of ``user
11077 convenience.'' Why? Because what is \emph{freedom to do} if it
11078 doesn't go along with actual \emph{ability to do}? \emph{Empty!} I
11079 call the basic notion at work here the ``liberties model of freedom.''
11080 (With all due apologies to The Dead Kennedys.)
11082 (Note that the guaranteed freedom to do something that one might
11083 potentially be able to do at some point but can't do just now isn't
11084 empty, it's more like ``half full''.)
11085 \end{notate}
11087 \begin{notate}{``Free culture'' is ambiguous} \label{free-culture}
11088 We should be careful when using this term to make sure it is really
11089 defined properly, something I don't think anyone really has done yet.
11090 I'm not really cool with using terms that aren't defined. But then I
11091 get caught up using the term. So, I'm not sure. I'm guessing that
11092 there is a false dichotomy here similar to the dichotomy between
11093 ``text'' and ``hypertext'' -- in other words, something that could
11094 perhaps be formalized, but which as yet hasn't been (see Note
11095 \ref{hyperstuff}). My sense is that ``free culture'' may be as
11096 ambiguously overloaded a term as ``intellectual property'' (just for
11097 example). And yet, freedom seems to be an important part of a useful
11098 system. We proceed with caution.
11099 \end{notate}
11101 \begin{notate}{``All information is superimposed.''}
11102 Statements are superimposed on an author's perceptions and inner life.
11103 Perceptions are superimposed on the base data of experience (and are a
11104 part of this data). Everything we identify as ``information'' is
11105 superimposed.
11106 \end{notate}
11108 \begin{notate}{What, then is at the bottom?}
11109 Is there a bottom, a ``real'' reality, even if it is an
11110 extra-informational one? Or is reality as we know it a mutually
11111 agreed-upon set of mutually-referential superimposed bits? (And for
11112 that matter, is there a top, and what would \emph{that} look like?)
11113 \end{notate}
11115 \begin{notate}{A possible interpretation of physical scholium systems}
11116 The physical systems of Section \ref{more-physical-scholia} and
11117 elsewhere show that physical systems can ``do'' simulation. Compare
11118 also Alan Moore's ``Supreme'', a fictional character who is somewhat
11119 aware of the effects of being as such, although not \emph{quite} to
11120 the point of being fully cognizant of the fact that he is fictional.
11121 Physical scholium systems are only partially aware of their
11122 computational possibilities (and, mutatis mutandi, computational
11123 systems don't always fully take into account their physical
11124 manifestations, whether concrete or only barely imaginable).
11125 \end{notate}
11127 \begin{notate}{Making things easier to learn}
11128 If subject matter to be learned is embedded in a scholium system,
11129 questions and answers that people have asked already would tend to be
11130 easily accessible and clearly organized. It would also be easy to ask
11131 new questions in the context in which the right people will take
11132 notice.
11133 \end{notate}
11135 \begin{notate}{The extensions of man}
11136 What are the things you can do in a given medium? What can you point
11137 at (indicate)? What sorts of gestures can you make? See Note
11138 \ref{human-and-artificial-intelligence}.
11139 \end{notate}
11141 \begin{notate}{Designing a free code market}
11142 A ``consortium'' of free software supporting companies would be
11143 similar to the scholium model of business and relates to FSB. It is
11144 important to know what is in demand and what the supply and costs are.
11145 \end{notate}
11147 \begin{notate}{Scholia in ``The star's my destination''}
11148 The modifications to the main character's teeth are an example of
11149 actionable scholia. The tattoos are another obvious example, adding
11150 art on top of skin. This makes me think that perhaps the issue of
11151 scholia also comes up in the book by Dumas that this one draws so
11152 heavily upon. The SF book might also be considered to be a sort of
11153 scholium attached to Dumas's ``The Count of Monty Cristo'' (cf. Note
11154 \ref{barkovs-hamlet}).
11155 \end{notate}
11157 \begin{notate}{Anthropogenic change}
11158 Changes effected by humans upon the world might be considered to be
11159 scholia. Changes effected upon ourselves (whether skin-deep or
11160 destiny-changing) could be as well. But this vision of anthropogenic
11161 change is also somewhat \emph{anthrocentric}. Humans are just part of
11162 a much broader world. Our ``will'' and ``agency'' are brought into
11163 question in the context in which ``everything is connected.''
11164 (Compare ``Les Enfants Terrible'' on that one.)
11165 \end{notate}
11167 \begin{notate}{Document closure} \label{closure}
11168 Wittgenstein said that the world is all that is the case. Baudrillard
11169 said that the world is that which can't be exchanged for anything
11170 else. A document that contains references to things outside of itself
11171 is really an article in a larger document.
11172 \end{notate}
11174 \begin{notate}{When is a document finished?}
11175 The question as to what needs to go into a document before the
11176 document is finished has probably been thought about by many authors
11177 and editors in the past. Some things are bound to be off topic,
11178 whereas other things are bound to be completely critical. Some things
11179 are of only peripheral importance.
11180 \end{notate}
11182 \begin{notate}{Different kinds of documents}
11183 Different kinds of documents correspond to different sorts of context
11184 -- spatial, temporal, ideational, etc. (see Note \ref{context}).
11185 Note \ref{container}, Note \ref{thread}, Note \ref{process}, and
11186 Note \ref{collection} talk about several different kinds of
11187 documents. See also Note \ref{displaying-nearby-scholia} for some
11188 further words about different kinds of context.
11189 \end{notate}
11191 \begin{notate}{Document as container} \label{container}
11192 Each document or article contains statements. Sometimes these
11193 statements can be bonafide objects, for example, each section in this
11194 document contains Notes and certain other objects. ``Frames'' and
11195 ``ontologies'' fall into this category (and presumably so does the
11196 notion of ``category''). This model seems particularly well-adapted
11197 to the notion of transclusion (and vice versa), and to the idea of a
11198 document as the expansion of an outline. Comments about the document
11199 as a whole should apply to the containing object (so that in some
11200 cases, comments about the document as a whole come from within, i.e.,
11201 comments need to be contained somewhere; see Note \ref{closure}). If
11202 we set the current document up in the scholium system on public
11203 display (and for public comment), we would probably want to have a
11204 special place for general comments about the article. This relates to
11205 the issue of namespaces and labels (Note
11206 \ref{labels-and-namespaces}).
11207 \end{notate}
11209 \begin{notate}{Document as thread} \label{thread}
11210 Sometimes a document takes you along a linear path through a more
11211 complicated space (see Note
11212 \ref{transclusion-induces-linear-structure} for a description of one
11213 way this can work). Frequently authors don't know where their writing
11214 is going when they start. Franz Kafka and Stephen King are notable
11215 proponents of this style of writing, which is almost the antithesis of
11216 writing from an outline. Whether stitching a specific pattern or
11217 exploring a strange labyrinth, the writer's experience has several
11218 threadlike qualities. When there are many authors, then the metaphor
11219 is more obviously one of weaving many threads. Of course, individual
11220 threads and an overall threadlike quality writing only appear under
11221 certain circumstances. (I wonder what Dijkstra said about writing.
11222 One thing I know is that his thought about writing proofs was that
11223 each step should be made clear; the reader shouldn't be left
11224 guessing.)
11225 \end{notate}
11227 \begin{notate}{Document as process} \label{process}
11228 The view advanced in Note \ref{thread} admits, but does not
11229 necessarily imply, the view of the document as a \emph{process}. A
11230 thread or body of woven threads could exist outside of the process
11231 proper; in this model, the author might follow the thread along to its
11232 conclusion (like a detective ``unraveling'' a mystery). It seems
11233 apparent that a document, whether it is written by one or many authors
11234 is a process, at least until it is ``finished''. Even then, though
11235 the central text becomes fixed, the body of peripheral texts continues
11236 to grow, as the central text is reinterpreted in new contexts.
11238 In order to evolve, documents typically need to interact with the
11239 world somehow. The schedule of interactions could be arbitrary, but
11240 when humans are involved some sort of phasic structure is often
11241 involved too. Laying down the law with some sort of schedule for work
11242 on this document might be something I could make myself do (whether or
11243 not keeping the schedule is also is not yet decided, and could be
11244 interesting to document either way). Personal schedules and
11245 organizational schedules are related. I really don't know what to do
11246 (when things grind to a halt, but I assume it would be a good idea to
11247 do something.
11248 \end{notate}
11250 \begin{notate}{Document as collection} \label{collection}
11251 Maybe the evolution of the desktop that we hear so much about (or the
11252 evolution of email, a la Gmail) is going to carry over to documents as
11253 well. Instead of being organized into sections, documents could just
11254 be miscellaneous collections of notes, which then take on certain
11255 organization through search (or maybe some fancy self-organizing
11256 phenomena) as needed.
11257 \end{notate}
11259 \begin{notate}{Document as ontology} \label{ontology}
11260 Documents typically come in an outline-oriented fashion. The idea of
11261 ``document as ontology'' just expands on the idea of ``document as
11262 container'' and posits some nested containers. I'm not actually sure
11263 what the difference between an ``ontology'' and a set of nested sets
11264 is; my sense is that ontologies will typically also specify
11265 interrelationships beyond just ``is-a''. It would be worth looking
11266 into this more.
11267 \end{notate}
11269 \begin{notate}{Document as simulasm} \label{simulasm}
11270 Eventually when one has abstracted out the author a document takes on
11271 the appearance of an agentless simulation.
11272 \end{notate}
11274 \begin{notate}{Unlimited refactoring}
11275 The system seems to go one level beyond ``refactoring'' to something
11276 more like ``multiple on-the-fly as-needed refactoring.'' Code will
11277 take whatever shape you put it in temporarily; however, these shapes
11278 can also be saved. Maybe this is what refactoring is already about in
11279 sophisticated systems (on a wiki it means something much weaker).
11280 This would be worth investigating.
11281 \end{notate}
11283 \begin{notate}{Assimilating data} \label{assimilating-data}
11284 We learn to map data ``up'' (local) hierarchies. For example, when we
11285 make lists of things to do, we map observations up from a perceptual
11286 space to a potential action space. It is valuable when living and
11287 writing to have good heuristics for figuring out the best level for
11288 observations. (Some should be simple data, some should be containers
11289 for other sorts of data.) This also relates to the issue of text and
11290 code from Note \ref{text-and-code}.
11292 If the document is a process (Note \ref{process}), then it may
11293 sometimes be a ``process of understanding'', or a trace thereof. When
11294 we think about something, we may be thinking in terms of an internal
11295 ``scholia-based document''.
11297 As I've been working on \emph{this} document, various ideas have
11298 occured to me, and they make their way in as marginalia, then as
11299 Notes, and perhaps more expanded or refined.
11301 It would be nice to have a specific reference to something from
11302 ``psychology'' here -- the \emph{On Intelligence} book would work,
11303 even though it could be a better book. Note that the Minsky book
11304 contains similar (but more theoretical) notions.
11306 The idea of ``hooking'' from Note \ref{thought-processes} seems
11307 related -- both with regard to expressing assimilated knowledge by
11308 supplying suitable hooks, and with regard to figuring things out by
11309 hooking them together or hooking them to things that we already know.
11310 \end{notate}
11312 \begin{notate}{Text and code} \label{text-and-code}
11313 What items should be coded up and what should be written about? This
11314 question seems particularly on-topic for a literate program. (See
11315 Note \ref{motto}.) Historically, many thinkers were not able to
11316 write (useful) programs, because there weren't computers to run the
11317 programs on. But algorithms have been being designed for a long time.
11318 If Newton had kept calculus on a completely abstract and philosophical
11319 level, it wouldn't have been useful for computation. On the other
11320 hand, I have very little idea how the phenomenologists could have gone
11321 about coding up their ideas. Even though now, work in knowledge
11322 representation apparently follows in their footsteps. Part of the
11323 issue is that there are different languages for different things.
11324 People frequently work on the ``conceptual'' level, and they need
11325 things to be narrated to them. Programs typically only ``work'', if
11326 they come with some suitable narration, either intrinsic or extrinsic.
11327 The actionable-nonactionable dichotomy may not be so useful (compare
11328 Minsky on dumbbell theories). The notion that things ``evolve'' from
11329 nonactionable to actionable is probably a somewhat misleading, as
11330 appealing as it might be. Sometimes we need to ask: what programs
11331 must be written to understand this question? To paraphrase a
11332 correspondent of mine (Ray Puzio), text and code are like yin and yang
11333 (cf. ``chaos
11334 linguistics''\footnote{{\tt http://www.thing.de/projekte/7:9\%23/chuang\_tzu\_linguistics.html}}?).
11335 Understanding how they relate to one another in more detail would
11336 presumably be quite fruitful.
11337 \end{notate}
11339 \begin{notate}{Hyperstuff} \label{hyperstuff}
11340 Text is (or can be) hypertext; mathematics is just as ``hyperreal'' as
11341 the HDM. But I suppose that with some work towards \emph{formalizing}
11342 a definition the ``hyper'' prefix might give us more than just hype
11343 about a quote-un-quote new technology. (As an example of how these
11344 categories run together, Note
11345 \ref{derivative-works-in-the-scholium-system} contrasts hypertext-like
11346 indices with more text-like compilations.)
11348 Accordingly, you can build an AI out of all sorts of miscellaneous
11349 components. Mathematics is already very AI-like, even though many of
11350 its agents are human beings. It isn't completely clear what the
11351 differences there are between working with systems with more
11352 electronic components and systems with less. Is, or, how is, one set
11353 inherently more powerful, or more risky, or just better for different
11354 things?
11356 Compare Note \ref{physical-scholium-system}.
11357 \end{notate}
11359 \begin{notate}{Not-so-holistic mathematics}
11360 The QA section is typically split into two or three parts, each found
11361 in a separate library. Here in Minnesota, there is the math library,
11362 the math philosophy section in the humanities library, and the
11363 engineering library. It can be somewhat inconvenient and a bit
11364 offputting for people who want to look at math from all of these
11365 perspectives. On the other hand, it frequently makes sense to divide
11366 when resources can't be copied. Note that digital libraries don't
11367 need to be divided in a permanent way; cf. Aaron's Emory paper -- in
11368 both positive and negative senses -- in particular, think about
11369 Google, today's great integrator. Compare Leibnitz on the university
11370 and Minsky on the mind.
11371 \end{notate}
11373 \begin{notate}{Philosophy of intelligent documents}
11374 The main thing to look at here is the Dreyfus and Dreyfus article in
11375 \emph{The Artifical Intelligence Debate}. The ideas in the current
11376 document (e.g. in Note \ref{human-and-artificial-intelligence})
11377 should give some ideas about why there is hope for AI, and why we can
11378 make something that people like to use as we make progress towards
11379 this goal.
11380 \end{notate}
11382 \begin{notate}{Usefulness of bidirectional linking}
11383 When a note contains a link to a section that contains more
11384 information on the topic of that note, this gives the author a way to
11385 have some of this topic spread into different contexts, but also to
11386 have a compressed treatment that reflects all the different ideas
11387 about the given topic in the document as a whole. Bidirectional links
11388 can be used to facilitate this bifurcated style of writing.
11389 \end{notate}
11391 \begin{notate}{Being ``meta''}
11392 One way to be ``meta'' is to loop through some dimension that was
11393 previously held static. Just for example, we might switch from
11394 single-article rendering to multi-article rendering at some point.
11395 \end{notate}
11397 \begin{notate}{Thought processes} \label{thought-processes}
11398 It is interesting how different pieces of information will attach
11399 themselves to a train of thought -- like so many carriages. Or like
11400 the miscellaneous stops on a messenger race.
11402 In such races, there is actually no ``message'' to deliver; rather,
11403 the racers must simply visit several predesignated stops, and
11404 sometimes perform a certain task at each -- like drink a beer, for
11405 instance. Typically these stops can be visited in any order.
11407 Like \emph{post facto} routes, thought process seems to be exploring a
11408 large web-like space -- and only finally getting pulled together into
11409 one narrative thread. Perhaps one unwinds an \emph{Ariadne's thread}
11410 as one explores; and perhaps at each important stop a hook is added,
11411 so that when we get to the ``end'' of the path, we pull the Ariadne's
11412 thread, and the hooked-in items from hither and yon are present before
11413 us, ready in salute.
11415 This business with the Ariadne's thread is pretty amazing, but the
11416 hooks, by contrast, seem pointedly quotidian. They include such drole
11417 things as word-association, metaphor, alliteration, and various other
11418 tropes.
11420 Some thoughts are fleeting and remain between the lines forever (``you
11421 should have seen the one that got away!''). Is this a problem?
11422 Perhaps less so when you are focused (Note \ref{staying-focused}).
11423 \end{notate}
11425 \begin{notate}{Mnemonics}
11426 The fact that humans can often improve their ability to remember
11427 things maybe means that we shouldn't trivialize memory-hooks
11428 too much. Ultimately, however, it seems like we do run into
11429 ``wetware limitations''.
11430 \end{notate}
11432 \begin{notate}{Search}
11433 Being able to search is a very nice feature of the computer
11434 interface. But of course, it is also possible to use
11435 thought processes (Note \ref{thought-processes}) to search.
11436 (If it wasn't, we'd almost surely be utterly screwed.)
11437 \end{notate}
11439 \begin{notate}{Experience}
11440 Experiences give you things to point at or hook to. They are sort of
11441 like pre-computed cases -- you can save time and be secure by knowing
11442 what to do in a given situation in advance. However, our experiences
11443 are almost always (or maybe ``always'') only heuristically applicable.
11445 Scholia, too, are sort of like pre-computed cases; i.e., they document
11446 the experiences of persons who have interacted with a given subject.
11447 \end{notate}
11449 \begin{notate}{Establishing setting}
11450 In filmmaking (and fiction writing), there is a tradition of images
11451 that are only secondarily part of the story per se, but which, rather,
11452 tend to say \emph{where} the story takes place, and to lend it some
11453 realism (or similar quality of substance).
11455 These images are sort of like attached scholia; they could be cut and
11456 the plot would remain. However, we often see films that have been
11457 ``ruined'' by overzealous cutting.
11458 \end{notate}
11460 \begin{notate}{This document as an example of CBPP}
11461 This document will hopefully be CBPP (``for real'', and not just via
11462 the Swift-Minsky societies of my mind). The transition from solo work
11463 to group work is probably almost always rocky, and sometimes even too
11464 off-putting for it to happen at all. However, there are certainly
11465 some steps that can be taken to ease the process along -- it is
11466 possible that having a ``cool'' product helps (some would argue
11467 vehemently that the cool factor is unimportant to the extreme).
11469 Hopefully by trying to make the code and documentation as accessible,
11470 starting with some discussions about the system, moving to discussions
11471 within the system, and from there soliciting code, etc., things will
11472 work out for the current current project.
11473 \end{notate}
11475 \begin{notate}{Freedom, bookmaking, and book-buying}
11476 In my view, part of the idea of paying for copies \emph{should} be
11477 that the copy itself is a work of art. If the copy is simply
11478 something you could run off yourself on your laser printer, it might
11479 not really be worth buying. If it is a limited edition artwork -- and
11480 if the price is right -- then it could be very much worth buying. On
11481 the other hand, if the salient features can be simulated cheaply, then
11482 even the ``unique'' artwork may not be very valuable.
11484 This relates to Section \ref{more-physical-scholia}. The value of
11485 print versions of a document is an interesting psychological question.
11486 Writing marginal notes into a printed document seems to be a perfectly
11487 viable way of building meaning clusters, but it isn't clear whether it
11488 has any specific psychological benefits over writing marginal notes
11489 into a sufficiently robust electronic system.
11490 \end{notate}
11492 \begin{notate}{Staying focused} \label{staying-focused}
11493 In a scholia-based document, it should be somewhat obvious when you
11494 drift off subject or off task. Sometimes the connection between the
11495 ``off subject'' elements of the document and the ``on subject''
11496 elements comes through a ``meta'' sort of connection. For example, I
11497 initially worte this Note as a reminder to myself to stay focused on
11498 the code I'm looking at today, and not to get distracted by too many
11499 peripheral or minor concerns. Even though this Note is peripheral
11500 with regard to the semantic content of the code, hopefully it will have
11501 a salutory ``meta-level'' effect on the coding process.
11502 \end{notate}
11504 \begin{notate}{Hetrarchy} \label{hetrarchy}
11505 If it isn't obvious, a hetrarchy is an example of a scholium-based
11506 document in which the articles are people and the attachment
11507 relationships are given by who is working on whose project. It
11508 shouldn't be too hard to map out these sorts of relationships in a
11509 given CBPP system (like PlanetMath, for example).
11510 \end{notate}
11512 \begin{notate}{Hierarchy} \label{hierarchy}
11513 Of course, a hetrarchy (Note \ref{hetrarchy}) can be viewed as the
11514 joining-together of several hierarchies. It seems helpful to be able
11515 to look at the local hierarchies associated with certain articles.
11516 Who cites who, and who do \emph{they} cite? -- and so on.
11517 \end{notate}
11519 \begin{notate}{Scholia-based digital libraries}
11520 Some of the relationships to Digital Libraries are as follows.
11522 In a physical library, marginalia are considered to be graffiti. In a
11523 digital library, they can easily be ignored, if that is desired. They
11524 are more like sticky notes than they are like true marginalia, but
11525 even more potentiallly-ignorable than these handy-dandy things.
11527 Still, the fact of the matter is that adding scholia to a document
11528 will always change the document's meaning in some sense. However, in
11529 the case of \emph{private} scholia, other people will be in the dark
11530 as to the nature of the change. There is a gradient here; some
11531 scholia. may be ``so public'' that everyone sees them, no matter how
11532 their filters are set. (E.g., the user interface to monolithic
11533 operating systems.)
11535 In a physical library, loud conversation is considered to be
11536 disruptive. In a scholia-based document, it should be possible to
11537 mark conversations with metadata that will make them more or less
11538 private. (Conversations are an example of processes-as-scholia.) In
11539 a typical feedback-forum situation, user feedback isn't actionable.
11540 But of course scholia can be made actionable -- and they need not be
11541 favorable. For example, scholia can be used to vote such-and-such an
11542 item out of the collection.
11543 \end{notate}
11545 \begin{notate}{The system} \label{the-system}
11546 ``The system'' is comprised exactly of the most-public articles.
11547 Every user ``sees'' the system (as filtered through their own
11548 customizations). Freedom of users to make (not-publically-visible)
11549 customizations \emph{ad infinitum} is certainly important. But
11550 questions as to who can change the system itself and
11551 \emph{how} it can be changed seem to be at least as important.
11552 \end{notate}
11554 \begin{notate}{Ontology versus pre-ontology}
11555 Most of the work done so far in this document has been at the
11556 level of pre-ontology; work on the associate ontology or
11557 ontologies can begin before long.
11558 \end{notate}
11560 \begin{notate}{Various free and nonfree cultures}
11561 I still don't know what to say about the license-defined
11562 common versus a managed public domain common commons.
11563 \end{notate}
11565 \begin{notate}{Teamwork}
11566 Building a good team relates to the platform's usability (in both
11567 directions). Is the whole just as good as the sum of its parts?
11568 What's good/bad/indifferent about \emph{informal} teams?
11569 \end{notate}
11571 \begin{notate}{Places to store thoughts}
11572 Places, or spaces, for thoughts can be helpful to have around. File
11573 $X$ under ``experiments'', $Y$ under ``community spirit'' and so on.
11574 As to whether the metaphor of ``file'' works, that's a good question;
11575 labels may be uniformly better to use. Furthermore, just about any
11576 sort of attachment relationship can be used to categorize things;
11577 compare Note \ref{hyperstuff}.
11578 \end{notate}
11580 \begin{notate}{Work ethic}
11581 The achievement of a workable work ethic was supposed to be the big
11582 event in Penmaster's Apprentice issue 2. With regard to this work, it
11583 is interesting to consider the interplay of different work styles:
11584 small and large, physical and computational. We can get very
11585 different sorts of meaning clusters simply by adjusting our
11586 scholia-creation patterns (at least in theory). The (judicious) use
11587 of summaries, critiques, new-found relationships, and so forth, give
11588 an overall feeling to the evolution of a document.
11589 \end{notate}
11591 \begin{notate}{Interpretation}
11592 What is meaningful? In relationships, in activities, and so forth?
11593 In literature, you want to figure out e.g. how to do character
11594 development in a ``meaningful'' way, to create something that people
11595 will want to read (and which they will find meaningful).
11596 \end{notate}
11598 \begin{notate}{Vanity publishing}
11599 One's vanity can at least have the effect of encouraging one to write
11600 and perhaps to do research as well.
11601 \end{notate}
11603 \begin{notate}{Role of philosophy in this document}
11604 Some people have told me that they don't see the point of writing so
11605 much. But code is allegedly supposed to come after design, and design
11606 is supposed to come after you understand the problem. I think on
11607 paper, and code things up as I understand them. By this token,
11608 perhaps eventually we'll see a version of the document in which most
11609 of the philosophy has code associated with it.
11611 One thing to realize (might as well do so at some point) is that this
11612 is more than just a program; it is a philosophy of documents, whence,
11613 maybe even a tentative metaphysics, since what can't be regarded as a
11614 document, after all!, and as making some addition to the philosophy of
11615 (the society of) mind.
11616 \end{notate}
11618 \begin{notate}{Philosophy of dictionaries}
11619 Someone or other said something about defining via every \emph{use}.
11620 Which implies that each definition is a more-than-octopodal sort of
11621 thing, reaching all over the place. Uses can often be partitioned,
11622 and showing this partition only can massively simplify things. It is
11623 interesting to think about the scholium nature of partitions and
11624 representatives of the partitional classes.
11625 \end{notate}
11627 \begin{notate}{Control}
11628 One tends to imagine that the things that one can control are
11629 relatively safe.
11630 \end{notate}
11632 \subsection{Mathematics of the scholium system} \label{mathematics}
11634 \begin{notate}{Document topology}
11635 The conversation about identification of document regions has a very
11636 topological flavor, as does the idea (also mentioned in the paper)
11637 about stitching documents together out of articles attached along
11638 their margins.
11639 \end{notate}
11641 \begin{notate}{Cyberspace geometry}
11642 The ``observation'' mentioned in Note \ref{observation-on-cyberspace}
11643 could presumably be translated -- at least partially -- into a
11644 statement about the hyperbolic geometry of cyberspace. And I think
11645 people have been studying this stuff for a while. However, I think
11646 there is more to the statement than just that.
11647 \end{notate}
11649 \begin{notate}{Region arithmetic}
11650 The notion that regions can be copied, broken apart, deleted, and
11651 added on the fly gives a notion of $*$, $/$, $-$, and $+$ for marked
11652 up regions (and this applies to both text and markup). I don't know
11653 whether much can be made of these things, but they are the fundamental
11654 operations, so perhaps there is something here.
11655 \end{notate}
11657 \begin{notate}{Clusion algebra}
11658 Studying articles and clusions could be an interesting computational
11659 variant on the study of objects and morphisms.
11660 \end{notate}
11662 \begin{notate}{Transclusion linearity}
11663 The fact that transclusions shouldn't be indicated by constant, but
11664 rather, linear, functions, seems cute (but I'm not sure what to make
11665 of it).
11666 \end{notate}
11668 \begin{notate}{Scholium mathematics in general}
11669 I'm particularly reminded of topology (including graph theory) and
11670 ergodic theory. ``Information theory'' seems related to the issues of
11671 updates and versioning; similarly, ``knowledge theory'' may be related
11672 to the issues of multi-directional updating. From there we could move
11673 on to game theory, I suppose, as the mathematical domain most
11674 closely related to culture building (\emph{nomics}
11675 are what I'm thinking of here; these also relate to MUDs).
11677 Economics, more generally, seems to be where things are headed, when
11678 we think about the social welfare situation associated with CBPP
11679 system policies (e.g. rejecting corrections on PlanetMath has no
11680 %% Maybe the open source version would be Franklinstein
11681 repurcussions; if an essay about \emph{Frankenstein} is posted to the
11682 site and the author rejects all corrections which say ``this is not
11683 math!'', the administrators will presumably have to get involved, and
11684 take some extra-protocol action to remove the article).
11686 Other topics that should be taken up are the linguistic and
11687 ``mathematical artificial intelligence'' threads coming from the HDM
11688 project.
11689 \end{notate}
11691 \begin{notate}{Network navigation}
11692 If a scholium-based document is broken up into trees, the document's
11693 underlying network can be linearized simply by ordering the roots of
11694 these trees. This relates to questions about literate programming and
11695 proof checking (how do you write a ``structured proof''?).
11696 \end{notate}
11698 \subsection{Document analysis and the scholium system} \label{document-analysis}
11700 \begin{notate}{Pitfalls of summarization}
11701 It isn't completely clear that Note \ref{the-philosophy} makes a great
11702 summary of the whole of the philosophy of this work. Any summary
11703 leaves things out or is otherwise vague.
11704 \end{notate}
11706 \begin{notate}{Recapitulation}
11707 An article $A$ that appears after some article $B$ in a given ordering
11708 which contains a summary of $B$. This relationship could be indicated
11709 by a link in one direction or another (likely to run from $A$ to $B$).
11710 \end{notate}
11712 \begin{notate}{Discourse analysis and holographic or monadological structures}
11713 Long-range reference and design theory seem related to each other and
11714 to this work as a whole; cf. Section \ref{mathematics}.
11715 \end{notate}
11717 \begin{notate}{Unified semantics}
11718 Nelson (I think) has advertised some kind of unified theory of
11719 semantics; it might be fun to take a look at that.
11720 \end{notate}
11722 \section{Conclusions} \label{conclusions}
11724 \begin{notate}{Original conclusion}
11725 In a context with multiple authors talking about many
11726 intersubjectively important concepts, with ownership of the texts that
11727 they write but freedom with the content, treating the total document
11728 as a collection of scholia could provide important alternative
11729 perspectives on a given subject. The presence of on-screen scholia
11730 could encourage responsible maintainership and aid users in making
11731 specific comments and suggestions part of their critical reviews of
11732 existing entries.
11733 \end{notate}
11735 \begin{notate}{Difficulty of putting things together}
11736 Technological difficulties are posed by the fact that a document must
11737 be assembled out of several pieces for presentation purposes and the
11738 fact that standard web browsers and editors may not be very useful for
11739 browsing or creating these sorts of documents. (This isn't
11740 \emph{always} a difficulty; rather, it motivates the current
11741 development effort!) Compare the message on the outside of the
11742 Walker (Figure \ref{author-as-scholium}).
11744 And: why didn't we see something like this document before? Why
11745 haven't the systems on the Hyperworlds server become ``popular''? I'm
11746 not completely sure; there are probably a number of interrelated
11747 reasons.
11748 \end{notate}
11750 \begin{notate}{Freedom in an online context}
11751 Another very important thing to talk about is free versus non-free web
11752 services. I'm not sure if we mean to completely \emph{skewer}
11753 non-free systems, i.e., systems that don't have a collaborative free
11754 scholia-based compenent to them. But on the other hand, such systems
11755 really may be much less useful. The current model is basically: if
11756 you want to create some commentary on something else, you need to find
11757 your own platform/soapbox from which to make that commentary. Some
11758 systems, like PM's attached fora, invite commentary and provide a
11759 place for it. But many, many, pages out there do not invite
11760 commentary or simply do not supply a place to put it. Another thing
11761 to notice about the scholia-based system is that it is very
11762 egalitarian. Just because something was ``there first'' doesn't make
11763 it better. The commentary can become just as important as the main
11764 document, or more important. On the other hand, it would be very
11765 useful to develop some algorithms that can be used to sort out the
11766 useful commentary from the utter crap. Slashdot does a pretty good
11767 job of this, but I think there is still room for improvement. And,
11768 even though PM provides attached fora, they could do a significantly
11769 better job of exposing the content that is provided in those fora in
11770 the ``default view'' or some ``secondary view'' of the object that is
11771 being commented on. It might just take something simple, like
11772 expanding all of the threads, or possibly using some Slashdot-like
11773 rating system to expand notable threads. Both interactive and
11774 automatic ways of determining the usefulness of certain feedback can
11775 be used -- and there are already some things like this in Gnus (I'm
11776 sure).
11777 \end{notate}
11779 \begin{notate}{Knowledge communities}
11780 It would also be good to talk about Ray's comments about knowledge
11781 communities -- need to take another look at those again. Also,
11782 referring to other Ray stuff, I wonder what conditions would be
11783 necessary for academics to accept more off-the-beaten-track
11784 publications (e.g. PlanetMath). Of course, if these things became
11785 popular they wouldn't be off-the-beaten-track any more, really, but
11786 let's not get circular. My sense is that making some sort of medium
11787 ``respectable'' has to do with the social contract thing. On the
11788 other hand, people do seem to get respect for out-there stuff if it is
11789 somehow novel, or useful, or \emph{something}. (Not sure what the
11790 relevant quality here is, how much ``uptake'' has to do with it, how
11791 much ``propaganda'' (or ``PR'') or what -- if I knew maybe I'd try to
11792 exploit this knowledge!)
11793 \end{notate}
11795 \begin{notate}{Social simplicity}
11796 Sometimes complexity may not be totally avoidable within the code.
11797 (E.g. if there are 1 billion scholia about a given article, sorting
11798 them would take a long time.) Sometimes we can do clever things --
11799 but other times we can probably rely on the user groups to structure
11800 things in ways that won't push things too far. It isn't clear how
11801 much we can rely on them for this -- but my guess is that things that
11802 the machine would whine about are frequently going things that people
11803 want to avoid for their own reasons.
11804 \end{notate}
11806 \begin{notate}{Human and artificial intelligence} \label{human-and-artificial-intelligence}
11807 The HDM project may be better off building something that smart people
11808 can hack than building smart code right away. Perhaps that's why I'm
11809 giving precedence to the scholium system over things like parsers and
11810 the like. The ``human element'' in software development seems
11811 powerful. It is curious that I've envisioned the scholium system as
11812 being mainly about the AI component of HDM; but it may be that we can
11813 expect more from it, namely, a contribution to AI for HDM creation.
11814 Take a look at Note \ref{text-and-code} for some words against
11815 thinking about things in terms of ``evolution towards actionable
11816 form.'' I think a better argument would be for \emph{co-evolution}
11817 (which is good, because there has been plenty of thinking done on this
11818 issue). SNePs seems to have some things to say on this
11819 topic\footnote{{\tt
11820 http://www.cse.buffalo.edu/sneps/snerg.prospectus/node19.html}}.
11821 Presumably so do others; still, by contrast with many other systems,
11822 the co-evolution view seems to be emphasized particularly strongly
11823 here.
11824 \end{notate}
11826 \begin{notate}{Labels vs namespaces, transclusion vs inclusion, overlays vs text properties}
11827 It is interesting to compare the ``hard'' to the ``soft'' approaches,
11828 both of which appear in this document in different roles (sometimes in
11829 interestingly similar relationships to one another).
11830 \end{notate}
11832 \begin{notate}{Compatibility between versions of this system?}
11833 All else equal, it would be nice for any future versions of this
11834 system to be compatible with this one. But we can make no guarantees
11835 that this will actually happen, although I do think that the system
11836 will be revised somewhat to continue to make improvements and add new
11837 features.
11838 \end{notate}
11840 \begin{notate}{Future work}
11841 It would be pleasant to have Arxana hooked up with a graphical
11842 node/edge display, such as fenfire\footnote{{\tt http://fenfire.org}}.
11843 Building rich displays is a problem that we'll want to consider from
11844 many angles (cf. Note \ref{large-form}). The usefulness of getting
11845 various tools worked out in plain-text modes shouldn't be ignored!
11846 \end{notate}
11848 \begin{notate}{Getting work done on Arxana}
11849 We mentioned one strategic point, that of collaborating early on, in
11850 Note \ref{collaborate-early}. There are probably other things I
11851 should be doing that would enhance my ability to get things done with
11852 this system. Productivity is a topic that should be studied more.
11853 Working a lot, trying to check concrete usefulness or applicability a
11854 lot, maintaining a strategic plan -- these all seem like good ideas.
11855 \end{notate}
11857 \appendix
11859 \section{Appendix: A simple literate programming system} \label{appendix-lit}
11861 \begin{notate}{The literate programming system used in this paper}
11862 The point of this code is to grab all the Lisp sections
11863 of this document and evaluate them. It requires that
11864 the \LaTeX\ be written in a certain consistent way, with
11865 all of the code in a certain kind of environment. That
11866 is all it does and all it requires.
11868 \begin{verbatim}
11869 (defvar lit-code-beginning-regexp "^\\\\begin{lisp}")
11870 (defvar lit-code-end-regexp "^\\\\end{lisp}")
11871 (defvar lit-count 0)
11873 (defun lit-eval ()
11874 (interactive)
11875 (lit-process 'eval))
11877 (defun lit-process (&optional code)
11878 (interactive)
11879 (setq lit-count (1+ lit-count))
11880 (save-excursion
11881 (let ((to-buffer (concat "*Lit Code " (int-to-string
11882 lit-count)"*"))
11883 (from-buffer (buffer-name (current-buffer))))
11884 (set-buffer (get-buffer-create to-buffer))
11885 (erase-buffer)
11886 (set-buffer (get-buffer-create from-buffer))
11887 (goto-char (point-min))
11888 (while (re-search-forward
11889 lit-code-beginning-regexp nil t)
11890 (let* ((beg (match-end 0))
11891 (end (save-excursion
11892 (search-forward-regexp
11893 lit-code-end-regexp nil t)
11894 (match-beginning 0)))
11895 (match (buffer-substring beg end)))
11896 (save-excursion
11897 (set-buffer to-buffer)
11898 (insert match))))
11899 (case code
11900 ('eval
11901 (set-buffer to-buffer)
11902 (eval-buffer)
11903 (kill-buffer (current-buffer)))
11905 (switch-to-buffer to-buffer))))))
11907 (defun lit-require (feature)
11908 (let* ((basename (symbol-name 'scholium-preliminaries))
11909 (name (concat basename ".tex"))
11910 (livep (buffer-live-p name)))
11911 (save-excursion
11912 (if livep
11913 (set-buffer name)
11914 (find-file name))
11915 (lit-eval)
11916 (unless livep
11917 (kill-buffer (current-buffer))))))
11918 \end{verbatim}
11919 \end{notate}
11921 \begin{notate}{Another way}
11922 This code could go into a stand-alone file. This would
11923 make it somewhat more reuseable, at the cost of making
11924 the current document somewhat less self-contained.
11925 Since I seem to like writing literate programs, making
11926 the code reusable probably wins out.
11927 \end{notate}
11929 \begin{notate}{Adding docstrings at deliteration time}
11930 It might be adventageous to have some way to add docstrings to
11931 functions that have been literately documented when the literate
11932 documentation is stripped out, before the functions are evalled.
11933 \end{notate}
11935 \begin{notate}{Split into sections}
11936 It might be handy to have the code that evaluates
11937 this file split it into several separate files, or
11938 to provide an option for doing this in the ancillary
11939 elisp file.
11940 \end{notate}
11942 \begin{notate}{LaTeX verbatim environments}
11943 The only thing you can't put into a verbatim environment is the text
11944 ``\verb|\end{verbatim}|'' $\ddot{\smile}$. See Note
11945 \ref{principle-of-transparency}.
11946 \end{notate}
11948 \section{Appendix: Overview of specifications} \label{appendix-specs}
11950 \begin{notate}{A quick guide for the theoretically minded}
11951 This section will contain an overview of the specifications of
11952 \emph{this} scholium system, which, I think should help people who
11953 want to hack on it, or who want to create \emph{other} scholium
11954 systems. The full theory is found in the main document, of course;
11955 this section serves to remind the reader of points that are dealt with
11956 in greater detail there.
11957 \end{notate}
11959 \begin{notate}{Spec for article}
11960 An article is an element of some namespace, by default,
11961 the main article-table (a hash table).
11962 It takes the form of a quintuplet,
11963 \begin{idea}
11964 (name text about type bookkeeping)
11965 \end{idea}
11966 where, when stored in the hash table, \inp{name} is used
11967 as the key. (See Note \ref{structure-of-articles}.)
11968 \end{notate}
11970 \begin{notate}{Spec for about data}
11971 About data in articles takes the form of a list of \emph{links}. (See
11972 Note \ref{format-of-about-field}.)
11973 \end{notate}
11975 \begin{notate}{Spec for link}
11976 Each link takes the form
11977 \begin{idea}
11978 (<target article's name> &rest <link-types>)
11979 \end{idea}
11980 The design here maintains partial symmetry between the treatment of
11981 article types and link types; the cdr of a link can be processed
11982 by the same typedata processing functions as the \inp{type}
11983 data from articles. (See Note \ref{links}.)
11984 \end{notate}
11986 \begin{notate}{Spec for type data}
11987 A type can be a single token specifying a type or a list of types.
11988 Types can, themselves, come with additional data; in which case they
11989 take the form of a list, where the car gives the type's name, and the
11990 cdr carries all additional specifics.
11991 \end{notate}
11993 \begin{notate}{Spec for metadata article}
11994 An article $A$ has metadata article $\tilde{A}$ whose
11995 \inp{name} is
11996 \begin{idea}
11997 (meta <name of A>)
11998 \end{idea}
11999 The \inp{text} of a metadata article takes the form of a list of
12000 lists, with each sub-list headed by a tag naming the contents of that
12001 sub-list. The \inp{about} data is `nil', the \inp{type} is `meta',
12002 and the bookkeeping data is `system'. (See Note
12003 \ref{metadata-article-design}.)
12004 \end{notate}
12006 \begin{notate}{Spec for backlink}
12007 An article's backlinks are stored on the `backlink' field of its
12008 metadata article. An individual backlink
12009 takes the form
12010 \begin{idea}
12011 (<name> <link number> [<version number>])
12012 \end{idea}
12013 where ``name'' is the name of the article being backlinked, and
12014 link number indicates the particular link to which this backlink
12015 corresponds. The optional version number is used if the backlink
12016 corresponds to a specific version of the linking article other
12017 than the most current one.
12018 (See Note \ref{implementation-of-backlinks}.)
12019 \end{notate}
12021 \begin{notate}{Spec for link-id}
12022 The purpose of a link-id is to specify a link when marking up a piece
12023 of text with a text property corresponding to a scholium, namely the
12024 link through with that region was indicated (see Note
12025 \ref{the-scholia-property}; the `scholia' text property contains a
12026 list of link-ids.).
12028 The format of a link-id is
12029 \begin{idea}
12030 (<name> <link number>)
12031 \end{idea}
12033 Notice that link-id's also come up in the context of masks and other
12034 places. They are a sort of idiom used in several places in the work
12035 (as you can easily see by looking around at the specs shown in this
12036 appendix). One thing to notice is that the ``usable about data'' of
12037 Note \ref{compute-usable-about-data} \emph{et seq.} leads up to markup
12038 fairly directly, and, in particular, that it computes markup by
12039 applying masks to links as needed. So, it is no wonder that there is
12040 some continuity between these various parts of the system; and, in
12041 particular, the fact that link-id's are a part of that continuity
12042 makes sense.
12043 \end{notate}
12045 \begin{notate}{Spec for mask} \label{spec-for-mask}
12046 An article's masks are stored in the `masks' field of its metadata
12047 article. An individual mask takes the form
12048 \begin{idea}
12049 ((<name> <link number>) &rest regions)
12050 \end{idea}
12051 The regions are two-element lists, each giving the beginning and end
12052 of a region that the link is being redirected to. See Note
12053 \ref{masking-links} and Note \ref{masks}, and for further discussion
12054 of the lack of generality in the current mask format, see Note
12055 \ref{generality-of-masks}.
12056 \end{notate}
12058 \begin{notate}{Spec for `usable-about-data'}
12059 Something called ``usable-about-data'' is produced by the function
12060 `compute-usable-about-data' (see Note
12061 \ref{compute-usable-about-data}). This stuff is used when marking
12062 things up (in particular, by `mark-up-scholium' and
12063 `mark-up-reference'). The reason for documenting it here is that its
12064 format is confusing and easy to forget. I think that it would be best
12065 if we could find another way to get this data to where it needs to be.
12067 The format of the return value of `compute-usable-about-data'
12068 is a list of elements of the form
12069 \begin{idea}
12070 ((<name> <link number>) <beg end | nil>)
12071 \end{idea}
12072 where name is the name of a scholium, `beg' and `end', if specified,
12073 give the beginning and end of a marked region (yes, only one region
12074 per link, as mentioned in Note \ref{links-indicating-passages}),
12075 whereas `nil' is specified if the link indicated by the `car' of this
12076 form points at the whole of the article being rendered.
12078 (I am not a huge fan of this format, but it does seem to work;
12079 however, maybe the name should be changed to ``usable about data for
12080 markup'' or something like that, to make it clear why we are focusing
12081 on data describing regions.)
12083 (Also, perhaps we should note in this spec that instead of the
12084 \inp{name}, sometimes ``(mask \inp{name})'' is used instead. The
12085 development here seems a bit confusing: if we use (mask \inp{name}),
12086 is this a proper link-id? Something to think about, I guess.)
12087 \end{notate}
12089 \begin{notate}{Comments on specs}
12090 I fear that the choice to allow a token or a list of types may come
12091 back to bite later; it is certainly somewhat annoying now. But I
12092 think we're running with it?
12094 Eventually we might want some specs for various operations or other
12095 objects (e.g. transclusions are both operations and static objects).
12096 But we can hold off on that til it is all defined.
12098 Furthermore, we'll want to have clear specs for the formats that are
12099 used \emph{in markup} (of regular links, links coming from references,
12100 fake references, possibly etc.) but we don't quite have that taken
12101 care of yet.
12102 \end{notate}
12104 \section{Appendix: Time and workflow management} \label{appendix-cal}
12106 \begin{notate}{Framework for keeping track of time and events}
12107 People have been using calendars since the beginning of time
12108 (literally!). However, this is a case where reinventing the wheel
12109 might be called for. The scholium system can be used to keep track of
12110 epochs of different scales, and maintain the proper relationships
12111 between them. Well, different calendar programs already exist that
12112 will e.g. keep track of the events that are taking place in all of the
12113 days of the month, and know (in some sense of the word) that these
12114 events are taking place in that month. But I think I can do somewhat
12115 better for my needs. One of the reasons is to keep a lot of data in
12116 the system and integrate it up to get certain conclusions.
12117 Furthermore, I want to keep track of the way big tasks get parceled
12118 out to smaller time-scales. Another useful feature is the ability to
12119 go in the opposite direction, and produce somewhat realistic
12120 predictions about what can be done by when.
12122 So, we'll give it a shot.
12124 (Presumably if this ``appendix'' gets extremely verbose, big parts of
12125 it should be chunked out into some other separate document.)
12126 \end{notate}
12128 \begin{notate}{Summer 2006}
12129 I want to get a releasable version of Arxana out. I have to help
12130 mentor Shaneal on his proof checking stuff. I'd like to get started
12131 with some NLP stuff. I'd want to keep up with general reading and
12132 correspondence related to the HDM project. And finally, I want to do
12133 some more math related things.
12134 \end{notate}
12136 \begin{notate}{Miscellaneous items that can get into release} \label{misc-items-for-release}
12137 This stuff has come up as potentially important or at least
12138 interesting to consider for the release.
12139 \begin{itemize}
12140 \item How about being able to spawn a semi-anonymous scholium rooted
12141 in the current article?
12142 \item Build a subdocument library.
12143 \item Make an easy to use demo.
12144 \item Get a system for unique ID's working.
12145 \item Import APM-Xi.
12146 \item Go back over the internal formatting and display, and make sure
12147 that the format is actually used properly by the code that is
12148 supposed to use it.
12149 \item Finish putting together the ``restricted view'' mode.
12150 \item Perfect some system for managing clusions (including a
12151 simplified version for assembling a document from outlines).
12152 \end{itemize}
12153 \end{notate}
12155 \begin{notate}{Revising the schedule}
12156 One of the most reasonable-seeming things to do when starting work is
12157 to assess the schedule of events, and clarify exactly which activities
12158 will be done during that work session. Other clarifications to the
12159 schedule can be effected at this point too.
12160 \end{notate}
12162 \begin{notate}{Release conditions}
12163 It would be nice to get some sort of system set up for collaborative
12164 work on the same state-containing scholium system. Maybe Arxana will
12165 have to be made inherently peer-to-peer for this to work (given that
12166 Emacs doesn't seem to include features for operating as a server with
12167 several distinct users working on it at the same time). Or
12168 conceivably we can find a good back-end (e.g. in Common Lisp or
12169 scheme?) to connect people to. Another possibility that might work,
12170 although it sounds like a little bit of a long-shot, is to get
12171 Ebby\footnote{{\tt
12172 http://dev.technomancy.us/phil/browser/dotfiles/.emacs.d/ebby.el}}
12173 working with Gobby, or build on this system to make some
12174 Emacs(-friendly) multi-user environment. (Since Ebby apparently just
12175 works as a client, I currently suspect that it won't directly solve
12176 our state-maintaining problems.)
12178 Since this all looks tricky, it seems to me that having some
12179 acceptible (though certainly not perfected, that would be asking too
12180 much) single-user environment ready to go even before making too many
12181 more investigations of the multi-user stuff. See Note
12182 \ref{misc-items-for-release} for the key details on this topic.
12183 \end{notate}
12185 \begin{notate}{Tue Jun 6 15:12:52 2006}
12186 I write this section up to the current point. Then I think about what
12187 to do next. I guess it would be a good idea to look at importing
12188 APM-Xi again, and maybe try to get the subdocument library stuff
12189 working. Since this should be fairly easy (at least initially).
12190 \end{notate}
12192 \section{Appendix: Annotated non-bibliography} \label{appendix-bib}
12194 \begin{notate}{Outside references}
12195 For now, references are contained in footnotes. To view a compilation
12196 of the Notes that contain footnotes, evaluate this form:
12197 \begin{idea}
12198 (progn (article-menu-list-articles-matching-regexp "\\footnote")
12199 (listing-to-compilation nil))
12200 \end{idea}
12201 Eventually we may have a nicer way of presenting this data. Also,
12202 there are a number of references made in the text for which there are
12203 no footnotes, and the footnotes that do exist don't necessarily take a
12204 proper or in any way standard form. This can be fixed up eventually.
12205 \end{notate}
12207 %%%%%%%%%%%%%%%%%%% Back matter %%%%%%%%%%%%%%%%%%%%%%
12209 \clearpage
12211 % \addcontentsline{toc}{section}{\numberline {}References}
12212 % \bibliography{sbdm4cbpp}
12214 \printindex
12216 \end{document}
12218 %%% sbdm4cbpp.tex ends here