[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
saving a buffer without images
- From: Boruch Baum <boruch_baum@xxxxxxx>
- Date: Tue, 6 Sep 2016 17:44:30 -0400
- X-ml-name: emacs-w3m
- X-mail-count: 12595
Here is a proposal for a one-line change to function `w3m-save-buffer'
to make life easier for those of us who view web pages without images,
or who never want to save images along with html.
The diff is considerably longer than a single line because:
* the change includes defining a new customizable variable
* documentation
* typo corrections of functions caddr cadar
* change of parameter name `no-image' to `no-images'
* there seems to be a bug in the function call to
`w3m-history-set-current', so that function call was removed in
order to illustrate an error-free test.
diff appended in-line and attached.
=====================================================================
46,51c46,64
< (defun w3m-save-buffer (name &optional no-image)
< "Save the current page and its image data in NAME.html and NAME-files/.
< Those files will be saved in `w3m-save-buffer-directory' by default.
< No image will be saved if the prefix argument (the optional NO-IMAGE)
< is given. The saved page will be added to the history list, and be
< viewable using `w3m-next-page'."
---
> (defcustom w3m-save-buffer-html-only nil
> "If nil, `w3m-save-buffer' will save the images of a buffer in
> addition to the buffer's html. If the buffer was originally
> loaded without images, the images will now be retrieved. The
> value of this variable may be over-ridden at run-time by passing
> a prefix argument to function `w3m-save-buffer'."
> :group 'w3m
> :type 'boolean)
>
> (defun w3m-save-buffer (name &optional no-images)
> "Save the current buffer as `w3m-save-buffer-directory'/NAME.html,
> and optionally save the buffer's associated image files in
> folder `w3m-save-buffer-directory'/NAME-files/. Use of
> `w3m-save-buffer-directory' may be over-ridden by including a
> folder path in NAME. Variable `w3m-save-buffer-html-only'
> determines whether images will be save by default, but that
> setting may be over-ridden using the prefix argument (the
> optional NO-IMAGES). The saved page will be added to the
> history list, and be viewable using `w3m-next-page'."
77c90,91
< subdir type st base regexp sdir charset ibuf imgs nd img bads bname
---
> (no-images (if no-images (not w3m-save-buffer-html-only) w3m-save-buffer-html-only))
> subdir type st base regexp sdir charset ibuf imgs nd img bads bname
96c110
< (cond ((and (not no-image) (file-exists-p name) (file-exists-p subdir))
---
> (cond ((and (not no-images) (file-exists-p name) (file-exists-p subdir))
109c123
< ((and (not no-image) (file-exists-p subdir))
---
> ((and (not no-images) (file-exists-p subdir))
142c156
< (unless no-image
---
> (unless no-images
163c177
< ext (caddr (assoc img imgs)))
---
> ext (car (assoc img imgs)))
210,214c224
< (w3m-history-set-current
< (prog1
< (cadar w3m-history)
< (w3m-history-push (concat "file://" name)
< (list :title (or w3m-current-title "<no-title>")))))))
---
> ))
--
hkp://keys.gnupg.net
CA45 09B5 5351 7C11 A9D1 7286 0036 9E45 1595 8BC0
46,51c46,64
< (defun w3m-save-buffer (name &optional no-image)
< "Save the current page and its image data in NAME.html and NAME-files/.
< Those files will be saved in `w3m-save-buffer-directory' by default.
< No image will be saved if the prefix argument (the optional NO-IMAGE)
< is given. The saved page will be added to the history list, and be
< viewable using `w3m-next-page'."
---
> (defcustom w3m-save-buffer-html-only nil
> "If nil, `w3m-save-buffer' will save the images of a buffer in
> addition to the buffer's html. If the buffer was originally
> loaded without images, the images will now be retrieved. The
> value of this variable may be over-ridden at run-time by passing
> a prefix argument to function `w3m-save-buffer'."
> :group 'w3m
> :type 'boolean)
>
> (defun w3m-save-buffer (name &optional no-images)
> "Save the current buffer as `w3m-save-buffer-directory'/NAME.html,
> and optionally save the buffer's associated image files in
> folder `w3m-save-buffer-directory'/NAME-files/. Use of
> `w3m-save-buffer-directory' may be over-ridden by including a
> folder path in NAME. Variable `w3m-save-buffer-html-only'
> determines whether images will be save by default, but that
> setting may be over-ridden using the prefix argument (the
> optional NO-IMAGES). The saved page will be added to the
> history list, and be viewable using `w3m-next-page'."
77c90,91
< subdir type st base regexp sdir charset ibuf imgs nd img bads bname
---
> (no-images (if no-images (not w3m-save-buffer-html-only) w3m-save-buffer-html-only))
> subdir type st base regexp sdir charset ibuf imgs nd img bads bname
96c110
< (cond ((and (not no-image) (file-exists-p name) (file-exists-p subdir))
---
> (cond ((and (not no-images) (file-exists-p name) (file-exists-p subdir))
109c123
< ((and (not no-image) (file-exists-p subdir))
---
> ((and (not no-images) (file-exists-p subdir))
142c156
< (unless no-image
---
> (unless no-images
163c177
< ext (caddr (assoc img imgs)))
---
> ext (car (assoc img imgs)))
210,214c224
< (w3m-history-set-current
< (prog1
< (cadar w3m-history)
< (w3m-history-push (concat "file://" name)
< (list :title (or w3m-current-title "<no-title>")))))))
---
> ))