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

Re: recentre anchor at top of window



>>>>> In [emacs-w3m : No.10831] Kevin Ryde wrote:
> Recently there was a question about recentring the window start when
> going to an anchor,

>     http://osdir.com/ml/emacs.w3m/2003-04/msg00025.html

> Did a way to control or customize that ever come to pass?

> I wanted much the same for going to functions in the gtk docs.  When
> going to a particular anchor there it's good to have the anchor point at
> the top of the window so as to see as much as possible of the target
> function, not the preceding one, if you know what I mean.

> I got the effect I wanted with the following hack, but perhaps there's a
> better way.  (If so it could be indexed under "recenter" in the manual.)

>     (defadvice w3m-search-name-anchor (around my-recentre activate)
>       "Recentre to top of window."
>       (let ((found ad-do-it))
>         (if found
>             (recenter 1))
>         found))
>     (defadvice w3m-view-this-url-1 (after my-recentre activate)
>       "Recentre to top of window."
>       (recenter 1))

(To make the advice to `w3m-view-this-url-1' work, evaluating
 the `w3m-view-this-url' Lisp source is needed since
 `w3m-view-this-url-1' is an inline function.)

Anyway I found no problem in implementing that feature.  How about
making the arg passed to `recenter' customizable?  For example:

(defcustom w3m-view-this-url-and-recenter 1
  "Integer used to recenter the name link visited (passed to `recenter').
Nil means don't perform `recenter'."
  :group 'w3m
  :type '(radio (const :format "%t " nil) integer))

[...]
  (when w3m-view-this-url-and-recenter
    (recenter w3m-view-this-url-and-recenter))
[...]

Regards,