diff options
| author | Richard M. Stallman | 2005-04-30 20:30:03 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2005-04-30 20:30:03 +0000 |
| commit | 62679725a1a478e9e22dd26ac5c48aa50310f07d (patch) | |
| tree | d032308deeee408dab8e4f2c6b8f7ced30be986e | |
| parent | 0b1fc48a5cb40a2ce5d6bc10a83e76d06f7161dc (diff) | |
| download | emacs-62679725a1a478e9e22dd26ac5c48aa50310f07d.tar.gz emacs-62679725a1a478e9e22dd26ac5c48aa50310f07d.zip | |
(Magic File Names): Document `operations' property.
| -rw-r--r-- | lispref/files.texi | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/lispref/files.texi b/lispref/files.texi index 0b6e7a2832d..b39a552e3af 100644 --- a/lispref/files.texi +++ b/lispref/files.texi | |||
| @@ -2441,7 +2441,7 @@ check the given file name against @code{file-name-handler-alist}. If | |||
| 2441 | the file name matches @var{regexp}, the primitives handle that file by | 2441 | the file name matches @var{regexp}, the primitives handle that file by |
| 2442 | calling @var{handler}. | 2442 | calling @var{handler}. |
| 2443 | 2443 | ||
| 2444 | The first argument given to @var{handler} is the name of the | 2444 | The first argument given to @var{handler} is the name of the |
| 2445 | primitive, as a symbol; the remaining arguments are the arguments that | 2445 | primitive, as a symbol; the remaining arguments are the arguments that |
| 2446 | were passed to that primitive. (The first of these arguments is most | 2446 | were passed to that primitive. (The first of these arguments is most |
| 2447 | often the file name itself.) For example, if you do this: | 2447 | often the file name itself.) For example, if you do this: |
| @@ -2458,7 +2458,7 @@ called like this: | |||
| 2458 | (funcall @var{handler} 'file-exists-p @var{filename}) | 2458 | (funcall @var{handler} 'file-exists-p @var{filename}) |
| 2459 | @end example | 2459 | @end example |
| 2460 | 2460 | ||
| 2461 | When a function takes two or more arguments that must be file names, | 2461 | When a function takes two or more arguments that must be file names, |
| 2462 | it checks each of those names for a handler. For example, if you do | 2462 | it checks each of those names for a handler. For example, if you do |
| 2463 | this: | 2463 | this: |
| 2464 | 2464 | ||
| @@ -2479,7 +2479,7 @@ this: | |||
| 2479 | The @var{handler} then needs to figure out whether to handle | 2479 | The @var{handler} then needs to figure out whether to handle |
| 2480 | @var{filename} or @var{dirname}. | 2480 | @var{filename} or @var{dirname}. |
| 2481 | 2481 | ||
| 2482 | If the specified file name matches more than one handler, the one | 2482 | If the specified file name matches more than one handler, the one |
| 2483 | whose match starts last in the file name gets precedence. This rule | 2483 | whose match starts last in the file name gets precedence. This rule |
| 2484 | is chosen so that handlers for jobs such as uncompression are handled | 2484 | is chosen so that handlers for jobs such as uncompression are handled |
| 2485 | first, before handlers for jobs such as remote file access. | 2485 | first, before handlers for jobs such as remote file access. |
| @@ -2575,12 +2575,12 @@ Here are the operations that a magic file name handler gets to handle: | |||
| 2575 | @end flushleft | 2575 | @end flushleft |
| 2576 | @end iftex | 2576 | @end iftex |
| 2577 | 2577 | ||
| 2578 | Handlers for @code{insert-file-contents} typically need to clear the | 2578 | Handlers for @code{insert-file-contents} typically need to clear the |
| 2579 | buffer's modified flag, with @code{(set-buffer-modified-p nil)}, if the | 2579 | buffer's modified flag, with @code{(set-buffer-modified-p nil)}, if the |
| 2580 | @var{visit} argument is non-@code{nil}. This also has the effect of | 2580 | @var{visit} argument is non-@code{nil}. This also has the effect of |
| 2581 | unlocking the buffer if it is locked. | 2581 | unlocking the buffer if it is locked. |
| 2582 | 2582 | ||
| 2583 | The handler function must handle all of the above operations, and | 2583 | The handler function must handle all of the above operations, and |
| 2584 | possibly others to be added in the future. It need not implement all | 2584 | possibly others to be added in the future. It need not implement all |
| 2585 | these operations itself---when it has nothing special to do for a | 2585 | these operations itself---when it has nothing special to do for a |
| 2586 | certain operation, it can reinvoke the primitive, to handle the | 2586 | certain operation, it can reinvoke the primitive, to handle the |
| @@ -2603,7 +2603,7 @@ for an operation it does not recognize. Here's one way to do this: | |||
| 2603 | (apply operation args))))) | 2603 | (apply operation args))))) |
| 2604 | @end smallexample | 2604 | @end smallexample |
| 2605 | 2605 | ||
| 2606 | When a handler function decides to call the ordinary Emacs primitive for | 2606 | When a handler function decides to call the ordinary Emacs primitive for |
| 2607 | the operation at hand, it needs to prevent the primitive from calling | 2607 | the operation at hand, it needs to prevent the primitive from calling |
| 2608 | the same handler once again, thus leading to an infinite recursion. The | 2608 | the same handler once again, thus leading to an infinite recursion. The |
| 2609 | example above shows how to do this, with the variables | 2609 | example above shows how to do this, with the variables |
| @@ -2614,7 +2614,7 @@ multiple handlers, and for operations that have two file names that may | |||
| 2614 | each have handlers. | 2614 | each have handlers. |
| 2615 | 2615 | ||
| 2616 | @kindex safe-magic (@r{property}) | 2616 | @kindex safe-magic (@r{property}) |
| 2617 | Handlers that don't really do anything special for actual access to the | 2617 | Handlers that don't really do anything special for actual access to the |
| 2618 | file---such as the ones that implement completion of host names for | 2618 | file---such as the ones that implement completion of host names for |
| 2619 | remote file names---should have a non-@code{nil} @code{safe-magic} | 2619 | remote file names---should have a non-@code{nil} @code{safe-magic} |
| 2620 | property. For instance, Emacs normally ``protects'' directory names | 2620 | property. For instance, Emacs normally ``protects'' directory names |
| @@ -2623,6 +2623,15 @@ file names, by prefixing them with @samp{/:}. But if the handler that | |||
| 2623 | would be used for them has a non-@code{nil} @code{safe-magic} | 2623 | would be used for them has a non-@code{nil} @code{safe-magic} |
| 2624 | property, the @samp{/:} is not added. | 2624 | property, the @samp{/:} is not added. |
| 2625 | 2625 | ||
| 2626 | @kindex operations (@r{property}) | ||
| 2627 | A file name handler can have an @code{operations} property to | ||
| 2628 | declare which operations it handles in a nontrivial way. If this | ||
| 2629 | property has a non-@code{nil} value, it should be a list of | ||
| 2630 | operations; then only those operations will call the handler. This | ||
| 2631 | avoids inefficiency, but its main purpose is for autoloaded handler | ||
| 2632 | functions, so that they won't be loaded except when they have real | ||
| 2633 | work to do. | ||
| 2634 | |||
| 2626 | @defvar inhibit-file-name-handlers | 2635 | @defvar inhibit-file-name-handlers |
| 2627 | This variable holds a list of handlers whose use is presently inhibited | 2636 | This variable holds a list of handlers whose use is presently inhibited |
| 2628 | for a certain operation. | 2637 | for a certain operation. |