Function: comint-indirect-buffer
comint-indirect-buffer is a byte-compiled function defined in
comint.el.gz.
Signature
(comint-indirect-buffer &optional NO-CREATE)
Documentation
Return an indirect comint fontification buffer.
If an indirect buffer for the current buffer already exists,
return it, otherwise create it first and set it up by calling
comint-indirect-setup-function with zero arguments, turning on
font-lock, and running comint-indirect-setup-hook. This setup
happens with delay-mode-hooks(var)/delay-mode-hooks(fun) set to t in order to prevent
possible SETUP-FUN's mode hooks from running.
If an indirect buffer doesn't exist and NO-CREATE is non-nil, return nil.
Source Code
;; Defined in /usr/src/emacs/lisp/comint.el.gz
(defun comint-indirect-buffer (&optional no-create)
"Return an indirect comint fontification buffer.
If an indirect buffer for the current buffer already exists,
return it, otherwise create it first and set it up by calling
`comint-indirect-setup-function' with zero arguments, turning on
font-lock, and running `comint-indirect-setup-hook'. This setup
happens with `delay-mode-hooks' set to t in order to prevent
possible SETUP-FUN's mode hooks from running.
If an indirect buffer doesn't exist and NO-CREATE is non-nil,
return nil."
(or
comint--indirect-buffer
(unless no-create
(let ((setup-hook
(if (local-variable-p 'comint-indirect-setup-hook)
(list comint-indirect-setup-hook)))
(setup-fun comint-indirect-setup-function))
(add-hook 'change-major-mode-hook #'comint--indirect-cleanup
nil t)
(with-current-buffer
(setq comint--indirect-buffer
(make-indirect-buffer
(current-buffer)
(generate-new-buffer-name
(concat " " (buffer-name) "-comint-indirect"))))
(setq-local delay-mode-hooks t)
(when setup-fun
(let ((change-major-mode-hook nil)
(after-change-major-mode-hook nil))
(funcall setup-fun)))
(setq-local font-lock-dont-widen t)
(setq-local font-lock-support-mode nil)
(font-lock-mode)
(when setup-hook
(setq-local comint-indirect-setup-hook
(car setup-hook)))
(run-hooks 'comint-indirect-setup-hook))
comint--indirect-buffer))))