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

Re: using filter correctly?



In [emacs-w3m : No.12096] Samuel Wales wrote:
> Is this the correct way?  Seems to not display the changes.

Looks ok.  But if it doesn't work as expected, you may want to
verify if two regexps match the actual html contents.  To do
that:

・Visit the page in question using emacs-w3m.
・Press the backslash key to show the html source.
・Eval (i.e. `M-:') these sexps one by one:
  (goto-char (point-min))
  (re-search-forward "whatever: begin" nil t)
  (re-search-forward "whatever: end" nil t)

>     (setq w3m-use-filter t)
>     (require 'w3m-filter)

>     ;; (setf w3m-filter-configuration nil)
>     (add-to-list 'w3m-filter-configuration
>      '(t
>        "whatever -- remove stuff at top"
>        "https://whatever.com";
>        alpha-w3m-fix-whatever))
>     (defun alpha-w3m-fix-whatever (_url)
>       (let ((b (and (goto-char (point-min))
>                     (re-search-forward "whatever: begin" nil t)
>                     (beginning-of-line)
>                     (point)))
>             (e (and (re-search-forward "whatever: end" nil t)
>                     (beginning-of-line)
>                     (forward-line 1)
>                     (point))))
>         (when (and b e)
>           (delete-region b e))))