Function: icalendar-switch-to-unfolded-buffer
icalendar-switch-to-unfolded-buffer is an interactive and
byte-compiled function defined in icalendar-mode.el.gz.
Signature
(icalendar-switch-to-unfolded-buffer)
Documentation
Switch to a new buffer with content lines unfolded.
The new buffer will contain the same data as the current buffer, but with content lines unfolded (before decoding, if possible).
Folding means inserting a line break and a single whitespace
character to continue lines longer than 75 octets; unfolding
means removing the extra whitespace inserted by folding. The
iCalendar standard (RFC5545) requires folding lines when
serializing data to iCalendar format, and unfolding before
parsing it. In icalendar-mode, folded lines may not have proper
syntax highlighting; this command allows you to view iCalendar
data with proper syntax highlighting, as the parser sees it.
If the current buffer is visiting a file, this function will
offer to save the buffer first, and then reload the contents from
the file, performing unfolding with icalendar-unfold-undecoded-region
before decoding it. This is the most reliable way to unfold lines.
If it is not visiting a file, it will unfold the new buffer
with icalendar-unfold-region. This can in some cases have
undesirable effects (see its docstring), so the original contents
are preserved unchanged in the current buffer.
In both cases, after switching to the new buffer, this command offers to kill the original buffer.
It is recommended to turn off auto-fill-mode when viewing an
unfolded buffer, so that filling does not interfere with syntax
highlighting. This function offers to disable auto-fill-mode if
it is enabled in the new buffer; consider using
visual-line-mode(var)/visual-line-mode(fun) instead.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/calendar/icalendar-mode.el.gz
;;; Commands
(defun ical:switch-to-unfolded-buffer ()
"Switch to a new buffer with content lines unfolded.
The new buffer will contain the same data as the current buffer, but
with content lines unfolded (before decoding, if possible).
`Folding' means inserting a line break and a single whitespace
character to continue lines longer than 75 octets; `unfolding'
means removing the extra whitespace inserted by folding. The
iCalendar standard (RFC5545) requires folding lines when
serializing data to iCalendar format, and unfolding before
parsing it. In `icalendar-mode', folded lines may not have proper
syntax highlighting; this command allows you to view iCalendar
data with proper syntax highlighting, as the parser sees it.
If the current buffer is visiting a file, this function will
offer to save the buffer first, and then reload the contents from
the file, performing unfolding with `icalendar-unfold-undecoded-region'
before decoding it. This is the most reliable way to unfold lines.
If it is not visiting a file, it will unfold the new buffer
with `icalendar-unfold-region'. This can in some cases have
undesirable effects (see its docstring), so the original contents
are preserved unchanged in the current buffer.
In both cases, after switching to the new buffer, this command
offers to kill the original buffer.
It is recommended to turn off `auto-fill-mode' when viewing an
unfolded buffer, so that filling does not interfere with syntax
highlighting. This function offers to disable `auto-fill-mode' if
it is enabled in the new buffer; consider using
`visual-line-mode' instead."
(interactive)
(when (and buffer-file-name (buffer-modified-p))
(when (y-or-n-p (format "Save before reloading from %s?"
(file-name-nondirectory buffer-file-name)))
(save-buffer)))
(let ((old-buffer (current-buffer))
(mmode major-mode)
(uf-buffer (if buffer-file-name
(ical:unfolded-buffer-from-file buffer-file-name)
(ical:unfolded-buffer-from-buffer (current-buffer)))))
(switch-to-buffer uf-buffer)
;; restart original major mode, in case the new buffer is
;; still in fundamental-mode: TODO: is this necessary?
(funcall mmode)
(when (y-or-n-p (format "Unfolded buffer is shown. Kill %s?"
(buffer-name old-buffer)))
(kill-buffer old-buffer))
(when (and auto-fill-function (y-or-n-p "Disable auto-fill-mode?"))
(auto-fill-mode -1))))