annotate modules/sample/sample.c @ 844:047d37eb70d7

[xemacs-hg @ 2002-05-16 13:30:23 by ben] ui fixes for things that were bothering me bytecode.c, editfns.c, lisp.h, lread.c: Fix save-restriction to use markers rather than pseudo-markers (integers representing the amount of text on either side of the region). That way, all inserts are handled correctly, not just those inside old restriction. Add buffer argument to save_restriction_save(). process.c: Clean up very dirty and kludgy code that outputs into a buffer -- use proper unwind protects, etc. font-lock.c: Do save-restriction/widen around the function -- otherwise, incorrect results will ensue when a buffer has been narrowed before a call to e.g. `buffer-syntactic-context' -- something that happens quite often. fileio.c: Look for a handler for make-temp-name. window.c, winslots.h: Try to solve this annoying problem: have two frames displaying the buffer, in different places; in one, temporarily switch away to another buffer and then back -- and you've lost your position; it's reset to the other one in the other frame. My current solution involves window-level caches of buffers and points (also a cache for window-start); when set-window-buffer is called, it looks to see if the buffer was previously visited in the window, and if so, uses the most recent point at that time. (It's a marker, so it handles changes.) #### Note: It could be argued that doing it on the frame level would be better -- e.g. if you visit a buffer temporarily through a grep, and then go back to that buffer, you presumably want the grep's position rather than some previous position provided everything was in the same frame, even though the grep was in another window in the frame. However, doing it on the frame level fails when you have two windows on the same frame. Perhaps we keep both a window and a frame cache, and use the frame cache if there are no other windows on the frame showing the buffer, else the window's cache? This is probably something to be configurable using a specifier. Suggestions please please please? window.c: Clean up a bit code that deals with the annoyance of window-point vs. point. dialog.el: Function to ask a multiple-choice question, automatically choosing a dialog box or minibuffer representation as necessary. Generalized version of yes-or-no-p, y-or-n-p. files.el: Use get-user-response to ask "yes/no/diff" question when recovering. "diff" means that a diff is displayed between the current file and the autosave. (Converts/deconverts escape-quoted as necessary. No more complaints from you, Mr. Turnbull!) One known problem: when a dialog is used, it's modal, so you can't scroll the diff. Will fix soon. lisp-mode.el: If we're filling a string, don't treat semicolon as a comment, which would give very unfriendly results. Uses `buffer-syntactic-context'. simple.el: all changes back to the beginning. (Useful if you've saved the file in the middle of the changes.) simple.el: Add option kill-word-into-kill-ring, which controls whether words deleted with kill-word, backward-kill-word, etc. are "cut" into the kill ring, or "cleared" into nothingness. (My preference is the latter, by far. I'd almost go so far as suggesting we make it the default, as you can always select a word and then cut it if you want it cut.) menubar-items.el: Add option corresponding to kill-word-into-kill-ring.
author ben
date Thu, 16 May 2002 13:30:58 +0000
parents abe6d1db359e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
388
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
1 /*
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
2 * Very simple sample module. Illustrates most of the salient features
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
3 * of Emacs dynamic modules.
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
4 * (C) Copyright 1998, 1999 J. Kean Johnston. All rights reserved.
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
5 */
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
6
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
7 #include <emodules.h>
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
8
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
9 /*
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
10 * This sample introduces three new Lisp objects to the Lisp reader.
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
11 * The first, a simple boolean value, and the second a string. The
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
12 * Third is a sample function that simply prints a message.
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
13 */
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
14 int sample_bool;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
15 Lisp_Object Vsample_string;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
16
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
17 DEFUN ("sample-function", Fsample_function, 0, 0, "", /*
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
18 This is a sample function loaded dynamically.
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
19
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
20 You will notice in the source code for this module that the
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
21 declaration is identical to internal Emacs functions. This
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
22 makes it possible to use the exact same code in a dumped
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
23 version of Emacs.
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
24 */
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
25 ())
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
26 {
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
27 message ("Eureka! It worked");
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
28 return Qt;
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
29 }
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
30
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
31 /*
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
32 * Each dynamically loaded Emacs module is given a name at compile
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
33 * time. This is a short name, and must be a valid part of a C
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 388
diff changeset
34 * identifier. This name is used to construct the name of several
388
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
35 * functions which must appear in the module source code.
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 388
diff changeset
36 * The first such function, modules_of_XXXX, should load in any dependent
388
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
37 * modules. This function is optional, and the module will still load if
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
38 * it is not present in the module.
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
39 *
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
40 * The second function, which is NOT optional, is syms_of_XXXX, in which
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
41 * all functions that the module will be provided are declared. This
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
42 * function will contain calls to DEFSUBR().
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
43 *
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
44 * The third function, which is also NOT optional, is vars_of_XXXX, in
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
45 * which you declare all variables that the module provides. This
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
46 * function will contain calls to DEFVAR_LISP(), DEFVAR_BOOL() etc.
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
47 *
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
48 * When declaring functions and variables in the syms_of_XXXX and
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
49 * vars_of_XXXX functions, you use the exact same syntax that you
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
50 * would as if this module were being compiled into the pure Emacs.
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
51 *
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
52 * All three of these functions are declared as void functions,
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
53 * taking no parameters. Since this sample module is called 'sample',
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
54 * the functions will be named 'modules_of_sample', 'syms_of_sample'
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
55 * and 'vars_of_sample'.
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
56 */
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
57
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
58 void
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
59 modules_of_sample()
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
60 {
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
61 /*
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
62 * This function isn't actually required as we will not be loading
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 388
diff changeset
63 * in any dependent modules, but if we were, we would do something like:
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 388
diff changeset
64 * emodules_load ("dependent.ell", "sample2", "1.0.0");
388
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
65 */
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
66 }
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
67
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
68 void
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
69 syms_of_sample()
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
70 {
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
71 DEFSUBR(Fsample_function);
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
72 }
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
73
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
74 void
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
75 vars_of_sample()
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
76 {
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
77 DEFVAR_LISP ("sample-string", &Vsample_string /*
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
78 This is a sample string, declared in a dynamic module.
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
79
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
80 The syntax and conventions used for all normal Emacs variables
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
81 apply equally to modules, using an identical syntax.
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
82 */ );
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
83
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
84 DEFVAR_BOOL ("sample-boolean", &sample_bool /*
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
85 *Sample boolean value, in a dynamic module.
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
86
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
87 This is a user-settable variable, as indicated by the *
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
88 as the first character of the description. Declared in
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
89 a module exactly as it would be internally in Emacs.
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
90 */ );
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
91 }
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents:
diff changeset
92