[Date Prev][Date Next][Thread Prev][][Date Index][Thread Index]

Re: display-hook



On Thu, 2003-04-24 at 18:47, Katsumi Yamaoka wrote:
> Hi,
> 
> >>>>> In [emacs-w3m : No.04809]
> >>>>>	JD Smith <jdsmith@as.arizona.edu> wrote:
> 
> > I'm attempting to customize emacs-w3m (1.3.3) to display named
> > anchors near the top of the window, instead of in the middle when
> > they are linked.  Here's what I've used:
> 
> > (add-hook 'w3m-display-hook
> > 	  (lambda (url)
> > 	    (if (not (bobp)) (recenter 1))) 'append)
> 
> The reason why your hook doesn't work is the `w3m-goto-url'
> function is enclosed with `save-window-excursion' in the
> `w3m-view-this-url-1' function.  Since using `s-w-e' is for
> keeping windows arangement, not for keeping point or mark,
> there should be a solution.  Does anyone have any idea?
> 
> You developers can reproduce that behavior as follows:
> 
> 1. Eval JD's add-hook form.
> 2. Visit the url http://www.xemacs.org/Lists/index.html.
> 3. Type RET on the ``xemacs-beta-ja'' button.
> 
> Then you may not see the entry to the xemacs-beta-ja list.

Thanks for your help.  That explains why browse-url works with this hook
while direct linking does not.  Actually there are two failure
behaviors: when I step through with edebug, the anchor is temporarily
positioned at the top of the page, but s-w-e brings it back to the
center.  When it is run straight through with the problematic hook in
place, the anchor may not be displayed at all (for instance, the point
only moves a few lines).  I suspect this has something to do with the
asynchronous operation.  

Just FYI, I'm the maintainer of the IDLWAVE mode (idlwave.org), and will
soon release a new HTML help system.  So far, I've found w3m gives me
the best balance of speed and formatting fidelity.  Though I won't
enforce w3m by default (it's not installed with most Emacsen by
default), I'll probably strongly recommend it, and provide some coherent
configuration set.  I really appreciate how much you've put into it --
and I'm pretty sure a few more people will be appreciating it soon too
;).

A few small questions regarding formatting:

      * The vendor-converted HTML files I'm using align images in the
        center using a construct like:
        
        <div align="center"><img src="images/Ca14.gif" border="0"
        hspace="0" vspace="0">
        </div>
        
        Depending on where this occurs, this image location shows up
        differently, as seen in the attached screen shot and HTML
        example.  The difference between the first and the second images
        is that the first is wrapped up in *another* <div> block, e.g.:
        
        <div style="color: #000000;  font-size: 9pt; font-style: normal;
        font-weight: normal; margin-bottom: 4pt; margin-left: 0pt;
        margin-right: 0pt; margin-top: 0pt; text-align: left;
        text-decoration: none; text-indent: 0pt; text-transform: none;
        vertical-align: baseline">
        
        In any case, I wonder if it's possible to have div-centered
        images actually be centered when displayed (as opposed to
        aligning the left edge with the center), and whether this nested
        div behavior is correct (mozilla and other browsers do center
        it). 
      * The files use the special character entity &#151; which shows up
        as an em-dash ("--").  This is supposedly in the iso-latin1
        charset, but shows up as "\227" in w3m.  Also used is &#150;
        (regular dash "-"), and a few characters encoded in the
        (illegal, as far as I'm aware) symbol font, e.g.:
        
        Select <span class="Bold">File</span> <span
        class="Symbol">&#174;</span>
        
        where "Symbol" class is in the css:
        
        .Symbol
        {
            FONT-FAMILY: symbol;
        }
        
        These files are converted from Microsoft HTML Help, which may
        explain the use of some non-standard entities (even Mozilla
        can't handle Symbol by default).  

Thanks again for your help, and I apologize for the length.

JD

-- 
 J.D. Smith            <=> 
 Steward Observatory   <=> 520-621-9532 <W>
 University of Arizona <=> 520-621-1532 <F>
 Tucson, Arizona 85721 <=> 

Attachment: w3msnap.png
Description: PNG image

Title: CONVOL

CONVOL


Syntax | Return Value | Arguments | Keywords | Examples | Version History | See Also

The CONVOL function convolves an array with a kernel, and returns the result. Convolution is a general process that can be used for various types of smoothing, signal processing, shifting, differentiation, edge detection, etc. The CENTER keyword controls the alignment of the kernel with the array and the ordering of the kernel elements. If CENTER is explicitly set to 0, convolution is performed in the strict mathematical sense, otherwise the kernel is centered over each data point.

Using CONVOL

Assume R = CONVOL(A, K, S), where A is an n-element vector, K is an m-element vector (m < n), and S is the scale factor. If the CENTER keyword is omitted or set to 1:

where the value m/2 is determined by integer division. This means that the result of the division is the largest integer value less than or equal to the fractional number.

If CENTER is explicitly set to 0:

In the two-dimensional, zero CENTER case where A is an m by n-element array, and K is the l by l element kernel; the result R is an m by n-element array:

The centered case is similar, except the t-i and u-j subscripts are replaced by t+i-l/2 and u+j-l/2.

Syntax

Result = CONVOL( Array, Kernel [, Scale_Factor] [, /CENTER] [, /EDGE_WRAP] [, /EDGE_TRUNCATE] [, MISSING=value] [, /NAN] )

Return Value

Returns the result of the array convolution.

Arguments

Array

An array of any basic type except string. The result of CONVOL has the same type and dimensions as Array.

If the Array parameter is of byte type, the result is clipped to the range of 0 to 255. Negative results are set to 0, and values greater than 255 are set to 255.

Kernel

An array of any type except string. If the type of Kernel is not the same as Array, a copy of Kernel is made and converted to the appropriate type before use. The size of the kernel dimensions must be smaller than those of Array.

Note


CONVOL accepts non-square kernels including one-dimensional kernels.

Scale_Factor

A scale factor that is divided into each resulting value. This argument allows the use of fractional kernel values and avoids overflow with byte or integer arguments. If omitted, a scale factor of 1 is used.

Keywords

CENTER

Set or omit this keyword to center the kernel over each array point. If CENTER is explicitly set to zero, the CONVOL function works in the conventional mathematical sense. In many signal and image processing applications, it is useful to center a symmetric kernel over the data, thereby aligning the result with the original array.

Note that for the kernel to be centered, it must be symmetric about the point K(FLOOR(m/2)), where m is the number of elements in the kernel.

EDGE_WRAP

Set this keyword to make CONVOL compute the values of elements at the edge of Array by "wrapping" the subscripts of Array at the edge. For example, if CENTER is set to zero:


where n is the number of elements in Array. The mod operator in the formula above is defined as a mod b = a - b * floor(a/b). For example, -1 mod 5 is 4. If neither EDGE_WRAP nor EDGE_TRUNCATE is set, CONVOL sets the values of elements at the edges of Array to zero.

EDGE_TRUNCATE

Set this keyword to make CONVOL compute the values of elements at the edge of Array by repeating the subscripts of Array at the edge. For example, if CENTER is set to zero:

where n is the number of elements in Array. The "<" and ">" operators in the above formula return the smaller and larger of their operands, respectively. If neither EDGE_WRAP nor EDGE_TRUNCATE is set, CONVOL sets the values of elements at the edges of Array to zero.

MISSING

Set this keyword to the numeric value to return for elements that contain no valid points within the kernel. The default is the IEEE floating-point value NaN. This keyword is only used if the NAN keyword is set.

NAN

Set this keyword to cause the routine to check for occurrences of the IEEE floating-point value NaN in the input data. (See Special Floating-Point Values for more information on IEEE floating-point values.) Elements with the value NaN are treated as missing data, and are ignored when computing the convolution for neighboring elements. In the Result, missing elements are replaced by the convolution of all other valid points within the kernel. If all points within the kernel are missing, then the result at that point is given by the MISSING keyword.

Note


CONVOL should never be called without the NAN keyword if the input array may possibly contain NaN values.

Thread Pool Keywords

This routine is written to make use of IDL's thread pool, which can increase execution speed on systems with multiple CPUs. The values stored in the !CPU system variable control whether IDL uses the thread pool for a given computation. In addition, you can use the thread pool keywords TPOOL_MAX_ELTS, TPOOL_MIN_ELTS, and TPOOL_NOTHREAD to override the defaults established by !CPU for a single invocation of this routine. See Thread Pool Keywords for details.

Examples

Convolve a vector of random noise and a one-dimensional triangular kernel and plot the result. Create a simple vector as the original dataset and plot it by entering:

A = RANDOMN(SEED, 100) & PLOT, A

Create a simple kernel by entering:

K = [1, 2, 3, 2, 1]

Convolve the two and overplot the result by entering:

OPLOT, CONVOL(A, K, TOTAL(K))

Version History

Introduced: Original

See Also

BLK_CON