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

w3m-filter-delete-regions feature enhancements (patch included)



On 2017-05-29 21:48, Boruch Baum wrote:
> . . .
> In the code below, three args are added at the end as optional so as
> to maintain backwards-compatability with the previous version of the
> function.

Ooops. I inadvertantly broke backward compatability bu how I defined
two of the new optional args. Here is the fix:

=======================================================================

(defun my-w3m-filter-delete-regions (url start end &optional without-start without-end use-regex)
  "Delete regions surrounded with a START pattern and an END pattern.

  If argument WITHOUT-START is t, do not delete START strings.
  If argument WITHOUT-END is t, do not delete the END strings.
  If argument USE-REGEX is t, treat START and END as REGEXes"
  (goto-char (point-min))
  (let (p (i 0))
    (while
      (and
        (if use-regex
          (re-search-forward start nil t)
         (search-forward start nil t))
		(setq p (if without-start (match-end 0) (match-beginning 0)))
        (if use-regex
          (re-search-forward end nil t)
         (search-forward end nil t)))
      (delete-region p (if without-end (match-beginning 0) (match-end 0)))
      (incf i))
    (> i 0)))


--
hkp://keys.gnupg.net
CA45 09B5 5351 7C11 A9D1  7286 0036 9E45 1595 8BC0