Function: strokes-encode-buffer
strokes-encode-buffer is an interactive and byte-compiled function
defined in strokes.el.gz.
Signature
(strokes-encode-buffer &optional BUFFER FORCE)
Documentation
Convert the glyphs in BUFFER to their base-64 ASCII representations.
Optional BUFFER defaults to the current buffer. Optional FORCE non-nil will ignore the buffer's read-only status.
Probably introduced at or before Emacs version 21.1.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/strokes.el.gz
(defun strokes-encode-buffer (&optional buffer force)
"Convert the glyphs in BUFFER to their base-64 ASCII representations.
Optional BUFFER defaults to the current buffer.
Optional FORCE non-nil will ignore the buffer's read-only status."
;; ### NOTE !!! ### (for me)
;; For later on, you can/should make the inserted strings atomic
;; extents, so that the users have a clue that they shouldn't be
;; editing inside them. Plus, if you make them extents, you can
;; very easily just hide the glyphs, so if you unstrokify, and the
;; restrokify, then those that already are glyphed don't need to be
;; re-calculated, etc. It's just nicer that way. The only things
;; to worry about is cleanup (i.e. do the glyphs get gc'd when the
;; buffer is killed?
;; (interactive "*bUnstrokify buffer: ")
(interactive)
(with-current-buffer (setq buffer (or buffer (current-buffer)))
(when (or (not buffer-read-only)
force
inhibit-read-only
(y-or-n-p
(format "Buffer %s is read-only. Encode anyway? " buffer)))
(message "Encoding strokes in %s..." buffer)
;; (map-extents
;; (lambda (ext buf)
;; (when (eq (extent-property ext 'type) 'stroke-glyph)
;; (goto-char (extent-start-position ext))
;; (delete-char 1) ; ### What the hell do I do here? ###
;; (insert "+/" (extent-property ext 'data) "/")
;; (delete-extent ext))))))
(let ((inhibit-read-only t)
(start nil)
glyph)
(while (or (and (bobp)
(get-text-property (point) 'type))
(setq start (next-single-property-change (point) 'type)))
(when (eq 'stroke-glyph (get-text-property (point) 'type))
(goto-char start)
(setq start (point-marker)
glyph (get-text-property start 'display))
(insert "+/" (get-text-property (point) 'data) ?/)
(delete-char 1)
(add-text-properties start (point)
(list 'type 'stroke-string
'face 'strokes-char
'stroke-glyph glyph
'display nil))))
(message "Encoding strokes in %s...done" buffer)))))