aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/comint.el
diff options
context:
space:
mode:
authorMiha Rihtaršič2022-09-30 20:28:15 +0200
committerLars Ingebrigtsen2022-09-30 21:15:06 +0200
commitcd4208f6d8e4bcbfa326a2b70489ee3c0643e53f (patch)
treeaf7a9d836b19a896b1598ee1e0c2e20bbf81d6af /lisp/comint.el
parent90744ff0be581b69cedea1194b7e78265bdb67a4 (diff)
downloademacs-cd4208f6d8e4bcbfa326a2b70489ee3c0643e53f.tar.gz
emacs-cd4208f6d8e4bcbfa326a2b70489ee3c0643e53f.zip
Rename comint-fl-* to comint-fontify-input-* and mention it in NEWS
* lisp/comint.el (comint-fontify-input-mode): (comint--fontify-input-saved-jit-lock-contextually): (comint--fontify-input-on): (comint--fontify-input-off): (comint--fontify-input-ppss-flush-indirect): (comint--fontify-input-fontify-region): Replace comint-fl-* with comint-fontify-input-*. * lisp/ielm.el (ielm-fontify-input-enable): (ielm-fontify-input-enable): (ielm-indirect-setup-hook): (inferior-emacs-lisp-mode): Replace comint-fl-* with comint-fontify-input-*. * lisp/shell.el (shell-comint-fl-enable): (shell-mode): Replace comint-fl-* with comint-fontify-input-*. * etc/NEWS: Mention the new modes and how to disable or enable them (bug#58169).
Diffstat (limited to 'lisp/comint.el')
-rw-r--r--lisp/comint.el46
1 files changed, 23 insertions, 23 deletions
diff --git a/lisp/comint.el b/lisp/comint.el
index 15c9388ea4f..a70a75c6487 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -1945,7 +1945,7 @@ Similarly for Soar, Scheme, etc."
1945 (when comint-highlight-input 1945 (when comint-highlight-input
1946 (add-text-properties beg end 1946 (add-text-properties beg end
1947 '( font-lock-face comint-highlight-input 1947 '( font-lock-face comint-highlight-input
1948 comint--fl-inhibit-fontification t 1948 comint--fontify-input-inhibit-fontification t
1949 front-sticky t ))) 1949 front-sticky t )))
1950 (unless comint-use-prompt-regexp 1950 (unless comint-use-prompt-regexp
1951 ;; Give old user input a field property of `input', to 1951 ;; Give old user input a field property of `input', to
@@ -3976,9 +3976,9 @@ fontification and other behavior of the indirect buffer."
3976(defvar-local comint--indirect-buffer nil 3976(defvar-local comint--indirect-buffer nil
3977 "Indirect buffer used for input fontification.") 3977 "Indirect buffer used for input fontification.")
3978 3978
3979(defvar-local comint--fl-saved-jit-lock-contextually nil) 3979(defvar-local comint--fontify-input-saved-jit-lock-contextually nil)
3980 3980
3981(define-minor-mode comint-fl-mode 3981(define-minor-mode comint-fontify-input-mode
3982 "Enable input fontification in the current comint buffer. 3982 "Enable input fontification in the current comint buffer.
3983This minor mode is useful if the current major mode derives from 3983This minor mode is useful if the current major mode derives from
3984`comint-mode' and if `comint-indirect-setup-function' is set. 3984`comint-mode' and if `comint-indirect-setup-function' is set.
@@ -3993,71 +3993,71 @@ This function signals an error if `comint-use-prompt-regexp' is
3993non-nil. Input fontification isn't compatible with this 3993non-nil. Input fontification isn't compatible with this
3994setting." 3994setting."
3995 :lighter nil 3995 :lighter nil
3996 (if comint-fl-mode 3996 (if comint-fontify-input-mode
3997 (let ((success nil)) 3997 (let ((success nil))
3998 (unwind-protect 3998 (unwind-protect
3999 (progn 3999 (progn
4000 (comint--fl-on) 4000 (comint--fontify-input-on)
4001 (setq success t)) 4001 (setq success t))
4002 (unless success 4002 (unless success
4003 (setq comint-fl-mode nil) 4003 (setq comint-fontify-input-mode nil)
4004 (comint--fl-off)))) 4004 (comint--fontify-input-off))))
4005 (comint--fl-off))) 4005 (comint--fontify-input-off)))
4006 4006
4007(defun comint--fl-on () 4007(defun comint--fontify-input-on ()
4008 "Enable input fontification in the current comint buffer." 4008 "Enable input fontification in the current comint buffer."
4009 (comint--fl-off) 4009 (comint--fontify-input-off)
4010 4010
4011 (when comint-use-prompt-regexp 4011 (when comint-use-prompt-regexp
4012 (error 4012 (error
4013 "Input fontification is incompatible with `comint-use-prompt-regexp'")) 4013 "Input fontification is incompatible with `comint-use-prompt-regexp'"))
4014 4014
4015 (add-function :around (local 'font-lock-fontify-region-function) 4015 (add-function :around (local 'font-lock-fontify-region-function)
4016 #'comint--fl-fontify-region) 4016 #'comint--fontify-input-fontify-region)
4017 ;; `before-change-functions' are only run in the current buffer and 4017 ;; `before-change-functions' are only run in the current buffer and
4018 ;; not in its indirect buffers, which means that we must manually 4018 ;; not in its indirect buffers, which means that we must manually
4019 ;; flush ppss cache 4019 ;; flush ppss cache
4020 (add-hook 'before-change-functions 4020 (add-hook 'before-change-functions
4021 #'comint--fl-ppss-flush-indirect 99 t) 4021 #'comint--fontify-input-ppss-flush-indirect 99 t)
4022 4022
4023 ;; Set up contextual fontification 4023 ;; Set up contextual fontification
4024 (unless (booleanp jit-lock-contextually) 4024 (unless (booleanp jit-lock-contextually)
4025 (setq comint--fl-saved-jit-lock-contextually 4025 (setq comint--fontify-input-saved-jit-lock-contextually
4026 jit-lock-contextually) 4026 jit-lock-contextually)
4027 (setq-local jit-lock-contextually t) 4027 (setq-local jit-lock-contextually t)
4028 (when jit-lock-mode 4028 (when jit-lock-mode
4029 (jit-lock-mode t)))) 4029 (jit-lock-mode t))))
4030 4030
4031(defun comint--fl-off () 4031(defun comint--fontify-input-off ()
4032 "Disable input fontification in the current comint buffer." 4032 "Disable input fontification in the current comint buffer."
4033 (remove-function (local 'font-lock-fontify-region-function) 4033 (remove-function (local 'font-lock-fontify-region-function)
4034 #'comint--fl-fontify-region) 4034 #'comint--fontify-input-fontify-region)
4035 (remove-hook 'before-change-functions 4035 (remove-hook 'before-change-functions
4036 #'comint--fl-ppss-flush-indirect t) 4036 #'comint--fontify-input-ppss-flush-indirect t)
4037 4037
4038 ;; Reset contextual fontification 4038 ;; Reset contextual fontification
4039 (when comint--fl-saved-jit-lock-contextually 4039 (when comint--fontify-input-saved-jit-lock-contextually
4040 (setq-local jit-lock-contextually 4040 (setq-local jit-lock-contextually
4041 comint--fl-saved-jit-lock-contextually) 4041 comint--fontify-input-saved-jit-lock-contextually)
4042 (setq comint--fl-saved-jit-lock-contextually nil) 4042 (setq comint--fontify-input-saved-jit-lock-contextually nil)
4043 (when jit-lock-mode 4043 (when jit-lock-mode
4044 (jit-lock-mode t))) 4044 (jit-lock-mode t)))
4045 4045
4046 (font-lock-flush)) 4046 (font-lock-flush))
4047 4047
4048(defun comint--fl-ppss-flush-indirect (beg &rest rest) 4048(defun comint--fontify-input-ppss-flush-indirect (beg &rest rest)
4049 (when-let ((buf (comint-indirect-buffer t))) 4049 (when-let ((buf (comint-indirect-buffer t)))
4050 (with-current-buffer buf 4050 (with-current-buffer buf
4051 (when (memq #'syntax-ppss-flush-cache before-change-functions) 4051 (when (memq #'syntax-ppss-flush-cache before-change-functions)
4052 (apply #'syntax-ppss-flush-cache beg rest))))) 4052 (apply #'syntax-ppss-flush-cache beg rest)))))
4053 4053
4054(defun comint--fl-fontify-region (fun beg end verbose) 4054(defun comint--fontify-input-fontify-region (fun beg end verbose)
4055 "Fontify process output and user input in the current comint buffer. 4055 "Fontify process output and user input in the current comint buffer.
4056First, fontify the region between BEG and END using FUN. Then 4056First, fontify the region between BEG and END using FUN. Then
4057fontify only the input text in the region with the help of an 4057fontify only the input text in the region with the help of an
4058indirect buffer. VERBOSE is passed to the fontify-region 4058indirect buffer. VERBOSE is passed to the fontify-region
4059functions. Skip fontification of input regions with non-nil 4059functions. Skip fontification of input regions with non-nil
4060`comint--fl-inhibit-fontification' text property." 4060`comint--fontify-input-inhibit-fontification' text property."
4061 (pcase (funcall fun beg end verbose) 4061 (pcase (funcall fun beg end verbose)
4062 (`(jit-lock-bounds ,beg1 . ,end1) 4062 (`(jit-lock-bounds ,beg1 . ,end1)
4063 (setq beg beg1 end end1))) 4063 (setq beg beg1 end end1)))
@@ -4069,7 +4069,7 @@ functions. Skip fontification of input regions with non-nil
4069 (comint--intersect-regions 4069 (comint--intersect-regions
4070 nil (lambda (beg end) 4070 nil (lambda (beg end)
4071 (unless (get-text-property 4071 (unless (get-text-property
4072 beg 'comint--fl-inhibit-fontification) 4072 beg 'comint--fontify-input-inhibit-fontification)
4073 (font-lock-fontify-region beg end verbose))) 4073 (font-lock-fontify-region beg end verbose)))
4074 beg end))) 4074 beg end)))
4075 (`((jit-lock-bounds ,beg1 . ,_) . (jit-lock-bounds ,_ . ,end1)) 4075 (`((jit-lock-bounds ,beg1 . ,_) . (jit-lock-bounds ,_ . ,end1))