[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Proposed new function: save buffer as html sourceq
- From: Boruch Baum <boruch_baum@xxxxxxxxx>
- Date: Thu, 28 Jul 2016 00:51:03 -0400
- X-ml-name: emacs-w3m
- X-mail-count: 12580
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."
(interactive)
(let*
((this_file_name
(concat
(replace-regexp-in-string " " "_" (w3m-current-title))
".html"))
(this_file_name
(read-file-name "Save HTML source as: " w3m-default-save-directory
nil nil this_file_name))
(html_content
(progn
(w3m-view-source)
(buffer-substring-no-properties (point-min) (point-max)))))
(w3m-view-source)
; 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.
(write-region
html_content nil this_file_name nil nil nil t)))
What do you think?
--
hkp://keys.gnupg.net
CA45 09B5 5351 7C11 A9D1 7286 0036 9E45 1595 8BC0