空格前缀缓冲区是指名称以空格开头的缓冲区。不确定这种缓冲区的官方术语是什么。
我认为空间前缀缓冲区的唯一区别是它们禁用了撤消,但似乎还有其他差异导致包htmlize
对空间前缀缓冲区的反应不同。
(require 'htmlize)
;; function to write stuff on current buffer and call htmlize-region
(defun my-test-htmlize ()
(insert "1234567")
(emacs-lisp-mode)
;; (put-text-property 1 2 'font-lock-face "bold")
(put-text-property 3 4 'font-lock-face 'bold)
(with-current-buffer (htmlize-region (point-min)
(point-max))
(buffer-string)))
;; function that makes a (failed) attempt to make current buffer behave like a normal buffer
(defun my-make-buffer-normal ()
(buffer-enable-undo))
;; like with-temp-buffer, except it uses a buffer that is not a space prefix buffer.
(defmacro my-with-temp-buffer-with-no-space-prefix (&rest body)
(declare (indent 0) (debug t))
(let ((temp-buffer (make-symbol "temp-buffer")))
`(let ((,temp-buffer (generate-new-buffer "*tempwd2kemgv*")))
(with-current-buffer ,temp-buffer
(unwind-protect
(progn ,@body)
(and (buffer-name ,temp-buffer)
(kill-buffer ,temp-buffer)))))))
;; In a normal buffer, bold face is htmlized.
(my-with-temp-buffer-with-no-space-prefix
(my-test-htmlize))
;; In a space prefix buffer, bold face is not htmlized.
(with-temp-buffer
(my-test-htmlize))
;; Bold face is still not htmlized.
(with-temp-buffer
(my-make-buffer-normal)
(my-test-htmlize))