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

Re: Evaluating forms in particular pages



>>>>> In [emacs-w3m : No.08715] Romain Francoise wrote:

> Hi,

Hi,

> I'm looking for an elegant way to evaluate arbitrary code upon loading
> of certain pages, in a similar fashion to what Local Variables do in
> regular files.  I need this because I've been using outline-minor-mode
> extensively in certain web pages to hide uninteresting parts, and I need
> to set `outline-regexp' to different values depending on the page.

> For example in this page: http://bugs.debian.org/src:emacs-snapshot
> I evaluate the following form:

> (progn
>   (outline-minor-mode 1)
>   (set (make-local-variable 'outline-level) (lambda () 1))
>   (set (make-local-variable 'outline-regexp)
>        "\\(Outstanding\\|Resolved\\) bugs --"))

> I can then hide long lists of uninteresting bugs with the various
> Outline commands, which is very convenient[1].  At work I use this
> method to view wiki pages as outline documents.

I tried it in that page but I didn't see any difference.  It
might mean that there's no serious bug today or that I did
something wrong...

> Since I keep my Emacs sessions running for weeks, having to evaluate
> forms once in a while isn't really a problem, but automating the process
> would be nice.  Is there an existing way to do this?  I couldn't find
> any.

> If not something like `after-load-alist' comes to mind (i.e. an alist of
> regexps for URLs and corresponding forms to evaluate).

> Thoughts?

Well, though it might not measure up to your ideal, how about
using the `w3m-fontify-after-hook'?

(add-hook
 'w3m-fontify-after-hook
 (lambda nil
   (when (and w3m-current-url
	      (string-match "\\`http://bugs\\.debian\\.org/";
			    w3m-current-url))
     (outline-minor-mode 1)
     (set (make-local-variable 'outline-level) (lambda () 1))
     (set (make-local-variable 'outline-regexp)
	  "\\(Outstanding\\|Resolved\\) bugs --"))))