Changes between Version 2 and Version 3 of HemlockProgrammer/Files
- Timestamp:
- 01/15/08 12:01:08 (5 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
HemlockProgrammer/Files
v2 v3 1 [HemlockProgrammer Back to Table of Contents] 1 2 [[PageOutline]] 2 3 3 = 13. Files = 4 = 13. Files =#Files 4 5 5 6 This chapter discusses ways to read and write files at various … … 8 9 are read. 9 10 10 == 13.1. File Options and Type Hooks == 11 == 13.1. File Options and Type Hooks ==#FileOptionsAndTypeHooks 11 12 12 13 The user specifies file options with a special syntax on the first … … 27 28 appropriate default major mode. 28 29 29 define-file-optionname (buffer value) {declaration}* {form}* [Macro]30 `define-file-option` name (buffer value) {declaration}* {form}* [Macro] 30 31 31 32 This defines a new file option with the string … … 33 34 option value string, and forms are evaluated with these bound. 34 35 35 define-file-type-hooktype-list (buffer type) {declaration}* {form}* [Macro]36 `define-file-type-hook` type-list (buffer type) {declaration}* {form}* [Macro] 36 37 37 38 This defines some code that process-file-options(below) executes when 38 39 the file options fail to set a major mode. This associates each type, 39 a simple-string, intype-list with a routine that binds bufferto the40 buffer the file is in and typeto the type of the pathname.40 a string, in type-list with a routine that binds buffer to the 41 buffer the file is in and type to the type of the pathname. 41 42 42 process-file-optionsbuffer &optional pathname [Function]43 `process-file-options` buffer &optional pathname [Function] 43 44 44 45 This checks for file options in buffer and invokes handlers if there … … 48 49 hook. read-buffer-file calls this. 49 50 50 == 13.2. Pathnames and Buffers == 51 == 13.2. Pathnames and Buffers ==#PathnamesAndBuffers 51 52 52 53 There is no good way to uniquely identify buffer names and pathnames. … … 56 57 generating prompting defaults when asking the user for pathnames. 57 58 58 pathname-to-buffer-namepathname [Function]59 `pathname-to-buffer-name` pathname [Function] 59 60 60 This function returns a string of the form "file-namestring 61 directory-namestring". 61 This function returns a string of the form "file-namestring directory-namestring". 62 62 63 Pathname Defaults (initial value (pathname "gazonk.del")) [Hemlock Variable] 64 65 Last Resort Pathname Defaults Function [Hemlock Variable] 66 67 Last Resort Pathname Defaults(initial value (pathname "gazonk")) [Hemlock Variable] 63 `Pathname Defaults` (initial value (pathname "gazonk.del")) [Hemlock Variable][[BR]] 64 `Last Resort Pathname Defaults Function` [Hemlock Variable][[BR]] 65 `Last Resort Pathname Defaults` (initial value (pathname "gazonk")) [Hemlock Variable][[BR]] 68 66 69 67 These variables control the computation of default pathnames when … … 71 69 default. See the Hemlock User's Manual for more details. 72 70 73 buffer-default-pathnamebuffer [Function]71 `buffer-default-pathname` buffer [Function] 74 72 75 73 This returns Buffer Pathname if it is bound. If it is not bound, and … … 79 77 Defaults Function called on buffer. 80 78 81 == 13.3. File Groups == 79 == 13.3. File Groups ==#FileGroups 82 80 83 File groups provide a simple way of collecting the files that compose 84 a system and naming that collection. Hemlock supports commands for 85 searching, replacing, and compiling groups. 81 Currently Hemlock doesn't have support for file groups. 86 82 87 *active-file-group* [Variable] 88 89 This is the list of files that constitute the currently selected file 90 group. If this is nil, then there is no current group. 91 92 do-active-group {form}* [Macro] 93 94 Group Find File (initial value nil) [Hemlock Variable] 95 96 Group Save File Confirm (initial value t) [Hemlock Variable] 97 98 do-active-group iterates over *active-file-group* executing the forms 99 once for each file. While the forms are executing, the file is in the 100 current buffer, and the point is at the beginning. If there is no 101 active group, this signals an editor-error. 102 103 This reads each file into its own buffer using find-file-buffer. Since 104 unwanted buffers may consume large amounts of memory, Group Find 105 File controls whether to delete the buffer after executing the forms. 106 When the variable is false, this deletes the buffer if it did not 107 previously exist; however, regardless of this variable, if the user 108 leaves the buffer modified, the buffer persists after the forms have 109 completed. Whenever this processes a buffer that already existed, it 110 saves the location of the buffer's point before and restores it 111 afterwards. 112 113 After processing a buffer, if it is modified, do-active-group tries to 114 save it. If Group Save File Confirmis non-nil, it asks for 115 confirmation. 116 117 == 13.4. File Reading and Writing == 83 == 13.4. File Reading and Writing ==#FileReadingAndWriting 118 84 119 85 Common Lisp pathnames are used by the file primitives. For probing, … … 121 87 functions are available. 122 88 123 read-filepathname mark [Function]89 `read-file` pathname mark [Function] 124 90 125 This inserts the file named by pathnameatmark.91 This inserts the file named by pathname at mark. 126 92 127 write-file region pathname &key :keep-backup :access :append [Function] 128 129 Keep Backup Files(initial valuenil) [Hemlock Variable] 93 `write-file` region pathname &key :keep-backup :append [Function][[BR]] 94 `Keep Backup Files` (initial value nil) [Hemlock Variable][[BR]] 130 95 131 96 This function writes the contents of region to the file named by … … 140 105 This signals an error if both append and keep-backup are supplied as non-nil. 141 106 142 Access is an implementation dependent value that is suitable for 143 setting pathname's access or protection bits. 144 145 write-buffer-file buffer pathname [Function] 146 147 Write File Hook [Hemlock Variable] 148 149 Add Newline at EOF on Writing File(initial value:ask-user) [Hemlock Variable] 107 `write-buffer-file` buffer pathname [Function][[BR]] 108 `Write File Hook` [Hemlock Variable][[BR]] 109 `Add Newline at EOF on Writing File` (initial value :ask-user) [Hemlock Variable] 150 110 151 111 write-buffer-file writes buffer to the file named by pathname … … 169 129 * It invokes Write File Hook. 170 130 171 Write File Hoo kis a list of functions that take the newly written buffer as an argument.131 Write File Hook is a list of functions that take the newly written buffer as an argument. 172 132 173 read-buffer-file pathname buffer [Function] 174 175 Read File Hook [Hemlock Variable] 133 `read-buffer-file` pathname buffer [Function][[BR]] 134 `Read File Hook` [Hemlock Variable][[BR]] 176 135 177 136 read-buffer-file deletes buffer's region and uses read-file to read … … 182 141 buffer's write date to nil. 183 142 184 * It moves buffer's point to the beginning.143 * It moves buffer's point to the beginning. 185 144 186 * It sets buffer's unmodified status.145 * It sets buffer's unmodified status. 187 146 188 147 * It sets buffer's pathname to the result of probing pathname if the … … 199 158 buffer read into and whether the file existed, t if so. 200 159 201 find-file-buffer pathname [Function]202 160 203 This returns a buffer assoicated with the pathname, reading the file 204 into a new buffer if necessary. This returns a second value 205 indicating whether a new buffer was created, t if so. If the file has 206 already been read, this checks to see if the file has been modified on 207 disk since it was read, giving the user various recovery options. 208 This is the basis of the Find File command. 209 161 [HemlockProgrammer Back to Table of Contents]
