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

Proposed new function: save buffer as html sourceq

I realize that I'm new to emacs-w3m; it may be that what I'm proposing
already exists and I just couldn't find it. The idea is that when a
user is looking at a rendered web page in emacs-w3m, it should be easy
to save the page as its original html, so that it can be referred to
later by any other program, for any other purpose.

Here's what I had in mind, written today:

(defun my-save-w3m-html-file()
  "Save the current w3 buffer as an html page.
   BUG: For https pages, w3m will prompt 'You are leaving secure
        page.  Continue?'. You must answer 'y', or the function
        will save the rendered text instead of the html source.
        I haven't figured out how to suppress this or to flag an
        'n' response and abort."
         (replace-regexp-in-string " " "_" (w3m-current-title))
       (read-file-name "Save HTML source as: " w3m-default-save-directory
         nil nil this_file_name))
         (buffer-substring-no-properties (point-min) (point-max)))))
    ; the call to 'write-region' must be after a return to the
    ; rendered version of the w3m page, so that if the user aborts,
    ; the window isn't left displaying html source.
      html_content nil this_file_name nil nil nil t)))

What do you think?

CA45 09B5 5351 7C11 A9D1  7286 0036 9E45 1595 8BC0