Function: icalendar-unfolded-buffer-from-region
icalendar-unfolded-buffer-from-region is a byte-compiled function
defined in icalendar-parser.el.gz.
Signature
(icalendar-unfolded-buffer-from-region START END &optional BUFFER)
Documentation
Create a new, unfolded buffer with the same contents as the region.
Copies the buffer contents between START and END (in BUFFER, if
provided) to a new buffer and performs line unfolding in the new buffer
with icalendar-unfold-region. That function can in some cases have
undesirable effects; see its docstring. If BUFFER is visiting a file, it
may be better to reload its contents from that file and perform line
unfolding before decoding; see icalendar-unfolded-buffer-from-file.
Returns the new buffer.
Source Code
;; Defined in /usr/src/emacs/lisp/calendar/icalendar-parser.el.gz
(defun ical:unfolded-buffer-from-region (start end &optional buffer)
"Create a new, unfolded buffer with the same contents as the region.
Copies the buffer contents between START and END (in BUFFER, if
provided) to a new buffer and performs line unfolding in the new buffer
with `icalendar-unfold-region'. That function can in some cases have
undesirable effects; see its docstring. If BUFFER is visiting a file, it
may be better to reload its contents from that file and perform line
unfolding before decoding; see `icalendar-unfolded-buffer-from-file'.
Returns the new buffer."
(let* ((old-buffer (or buffer (current-buffer)))
(contents (with-current-buffer old-buffer
(buffer-substring start end)))
(uf-buffer (generate-new-buffer ;; TODO: again, move to modeline?
(concat " *UNFOLDED:" (buffer-name old-buffer)))))
(with-current-buffer uf-buffer
(insert contents)
(ical:unfold-region (point-min) (point-max))
;; ensure we'll use CR-LF line endings on write, even if they weren't
;; in the source data. The standard also says UTF-8 is the default
;; encoding, so use 'prefer-utf-8-dos when last-coding-system-used
;; is nil.
(setq buffer-file-coding-system
(if last-coding-system-used
(coding-system-change-eol-conversion last-coding-system-used
'dos)
'prefer-utf-8-dos))
;; inhibit auto-save-mode, which will otherwise create save
;; files containing the unfolded data; these are probably
;; not useful to the user and a nuisance when running tests:
(auto-save-mode -1))
uf-buffer))