Changes between Version 1 and Version 2 of HemlockProgrammer/Miscellaneous


Ignore:
Timestamp:
Jan 16, 2008, 12:43:59 AM (12 years ago)
Author:
gz
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • HemlockProgrammer/Miscellaneous

    v1 v2  
     1[HemlockProgrammer Back to Table of Contents]
    12[[PageOutline]]
    23
     
    67don't fit well anywhere else.
    78
    8 == 17.1. Generic Pointer Up ==
     9== 17.1. ==
    910
    10 Generic Pointer Up is a Hemlock command bound to mouse up-clicks. It
    11 invokes a function supplied with the interface described in this
    12 section. This command allows different commands to be bound to the
    13 same down-click in various modes with one command bound to the
    14 corresponding up-click.
     11This section intentionally left blank to maintain numbering.
    1512
    16 supply-generic-pointer-up-function      function         [Function]
    17                
    18 This function supplies a function that Generic Pointer Up invokes the
    19 next time it executes.
     13== 17.2. ==
    2014
     15This section intentionally left blank to maintain numbering.
    2116
    22 
    23 == 17.2. Using View Mode ==
    24 
    25 View mode supports scrolling through files automatically terminating
    26 the buffer at end-of-file as well as commands for quitting the mode
    27 and popping back to the buffer that spawned the View mode
    28 buffer. Modes such as Dired and Lisp-Lib use this to view files and
    29 description of library entries.
    30 
    31 Modes that want similar commands should use view-file-command to view
    32 a file and get a handle on the view buffer. To allow the View Return
    33 and View Quit commands to return to the originating buffer, you must
    34 set the variable View Return Function in the viewing buffer to a
    35 function that knows how to do this. Furthermore, since you now have a
    36 reference to the originating buffer, you must add a buffer local
    37 delete hook to it that will clear the view return function's
    38 reference. This needs to happen for two reasons in case the user
    39 deletes the originating buffer:
    40 
    41  1. You don't want the return function to go to a non-existing,
    42  invalid buffer.
    43 
    44  2. Since the viewing buffer still exists, its View Return Function
    45  buffer local variable still exists. This means the function still
    46  references the deleted originating buffer, and garbage collection
    47  cannot reclaim the memory locked down by the deleted buffer.
    48 
    49 The following is a piece of code that could implement part of Dired
    50 View File that uses two closures to accomplish that described above:
    51 {{{
    52 (let* ((dired-buf (current-buffer))
    53        (buffer (view-file-command nil pathname)))
    54   (push #'(lambda (buffer)
    55             (declare (ignore buffer))
    56             (setf dired-buf nil))
    57         (buffer-delete-hook dired-buf))
    58   (setf (variable-value 'view-return-function :buffer buffer)
    59         #'(lambda ()
    60             (if dired-buf
    61               (change-to-buffer dired-buf)
    62               (dired-from-buffer-pathname-command nil)))))
    63 }}}
    64 
    65 The Dired buffer's delete hook clears the return function's reference
    66 to the Dired buffer. The return function tests the variable to see if
    67 it still holds a buffer when the function executes.
    68 
    69 
    70 
     17[HemlockProgrammer Back to Table of Contents]