all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Deniz Dogan <deniz@dogan.se>
To: emacs-devel@gnu.org
Subject: html2text-remove-tags documentation
Date: Sun, 24 Jul 2011 11:11:05 +0200	[thread overview]
Message-ID: <4E2BE1A9.6010805@dogan.se> (raw)

This is the definition of `html2text-remove-tags' in lisp/gnus/html2text.el:

(defun html2text-remove-tags (tag-list)
   "Removes the tags listed in the list `html2text-remove-tag-list'.
See the documentation for that variable."
   (interactive)
   (dolist (tag tag-list)
     (goto-char (point-min))
     (while (re-search-forward (format "\\(</?%s[^>]*>\\)" tag) 
(point-max) t)
       (delete-region (match-beginning 0) (match-end 0)))))

As you can see, the documentation is clearly incorrect.  The function 
removes the tags in TAG-LIST, not `html2text-remove-tag-list'. 
Furthermore, the function is interactive which doesn't make sense the 
way it's written now.

So what should we do about this function?

I suggest we make TAG-LIST optional and defaulted to 
`html2text-remove-tag-list', i.e., (or tag-list 
html2text-remove-tag-list).  If called interactively, TAG-LIST should be 
a space-or-comma-separated string of tags to remove.

Such a definition could be:

(defun html2text-remove-tags (&optional tag-list)
   "Remove the tags in TAG-LIST.
If TAG-LIST is nil, use `html2text-remove-tag-list'.
If called interactively, "
   (interactive "MTags to remove: ")
   (setq tag-list (if (called-interactively-p 'any)
                      (split-string tag-list "[ ,]" t)
                    (or tag-list html2text-remove-tag-list)))
   (dolist (tag tag-list)
     (goto-char (point-min))
     (while (re-search-forward (format "\\(</?%s[^>]*>\\)" tag) 
(point-max) t)
       (delete-region (match-beginning 0) (match-end 0)))))

This definition would not break any existing code as far as I can tell 
and both fixes and adds functionality.

What do you think?

Deniz



             reply	other threads:[~2011-07-24  9:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-24  9:11 Deniz Dogan [this message]
2011-07-27  1:43 ` html2text-remove-tags documentation Deniz Dogan
2011-07-27  6:51   ` Andreas Röhler
2011-07-27  7:10   ` Andreas Röhler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4E2BE1A9.6010805@dogan.se \
    --to=deniz@dogan.se \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.