all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* html2text-remove-tags documentation
@ 2011-07-24  9:11 Deniz Dogan
  2011-07-27  1:43 ` Deniz Dogan
  0 siblings, 1 reply; 4+ messages in thread
From: Deniz Dogan @ 2011-07-24  9:11 UTC (permalink / raw)
  To: emacs-devel

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



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-07-27  7:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-24  9:11 html2text-remove-tags documentation Deniz Dogan
2011-07-27  1:43 ` Deniz Dogan
2011-07-27  6:51   ` Andreas Röhler
2011-07-27  7:10   ` Andreas Röhler

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.