diff options
| author | Richard M. Stallman | 1993-11-15 06:46:14 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1993-11-15 06:46:14 +0000 |
| commit | 98d873522c4344184834ab940eeacdd9a2b4bdd3 (patch) | |
| tree | 1be595a55411ea2425dacdbfbd0a4f0a17391d3b /lisp | |
| parent | da625a3c9b42247bcf24802df94b5bfa4f155df2 (diff) | |
| download | emacs-98d873522c4344184834ab940eeacdd9a2b4bdd3.tar.gz emacs-98d873522c4344184834ab940eeacdd9a2b4bdd3.zip | |
Revise documentation. Add `provide'.
(pages-directory-for-adding-addresses-narrowing-p):
New user option for adding addresses. Default to narrowing.
(pages-directory-for-addresses): Intall user settable options.
(add-new-page): Insert new page in specified location.
(original-page-delimiter): Set default value to "^^L".
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/textmodes/page-ext.el | 343 |
1 files changed, 172 insertions, 171 deletions
diff --git a/lisp/textmodes/page-ext.el b/lisp/textmodes/page-ext.el index 8537e59450b..1b83a3ae3da 100644 --- a/lisp/textmodes/page-ext.el +++ b/lisp/textmodes/page-ext.el | |||
| @@ -1,8 +1,11 @@ | |||
| 1 | ;;; page-ext.el --- page handling commands | 1 | ;;; page-ext.el --- extended page handling commands |
| 2 | 2 | ||
| 3 | ;;; Copyright (C) 1990 Free Software Foundation | 3 | ;; You may use these commands to handle an address list or other |
| 4 | ;; small data base. | ||
| 4 | 5 | ||
| 5 | ;; Author: Robert J. Chassell <bob@gnu.ai.mit.edu> | 6 | ;; Copyright (C) 1990, 1991, 1993 Free Software Foundation |
| 7 | |||
| 8 | ;; Maintainer: Robert J. Chassell <bob@gnu.ai.mit.edu> | ||
| 6 | 9 | ||
| 7 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| 8 | 11 | ||
| @@ -20,124 +23,8 @@ | |||
| 20 | ;; along with GNU Emacs; see the file COPYING. If not, write to | 23 | ;; along with GNU Emacs; see the file COPYING. If not, write to |
| 21 | ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | 24 | ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
| 22 | 25 | ||
| 23 | ;;; Commentary: | ||
| 24 | |||
| 25 | ;;; You may use these commands to handle an address list or other | ||
| 26 | ;;; small data base. | ||
| 27 | |||
| 28 | ;;; Change Log: | ||
| 29 | |||
| 30 | ;;; Change Log ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
| 31 | ;;; | ||
| 32 | ;;; Version 0.043 | ||
| 33 | ;;; 24 May 1990 - When the cursor is at the end of the pages directory | ||
| 34 | ;;; buffer (which is empty), a `C-c C-c' (pages-directory-goto) | ||
| 35 | ;;; command now takes you to the end of the buffer. | ||
| 36 | ;;; | ||
| 37 | ;;; Version 0.042 | ||
| 38 | ;;; 16 May 1990 - Since people often handle address and other files | ||
| 39 | ;;; differently, variable `pages-directory-for-addresses-narrowing-p' | ||
| 40 | ;;; now specifies whether `pages-directory-goto' should narrow | ||
| 41 | ;;; addresses buffer to entry to which it goes. | ||
| 42 | ;;; `pages-directory-buffer-narrowing-p' continues to control | ||
| 43 | ;;; narrowing of pages buffer. | ||
| 44 | ;;; | ||
| 45 | ;;; `add-new-page' documentation string now explains | ||
| 46 | ;;; that the value of the inserted page-delimiter is a `^L'. | ||
| 47 | ;;; | ||
| 48 | ;;; `pages-directory-previous-regexp' definition reworded. | ||
| 49 | ;;; | ||
| 50 | ;;; Removed unneeded defvar for `pages-directory-buffer'. | ||
| 51 | ;;; | ||
| 52 | ;;; Version 0.041 | ||
| 53 | ;;; 14 May 1990 - `pages-last-search' bound to nil initially. | ||
| 54 | ;;; Remove unnecessary lines from `search-pages' definition. | ||
| 55 | ;;; | ||
| 56 | ;;; Version 0.04 | ||
| 57 | ;;; 18 Mar 1990 - `pages-directory' creates a directory for only the | ||
| 58 | ;;; accessible portion of the buffer; it does not automatically widen | ||
| 59 | ;;; the buffer. | ||
| 60 | ;;; | ||
| 61 | ;;; However, `pages-directory-for-addresses' does widen the addresses' | ||
| 62 | ;;; buffer before constructing the addresses' directory. | ||
| 63 | ;;; | ||
| 64 | ;;; Version 0.032 | ||
| 65 | ;;; 20 Feb 1990 - `pages-directory-for-addresses' no longer copies | ||
| 66 | ;;; first line of addresses directory to kill-ring | ||
| 67 | ;;; | ||
| 68 | ;;; Remove `(kill-all-local-variables)' line from | ||
| 69 | ;;; `pages-directory-address-mode' so Emacs will not be told to forget | ||
| 70 | ;;; the name of the file containing the addresses! | ||
| 71 | ;;; | ||
| 72 | ;;; Version 0.031 | ||
| 73 | ;;; 15 Feb 1990 - `pages-directory-goto' no longer erroneously selects | ||
| 74 | ;;; the entry on the following line when the cursor is at the end of | ||
| 75 | ;;; the line, but selects the entry on which the cursor rests. | ||
| 76 | ;;; | ||
| 77 | ;;; `pages-directory-address-mode' now sets local variables and enables | ||
| 78 | ;;; `describe-mode' to describe Addresses Directory mode. | ||
| 79 | ;;; | ||
| 80 | ;;; `pages-directory-for-addresses' now sets the buffer-modified flag | ||
| 81 | ;;; for the Addresses Directory to nil. | ||
| 82 | ;;; | ||
| 83 | ;;; The documentation string for both `pages-directory-mode' and | ||
| 84 | ;;; `pages-directory-address-mode' now provide a lookup for the | ||
| 85 | ;;; `pages-directory-goto' keybinding. | ||
| 86 | ;;; | ||
| 87 | ;;; Version 0.03 | ||
| 88 | ;;; 10 Feb 1990 - Incorporated a specialized extension of the | ||
| 89 | ;;; `pages-directory' command called `pages-directory-for-addresses' | ||
| 90 | ;;; and bound it to ctl-x-ctl-p-map "d" for integration with other | ||
| 91 | ;;; page functions. This function finds a file, creates a directory | ||
| 92 | ;;; for it using the `pages-directory' command, and displays the | ||
| 93 | ;;; directory. It is primarily for lists of addresses and the like. | ||
| 94 | ;;; | ||
| 95 | ;;; The difference between this and the `pages-directory' command is | ||
| 96 | ;;; that the `pages-directory-for-addresses' command presumes a | ||
| 97 | ;;; default addresses file (although you may optionally specify a file | ||
| 98 | ;;; name) and it switches you to the directory for the file, but the | ||
| 99 | ;;; `pages-directory' command creates a directory for the current | ||
| 100 | ;;; buffer, and pops to the directory in another window. | ||
| 101 | ;;; | ||
| 102 | ;;; `pages-directory' now places the cursor over the header line of | ||
| 103 | ;;; the page in which point was located in the pages buffer. | ||
| 104 | ;;; | ||
| 105 | ;;; New `set-page-delimiter' command sets the buffer local value of | ||
| 106 | ;;; the page-delimiter variable. With prefix arg, resets function to | ||
| 107 | ;;; original value. (Quicker to use than `edit-options'.) | ||
| 108 | ;;; | ||
| 109 | ;;; Version 0.02 | ||
| 110 | ;;; 9 Feb 1990 - `pages-directory' now displays the | ||
| 111 | ;;; first line that contains a non-blank character that follows the | ||
| 112 | ;;; `page-delimiter'; this may be the rest of the line that contains | ||
| 113 | ;;; the `page-delimiter' or a line following. (In most instances, the | ||
| 114 | ;;; line containing a non-blank character is a line of text.) | ||
| 115 | ;;; Modification includes changes to `pages-copy-header-and-position'. | ||
| 116 | ;;; | ||
| 117 | ;;; Each directory created by `pages-directory' now possesses a name | ||
| 118 | ;;; derived on the name of the pages buffer. Consequently, you may | ||
| 119 | ;;; create several different directories, one for each pages buffer. | ||
| 120 | ;;; | ||
| 121 | ;;; `sort-pages-in-region' no longers requires the text to start on | ||
| 122 | ;;; the line immediately following the line containing the | ||
| 123 | ;;; page-delimiter. | ||
| 124 | ;;; | ||
| 125 | ;;; `pages-directory-goto' no longer narrows to the page | ||
| 126 | ;;; automatically. Instead, if you wish it to narrow to the page, set | ||
| 127 | ;;; variable pages-directory-buffer-narrowing-p to a non-nil value. | ||
| 128 | ;;; Default is nil; this is an experiment to see whether it is useful | ||
| 129 | ;;; to see the surrounding context. | ||
| 130 | ;;; | ||
| 131 | ;;; Version 0.011 | ||
| 132 | ;;; 2 Feb 1990 - `add-new-page': removed extraneous space. | ||
| 133 | ;;; | ||
| 134 | ;;; Version 0.01 | ||
| 135 | ;;; 28 Jan 1990 - Initial definitions. | ||
| 136 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
| 137 | |||
| 138 | ;;; Code: | ||
| 139 | 26 | ||
| 140 | ;;;; Summary | 27 | ;;; Summary |
| 141 | 28 | ||
| 142 | ; The current page commands are: | 29 | ; The current page commands are: |
| 143 | 30 | ||
| @@ -164,11 +51,11 @@ | |||
| 164 | ; set-page-delimiter C-x C-p C-l | 51 | ; set-page-delimiter C-x C-p C-l |
| 165 | ; pages-directory C-x C-p C-d | 52 | ; pages-directory C-x C-p C-d |
| 166 | ; pages-directory-for-addresses C-x C-p d | 53 | ; pages-directory-for-addresses C-x C-p d |
| 167 | ; goto-page C-c C-c | 54 | ; pages-directory-goto C-c C-c |
| 168 | 55 | ||
| 169 | 56 | ||
| 170 | ;;;; Using the page commands | 57 | ;;; Using the page commands |
| 171 | ; | 58 | |
| 172 | ; The page commands are helpful in several different contexts. For | 59 | ; The page commands are helpful in several different contexts. For |
| 173 | ; example, programmers often divide source files into sections using the | 60 | ; example, programmers often divide source files into sections using the |
| 174 | ; `page-delimiter'; you can use the `pages-directory' command to list | 61 | ; `page-delimiter'; you can use the `pages-directory' command to list |
| @@ -180,8 +67,25 @@ | |||
| 180 | ; Called with a prefix-arg, the command resets the value of the | 67 | ; Called with a prefix-arg, the command resets the value of the |
| 181 | ; page-delimiter to its original value. | 68 | ; page-delimiter to its original value. |
| 182 | 69 | ||
| 70 | ; You may set several user options: | ||
| 71 | ; | ||
| 72 | ; The `pages-directory-buffer-narrowing-p' variable causes the | ||
| 73 | ; `pages-directory-goto' command to narrow to the destination page. | ||
| 74 | ; | ||
| 75 | ; The `pages-directory-for-adding-page-narrowing-p' variable, causes the | ||
| 76 | ; `add-new-page' command to narrow to the new entry. | ||
| 77 | ; | ||
| 78 | ; The `pages-directory-for-adding-new-page-before-current-page-p' variable | ||
| 79 | ; causes the `add-new-page' command to insert a new page before current | ||
| 80 | ; page. | ||
| 81 | ; | ||
| 82 | ; These variables are true by default. | ||
| 83 | ; | ||
| 84 | ; Additional, addresses-related user options are described in the next page | ||
| 85 | ; of this file. | ||
| 86 | |||
| 183 | 87 | ||
| 184 | ;;;; Handling an address list or small data base | 88 | ;;; Handling an address list or small data base |
| 185 | 89 | ||
| 186 | ; You may use the page commands to handle an address list or other | 90 | ; You may use the page commands to handle an address list or other |
| 187 | ; small data base. Put each address or entry on its own page. The | 91 | ; small data base. Put each address or entry on its own page. The |
| @@ -223,7 +127,7 @@ | |||
| 223 | ; Washington, DC 20515 | 127 | ; Washington, DC 20515 |
| 224 | ; | 128 | ; |
| 225 | ; Congressional committee concerned with permitting or preventing | 129 | ; Congressional committee concerned with permitting or preventing |
| 226 | ; monopolistic restrictions on the use of software technology | 130 | ; monopolistic restrictions on the use of software technology. |
| 227 | ; | 131 | ; |
| 228 | ; | 132 | ; |
| 229 | ; George Lakoff | 133 | ; George Lakoff |
| @@ -260,15 +164,12 @@ | |||
| 260 | ; dislay a directory of all the heading lines. | 164 | ; dislay a directory of all the heading lines. |
| 261 | 165 | ||
| 262 | ; In the directory, you may position the cursor over a heading line | 166 | ; In the directory, you may position the cursor over a heading line |
| 263 | ; and type `C-c C-c' to go to the entry to which it refers in the | 167 | ; and type `C-c C-c' (pages-directory-goto) to go to the entry to |
| 264 | ; pages buffer. | 168 | ; which it refers in the pages buffer. |
| 265 | 169 | ||
| 266 | ; When used in conjunction with the `pages-directory-for-addresses' | 170 | ; You can type `C-c C-p C-a' (add-new-page) to add a new entry in the |
| 267 | ; command, the `C-c C-c' (pages-directory-goto) command narrows to the | 171 | ; pages buffer or address file. This is the same command you use to |
| 268 | ; entry to which it goes. But, when used in conjunction with the | 172 | ; add a new entry when you are in the pages buffer or address file. |
| 269 | ; `pages-directory' command, the `C-c C-c' (pages-directory-goto) | ||
| 270 | ; command does not narrow to the entry, but widens the buffer so you | ||
| 271 | ; can see the context surrounding the entry. | ||
| 272 | 173 | ||
| 273 | ; If you wish, you may create several different directories, | 174 | ; If you wish, you may create several different directories, |
| 274 | ; one for each different buffer. | 175 | ; one for each different buffer. |
| @@ -282,11 +183,32 @@ | |||
| 282 | ; the command with a prefix arg, `C-u C-x C-p d', it prompts you for a | 183 | ; the command with a prefix arg, `C-u C-x C-p d', it prompts you for a |
| 283 | ; file name. | 184 | ; file name. |
| 284 | 185 | ||
| 186 | ; You may customize the addresses commands: | ||
| 187 | |||
| 188 | ; The `pages-addresses-file-name' variable determines the name of | ||
| 189 | ; the addresses file; by default it is "~/addresses". | ||
| 190 | |||
| 191 | ; The `pages-directory-for-addresses-goto-narrowing-p' variable | ||
| 192 | ; determines whether `pages-directory-goto' narrows the addresses | ||
| 193 | ; buffer to the entry, which it does by default. | ||
| 194 | |||
| 195 | ; The `pages-directory-for-addresses-buffer-keep-windows-p' variable | ||
| 196 | ; determines whether `pages-directory-for-addresses' deletes other | ||
| 197 | ; windows to show as many lines as possible on the screen or works | ||
| 198 | ; in the usual Emacs manner and keeps other windows. Default is to | ||
| 199 | ; keep other windows. | ||
| 200 | |||
| 201 | ; The `pages-directory-for-adding-addresses-narrowing-p' variable | ||
| 202 | ; determines whether `pages-directory-for-addresses' narrows the | ||
| 203 | ; addresses buffer to a new entry when you are adding that entry. | ||
| 204 | ; Default is to narrow to new entry, which means you see a blank | ||
| 205 | ; screen before you write the new entry. | ||
| 206 | |||
| 285 | ;; `pages-directory' in detail | 207 | ;; `pages-directory' in detail |
| 286 | 208 | ||
| 287 | ; Call the `pages-directory' from the buffer for which you want a | 209 | ; Call the `pages-directory' command from the buffer for which you |
| 288 | ; directory created; it creates a directory for the buffer and pops | 210 | ; want a directory created; it creates a directory for the buffer and |
| 289 | ; you to the directory. | 211 | ; pops you to the directory. |
| 290 | 212 | ||
| 291 | ; The `pages-directory' command has several options: | 213 | ; The `pages-directory' command has several options: |
| 292 | 214 | ||
| @@ -305,8 +227,38 @@ | |||
| 305 | ; Called with a negative numeric argument, the `pages-directory' | 227 | ; Called with a negative numeric argument, the `pages-directory' |
| 306 | ; command lists the lengths of pages whose contents match a regexp. | 228 | ; command lists the lengths of pages whose contents match a regexp. |
| 307 | 229 | ||
| 230 | ;;; Code: | ||
| 231 | |||
| 232 | |||
| 233 | ;;; Customarily customizable variable definitions | ||
| 234 | |||
| 235 | (defvar pages-directory-buffer-narrowing-p t | ||
| 236 | "*If non-nil, `pages-directory-goto' narrows pages buffer to entry.") | ||
| 237 | |||
| 238 | (defvar pages-directory-for-adding-page-narrowing-p t | ||
| 239 | "*If non-nil, `add-new-page' narrows page buffer to new entry.") | ||
| 240 | |||
| 241 | (defvar pages-directory-for-adding-new-page-before-current-page-p t | ||
| 242 | "*If non-nil, `add-new-page' inserts new page before current page.") | ||
| 243 | |||
| 244 | |||
| 245 | ;;; Addresses related variables | ||
| 246 | |||
| 247 | (defvar pages-addresses-file-name "~/addresses" | ||
| 248 | "*Standard name for file of addresses. Entries separated by page-delimiter. | ||
| 249 | Used by `pages-directory-for-addresses' function.") | ||
| 250 | |||
| 251 | (defvar pages-directory-for-addresses-goto-narrowing-p t | ||
| 252 | "*If non-nil, `pages-directory-goto' narrows addresses buffer to entry.") | ||
| 253 | |||
| 254 | (defvar pages-directory-for-addresses-buffer-keep-windows-p t | ||
| 255 | "*If nil, `pages-directory-for-addresses' deletes other windows.") | ||
| 256 | |||
| 257 | (defvar pages-directory-for-adding-addresses-narrowing-p t | ||
| 258 | "*If non-nil, `add-new-page' narrows addresses buffer to new entry.") | ||
| 259 | |||
| 308 | 260 | ||
| 309 | ;;;; Key bindings for page handling functions | 261 | ;;; Key bindings for page handling functions |
| 310 | 262 | ||
| 311 | (global-unset-key "\C-x\C-p") | 263 | (global-unset-key "\C-x\C-p") |
| 312 | 264 | ||
| @@ -327,7 +279,7 @@ | |||
| 327 | (define-key ctl-x-ctl-p-map "d" 'pages-directory-for-addresses) | 279 | (define-key ctl-x-ctl-p-map "d" 'pages-directory-for-addresses) |
| 328 | 280 | ||
| 329 | 281 | ||
| 330 | ;;;; Page movement function definitions | 282 | ;;; Page movement function definitions |
| 331 | 283 | ||
| 332 | (defun next-page (&optional count) | 284 | (defun next-page (&optional count) |
| 333 | "Move to the next page bounded by the `page-delimiter' variable. | 285 | "Move to the next page bounded by the `page-delimiter' variable. |
| @@ -361,17 +313,58 @@ With arg (prefix if interactive), move that many pages." | |||
| 361 | (next-page (- count))) | 313 | (next-page (- count))) |
| 362 | 314 | ||
| 363 | 315 | ||
| 364 | ;;;; Adding and searching pages | 316 | ;;; Adding and searching pages |
| 365 | 317 | ||
| 366 | (defun add-new-page (header-line) | 318 | (defun add-new-page (header-line) |
| 367 | "Insert new page at point; prompt for header line. | 319 | "Insert new page. Prompt for header line. |
| 368 | Page begins with a `^L' as the page-delimiter. | 320 | |
| 321 | If point is in the pages directory buffer, insert the new page in the | ||
| 322 | buffer associated with the directory. | ||
| 323 | |||
| 324 | Insert the new page just before current page if | ||
| 325 | pages-directory-for-adding-new-page-before-current-page-p variable | ||
| 326 | is non-nil. Else insert at exact location of point. | ||
| 327 | |||
| 328 | Narrow to new page if | ||
| 329 | pages-directory-for-adding-page-narrowing-p variable | ||
| 330 | is non-nil. | ||
| 331 | |||
| 332 | Page begins with a `^L' as the default page-delimiter. | ||
| 333 | Use \\[set-page-delimiter] to change the page-delimiter. | ||
| 369 | Point is left in the body of page." | 334 | Point is left in the body of page." |
| 370 | (interactive "sHeader line: ") | 335 | (interactive "sHeader line: ") |
| 371 | (widen) | 336 | (widen) |
| 372 | (insert (format "\n\n%s\n\n" header-line)) | 337 | ;; If in pages directory buffer |
| 373 | ;; don't renarrow; stay unnarrowed to see context | 338 | (if (eq major-mode 'pages-directory-mode) |
| 374 | (forward-line -1)) | 339 | (progn |
| 340 | ;; Add new page before or after current page? | ||
| 341 | (if pages-directory-for-adding-new-page-before-current-page-p | ||
| 342 | (pages-directory-goto) | ||
| 343 | (pages-directory-goto) | ||
| 344 | (forward-page) | ||
| 345 | (or (eobp) (forward-line -1))))) | ||
| 346 | (widen) | ||
| 347 | ;; Move point before current delimiter if desired. | ||
| 348 | (and pages-directory-for-adding-new-page-before-current-page-p | ||
| 349 | (if (re-search-backward page-delimiter nil t) | ||
| 350 | (goto-char (match-beginning 0)) | ||
| 351 | ;; If going to beginning of file, insert a page-delimiter | ||
| 352 | ;; before current first page. | ||
| 353 | (goto-char (point-min)) | ||
| 354 | (insert | ||
| 355 | (format "%s\n" | ||
| 356 | ;; Remove leading `^' from page-delimiter string | ||
| 357 | (if (eq '^ (car (read-from-string page-delimiter))) | ||
| 358 | (substring page-delimiter 1)))) | ||
| 359 | (goto-char (point-min)))) | ||
| 360 | ;; Insert page delimiter at beginning of line. | ||
| 361 | (if (not (looking-at "^.")) (forward-line 1)) | ||
| 362 | (insert (format "%s\n%s\n\n\n" | ||
| 363 | (if (eq '^ (car (read-from-string page-delimiter))) | ||
| 364 | (substring page-delimiter 1)) | ||
| 365 | header-line)) | ||
| 366 | (forward-line -1) | ||
| 367 | (and pages-directory-for-adding-page-narrowing-p (narrow-to-page))) | ||
| 375 | 368 | ||
| 376 | (defvar pages-last-search nil | 369 | (defvar pages-last-search nil |
| 377 | "Value of last regexp searched for. Initially, nil.") | 370 | "Value of last regexp searched for. Initially, nil.") |
| @@ -390,7 +383,7 @@ Point is left in the body of page." | |||
| 390 | (narrow-to-page)) | 383 | (narrow-to-page)) |
| 391 | 384 | ||
| 392 | 385 | ||
| 393 | ;;;; Sorting pages | 386 | ;;; Sorting pages |
| 394 | 387 | ||
| 395 | (autoload 'sort-subr "sort" "Primary function for sorting." t nil) | 388 | (autoload 'sort-subr "sort" "Primary function for sorting." t nil) |
| 396 | 389 | ||
| @@ -441,10 +434,7 @@ REVERSE (non-nil means reverse order), BEG and END (region to sort)." | |||
| 441 | (sort-pages-in-region reverse beginning end))) | 434 | (sort-pages-in-region reverse beginning end))) |
| 442 | 435 | ||
| 443 | 436 | ||
| 444 | ;;;; Pages directory ancillary definitions | 437 | ;;; Pages directory ancillary definitions |
| 445 | |||
| 446 | (defvar pages-directory-buffer-narrowing-p nil | ||
| 447 | "*If non-nil, `pages-directory-goto' narrows pages buffer to entry.") | ||
| 448 | 438 | ||
| 449 | (defvar pages-directory-previous-regexp nil | 439 | (defvar pages-directory-previous-regexp nil |
| 450 | "Value of previous regexp used by `pages-directory'. | 440 | "Value of previous regexp used by `pages-directory'. |
| @@ -467,7 +457,11 @@ contain matches to the regexp.\)") | |||
| 467 | () | 457 | () |
| 468 | (setq pages-directory-map (make-sparse-keymap)) | 458 | (setq pages-directory-map (make-sparse-keymap)) |
| 469 | (define-key pages-directory-map "\C-c\C-c" | 459 | (define-key pages-directory-map "\C-c\C-c" |
| 470 | 'pages-directory-goto)) | 460 | 'pages-directory-goto) |
| 461 | (define-key pages-directory-map "\C-c\C-p\C-a" 'add-new-page)) | ||
| 462 | |||
| 463 | (defvar original-page-delimiter "^" | ||
| 464 | "Default page delimiter.") | ||
| 471 | 465 | ||
| 472 | (defun set-page-delimiter (regexp reset-p) | 466 | (defun set-page-delimiter (regexp reset-p) |
| 473 | "Set buffer local value of page-delimiter to REGEXP. | 467 | "Set buffer local value of page-delimiter to REGEXP. |
| @@ -479,7 +473,7 @@ resets the page-delimiter to the original value." | |||
| 479 | 473 | ||
| 480 | (interactive | 474 | (interactive |
| 481 | (if current-prefix-arg | 475 | (if current-prefix-arg |
| 482 | (list original-page-delimiter nil) | 476 | (list original-page-delimiter "^") |
| 483 | (list (read-string "Set page-delimiter to regexp: " page-delimiter) | 477 | (list (read-string "Set page-delimiter to regexp: " page-delimiter) |
| 484 | nil))) | 478 | nil))) |
| 485 | (make-local-variable 'original-page-delimiter) | 479 | (make-local-variable 'original-page-delimiter) |
| @@ -493,7 +487,7 @@ resets the page-delimiter to the original value." | |||
| 493 | (message "The value of `page-delimiter' is now: %s" page-delimiter))) | 487 | (message "The value of `page-delimiter' is now: %s" page-delimiter))) |
| 494 | 488 | ||
| 495 | 489 | ||
| 496 | ;;;; Pages directory main definitions | 490 | ;;; Pages directory main definitions |
| 497 | 491 | ||
| 498 | (defun pages-directory | 492 | (defun pages-directory |
| 499 | (pages-list-all-headers-p count-lines-p &optional regexp) | 493 | (pages-list-all-headers-p count-lines-p &optional regexp) |
| @@ -551,7 +545,7 @@ directory for only the accessible portion of the buffer." | |||
| 551 | (message "Creating directory for: %s " | 545 | (message "Creating directory for: %s " |
| 552 | (buffer-name))) | 546 | (buffer-name))) |
| 553 | 547 | ||
| 554 | (let ((buffer (current-buffer)) | 548 | (let ((target-buffer (current-buffer)) |
| 555 | (pages-directory-buffer | 549 | (pages-directory-buffer |
| 556 | (concat pages-directory-prefix " " (buffer-name) " ")) | 550 | (concat pages-directory-prefix " " (buffer-name) " ")) |
| 557 | (linenum 1) | 551 | (linenum 1) |
| @@ -567,7 +561,7 @@ directory for only the accessible portion of the buffer." | |||
| 567 | (pages-directory-mode) | 561 | (pages-directory-mode) |
| 568 | (insert | 562 | (insert |
| 569 | "==== Pages Directory: use `C-c C-c' to go to page under cursor. ====" ?\n) | 563 | "==== Pages Directory: use `C-c C-c' to go to page under cursor. ====" ?\n) |
| 570 | (setq pages-buffer buffer) | 564 | (setq pages-buffer target-buffer) |
| 571 | (setq pages-pos-list nil)) | 565 | (setq pages-pos-list nil)) |
| 572 | 566 | ||
| 573 | (if pages-list-all-headers-p | 567 | (if pages-list-all-headers-p |
| @@ -617,7 +611,7 @@ directory for only the accessible portion of the buffer." | |||
| 617 | (setq pages-pos-list (nreverse pages-pos-list)) | 611 | (setq pages-pos-list (nreverse pages-pos-list)) |
| 618 | (if (interactive-p) | 612 | (if (interactive-p) |
| 619 | (message "%d matching lines in: %s" | 613 | (message "%d matching lines in: %s" |
| 620 | (length pages-pos-list) (buffer-name buffer)))) | 614 | (length pages-pos-list) (buffer-name target-buffer)))) |
| 621 | (pop-to-buffer pages-directory-buffer) | 615 | (pop-to-buffer pages-directory-buffer) |
| 622 | (sit-for 0) ; otherwise forward-line fails if N > window height. | 616 | (sit-for 0) ; otherwise forward-line fails if N > window height. |
| 623 | (forward-line (if (= 0 pages-buffer-original-page) | 617 | (forward-line (if (= 0 pages-buffer-original-page) |
| @@ -656,7 +650,7 @@ Used by `pages-directory' function." | |||
| 656 | ;; record page position | 650 | ;; record page position |
| 657 | (setq pages-pos-list (cons position pages-pos-list)) | 651 | (setq pages-pos-list (cons position pages-pos-list)) |
| 658 | ;; insert page header | 652 | ;; insert page header |
| 659 | (insert-buffer-substring buffer start end)) | 653 | (insert-buffer-substring target-buffer start end)) |
| 660 | 654 | ||
| 661 | (if count-lines-p | 655 | (if count-lines-p |
| 662 | (save-excursion | 656 | (save-excursion |
| @@ -697,7 +691,7 @@ to the same line in the pages buffer." | |||
| 697 | (pos (nth pages-number pages-pos-list)) | 691 | (pos (nth pages-number pages-pos-list)) |
| 698 | (end-of-directory-p (eobp)) | 692 | (end-of-directory-p (eobp)) |
| 699 | (narrowing-p pages-directory-buffer-narrowing-p)) | 693 | (narrowing-p pages-directory-buffer-narrowing-p)) |
| 700 | (pop-to-buffer pages-buffer) | 694 | (pop-to-buffer pages-buffer) |
| 701 | (widen) | 695 | (widen) |
| 702 | (if end-of-directory-p | 696 | (if end-of-directory-p |
| 703 | (goto-char (point-max)) | 697 | (goto-char (point-max)) |
| @@ -705,14 +699,7 @@ to the same line in the pages buffer." | |||
| 705 | (if narrowing-p (narrow-to-page)))) | 699 | (if narrowing-p (narrow-to-page)))) |
| 706 | 700 | ||
| 707 | 701 | ||
| 708 | ;;;; The `pages-directory-for-addresses' function and ancillary code | 702 | ;;; The `pages-directory-for-addresses' function and ancillary code |
| 709 | |||
| 710 | (defvar pages-addresses-file-name "~/addresses" | ||
| 711 | "*Standard name for file of addresses. Entries separated by `page-delimiter'. | ||
| 712 | Used by `pages-directory-for-addresses' function.") | ||
| 713 | |||
| 714 | (defvar pages-directory-for-addresses-narrowing-p t | ||
| 715 | "*If non-nil, `pages-directory-goto' narrows addresses buffer to entry.") | ||
| 716 | 703 | ||
| 717 | (defun pages-directory-for-addresses (&optional filename) | 704 | (defun pages-directory-for-addresses (&optional filename) |
| 718 | "Find addresses file and display its directory. | 705 | "Find addresses file and display its directory. |
| @@ -721,7 +708,15 @@ Optional argument is FILENAME. In interactive use, with prefix | |||
| 721 | argument, prompt for file name and provide completion. | 708 | argument, prompt for file name and provide completion. |
| 722 | 709 | ||
| 723 | Move point to one of the lines in the displayed directory, | 710 | Move point to one of the lines in the displayed directory, |
| 724 | then use C-c C-c to go to the same line in the addresses buffer." | 711 | then use \\[pages-directory-goto] to go to the same line |
| 712 | in the addresses buffer. | ||
| 713 | |||
| 714 | If pages-directory-for-addresses-goto-narrowing-p is non-nil, | ||
| 715 | `pages-directory-goto' narrows addresses buffer to entry. | ||
| 716 | |||
| 717 | If pages-directory-for-addresses-buffer-keep-windows-p is nil, | ||
| 718 | this command deletes other windows when it displays the addresses | ||
| 719 | directory." | ||
| 725 | 720 | ||
| 726 | (interactive | 721 | (interactive |
| 727 | (list (if current-prefix-arg | 722 | (list (if current-prefix-arg |
| @@ -739,9 +734,10 @@ then use C-c C-c to go to the same line in the addresses buffer." | |||
| 739 | (widen) | 734 | (widen) |
| 740 | (pages-directory t nil nil) | 735 | (pages-directory t nil nil) |
| 741 | (pages-directory-address-mode) | 736 | (pages-directory-address-mode) |
| 742 | (setq pages-directory-buffer-narrowing-p | 737 | (setq pages-directory-buffer-narrowing-p |
| 743 | pages-directory-for-addresses-narrowing-p) | 738 | pages-directory-for-addresses-goto-narrowing-p) |
| 744 | (delete-other-windows) | 739 | (or pages-directory-for-addresses-buffer-keep-windows-p |
| 740 | (delete-other-windows)) | ||
| 745 | (save-excursion | 741 | (save-excursion |
| 746 | (goto-char (point-min)) | 742 | (goto-char (point-min)) |
| 747 | (delete-region (point) (save-excursion (end-of-line) (point))) | 743 | (delete-region (point) (save-excursion (end-of-line) (point))) |
| @@ -754,7 +750,8 @@ then use C-c C-c to go to the same line in the addresses buffer." | |||
| 754 | (defun pages-directory-address-mode () | 750 | (defun pages-directory-address-mode () |
| 755 | "Mode for handling the Addresses Directory buffer. | 751 | "Mode for handling the Addresses Directory buffer. |
| 756 | 752 | ||
| 757 | Move point to one of the lines in this buffer, then use C-c C-c to go | 753 | Move point to one of the lines in this buffer, |
| 754 | then use \\[pages-directory-goto] to go | ||
| 758 | to the same line in the pages buffer." | 755 | to the same line in the pages buffer." |
| 759 | 756 | ||
| 760 | (use-local-map pages-directory-map) | 757 | (use-local-map pages-directory-map) |
| @@ -764,5 +761,9 @@ to the same line in the pages buffer." | |||
| 764 | (make-local-variable 'pages-pos-list) | 761 | (make-local-variable 'pages-pos-list) |
| 765 | (make-local-variable 'pages-directory-buffer-narrowing-p)) | 762 | (make-local-variable 'pages-directory-buffer-narrowing-p)) |
| 766 | 763 | ||
| 767 | ;;; page-ext.el ends here | 764 | |
| 765 | ;;; Place `provide' at end of file. | ||
| 766 | (provide 'page-ext) | ||
| 767 | |||
| 768 | ;;;;;;;;;;;;;;;; end of page-ext.el ;;;;;;;;;;;;;;;; | ||
| 768 | 769 | ||