aboutsummaryrefslogtreecommitdiffstats
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
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).
-rw-r--r--etc/NEWS14
-rw-r--r--lisp/comint.el46
-rw-r--r--lisp/ielm.el10
-rw-r--r--lisp/shell.el33
4 files changed, 59 insertions, 44 deletions
diff --git a/etc/NEWS b/etc/NEWS
index d5aad9afc27..b9c4ef62ceb 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1214,6 +1214,14 @@ When nil, this prevents comint from deleting the current input when
1214inserting previous input using '<mouse-2>'. The default is t, to 1214inserting previous input using '<mouse-2>'. The default is t, to
1215preserve past behavior. 1215preserve past behavior.
1216 1216
1217---
1218*** New minor mode 'comint-fontify-input-mode'.
1219This minor mode is enabled by default in "*shell*" and "*ielm*"
1220buffers. It fontifies input text according to 'shell-mode' or
1221'emacs-lisp-mode' font-lock rules. Customize the user options
1222'shell-fontify-input-enable' and 'ielm-fontify-input-enable' to nil if
1223you don't want to enable input fontification by default.
1224
1217** Mwheel 1225** Mwheel
1218 1226
1219--- 1227---
@@ -2520,6 +2528,12 @@ behavior, customize the new 'eshell-lisp-form-nil-is-failure' option.
2520Enabling this will automatically kill a "*shell*" buffer as soon as 2528Enabling this will automatically kill a "*shell*" buffer as soon as
2521the shell session terminates. 2529the shell session terminates.
2522 2530
2531---
2532*** New minor mode 'shell-highlight-undef-mode'
2533Customize 'shell-highlight-undef-enable' to t if you want to enable
2534this minor mode in "*shell*" buffers. It will highlight undefined
2535commands with a warning face as you type.
2536
2523** Calc 2537** Calc
2524 2538
2525+++ 2539+++
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))
diff --git a/lisp/ielm.el b/lisp/ielm.el
index ad41cb1f6bd..fd41afa2437 100644
--- a/lisp/ielm.el
+++ b/lisp/ielm.el
@@ -474,11 +474,11 @@ nonempty, then flushes the buffer."
474 474
475;;; Input fontification 475;;; Input fontification
476 476
477(defcustom ielm-comint-fl-enable t 477(defcustom ielm-fontify-input-enable t
478 "Enable fontification of input in ielm buffers. 478 "Enable fontification of input in ielm buffers.
479This variable only has effect when creating an ielm buffer. Use 479This variable only has effect when creating an ielm buffer. Use
480the command `comint-fl-mode' to toggle fontification of input in 480the command `comint-fontify-input-mode' to toggle fontification
481an already existing ielm buffer." 481of input in an already existing ielm buffer."
482 :type 'boolean 482 :type 'boolean
483 :safe 'booleanp 483 :safe 'booleanp
484 :version "29.1") 484 :version "29.1")
@@ -556,8 +556,8 @@ Customized bindings may be defined in `ielm-map', which currently contains:
556 :syntax-table emacs-lisp-mode-syntax-table 556 :syntax-table emacs-lisp-mode-syntax-table
557 :after-hook 557 :after-hook
558 (and (null comint-use-prompt-regexp) 558 (and (null comint-use-prompt-regexp)
559 ielm-comint-fl-enable 559 ielm-fontify-input-enable
560 (comint-fl-mode)) 560 (comint-fontify-input-mode))
561 561
562 (setq comint-prompt-regexp (concat "^" (regexp-quote ielm-prompt))) 562 (setq comint-prompt-regexp (concat "^" (regexp-quote ielm-prompt)))
563 (setq-local paragraph-separate "\\'") 563 (setq-local paragraph-separate "\\'")
diff --git a/lisp/shell.el b/lisp/shell.el
index 18bb3722427..641f274045d 100644
--- a/lisp/shell.el
+++ b/lisp/shell.el
@@ -308,10 +308,11 @@ for Shell mode only."
308 (const :tag "on" t)) 308 (const :tag "on" t))
309 :group 'shell) 309 :group 'shell)
310 310
311(defcustom shell-comint-fl-enable t 311(defcustom shell-fontify-input-enable t
312 "Enable fontification of input in shell buffers. 312 "Enable fontification of input in shell buffers.
313This variable only has effect when the shell is started. Use the 313This variable only has effect when the shell is started. Use the
314command `comint-fl-mode' to toggle fontification of input." 314command `comint-fontify-input-mode' to toggle fontification of
315input."
315 :type 'boolean 316 :type 'boolean
316 :group 'shell 317 :group 'shell
317 :safe 'booleanp 318 :safe 'booleanp
@@ -623,8 +624,8 @@ command."
623 :interactive nil 624 :interactive nil
624 :after-hook 625 :after-hook
625 (unless comint-use-prompt-regexp 626 (unless comint-use-prompt-regexp
626 (if shell-comint-fl-enable 627 (if shell-fontify-input-enable
627 (comint-fl-mode)) 628 (comint-fontify-input-mode))
628 (if shell-highlight-undef-enable 629 (if shell-highlight-undef-enable
629 (shell-highlight-undef-mode))) 630 (shell-highlight-undef-mode)))
630 631
@@ -1664,8 +1665,8 @@ Similar to `executable-find', but use cache stored in
1664 (if buf (buffer-local-value 'default-directory buf) 1665 (if buf (buffer-local-value 'default-directory buf)
1665 default-directory))) 1666 default-directory)))
1666 (cond 1667 (cond
1667 ;; Don't highlight command output. Mostly useful if 1668 ;; Don't fontify command output. Mostly useful if
1668 ;; `comint-fl-mode' is disabled. 1669 ;; `comint-fontify-input-mode' is disabled.
1669 ((text-property-any beg (point) 'field 'output) 1670 ((text-property-any beg (point) 'field 'output)
1670 nil) 1671 nil)
1671 ((member cmd shell-highlight-undef-aliases) 1672 ((member cmd shell-highlight-undef-aliases)
@@ -1696,7 +1697,7 @@ Similar to `executable-find', but use cache stored in
1696(define-minor-mode shell-highlight-undef-mode 1697(define-minor-mode shell-highlight-undef-mode
1697 "Highlight undefined shell commands and aliases. 1698 "Highlight undefined shell commands and aliases.
1698This minor mode is mostly useful in `shell-mode' buffers and 1699This minor mode is mostly useful in `shell-mode' buffers and
1699works better if `comint-fl-mode' is enabled." 1700works better if `comint-fontify-input-mode' is enabled."
1700 :init-value nil 1701 :init-value nil
1701 (if shell--highlight-undef-indirect 1702 (if shell--highlight-undef-indirect
1702 (progn 1703 (progn
@@ -1706,7 +1707,7 @@ works better if `comint-fl-mode' is enabled."
1706 (with-current-buffer buf 1707 (with-current-buffer buf
1707 (font-lock-remove-keywords nil shell-highlight-undef-keywords)))) 1708 (font-lock-remove-keywords nil shell-highlight-undef-keywords))))
1708 (font-lock-remove-keywords nil shell-highlight-undef-keywords)) 1709 (font-lock-remove-keywords nil shell-highlight-undef-keywords))
1709 (remove-hook 'comint-fl-mode-hook 1710 (remove-hook 'comint-fontify-input-mode-hook
1710 #'shell-highlight-undef-mode-restart t) 1711 #'shell-highlight-undef-mode-restart t)
1711 1712
1712 (when shell-highlight-undef-mode 1713 (when shell-highlight-undef-mode
@@ -1722,9 +1723,9 @@ works better if `comint-fl-mode' is enabled."
1722 (concat 1723 (concat
1723 "\\(" 1724 "\\("
1724 "[;(){}`|&]" 1725 "[;(){}`|&]"
1725 (if comint-fl-mode 1726 (if comint-fontify-input-mode
1726 ;; `comint-fl-mode' already puts point-min on end of 1727 ;; `comint-fontify-input-mode' already puts
1727 ;; prompt 1728 ;; point-min on end of prompt
1728 "" 1729 ""
1729 (concat "\\|" comint-prompt-regexp)) 1730 (concat "\\|" comint-prompt-regexp))
1730 "\\|^" 1731 "\\|^"
@@ -1740,7 +1741,7 @@ works better if `comint-fl-mode' is enabled."
1740 (lambda () 1741 (lambda ()
1741 (setq shell-highlight-undef-regexp regexp) 1742 (setq shell-highlight-undef-regexp regexp)
1742 (font-lock-add-keywords nil shell-highlight-undef-keywords t)))) 1743 (font-lock-add-keywords nil shell-highlight-undef-keywords t))))
1743 (cond (comint-fl-mode 1744 (cond (comint-fontify-input-mode
1744 (setq shell--highlight-undef-indirect setup) 1745 (setq shell--highlight-undef-indirect setup)
1745 (if-let ((buf (comint-indirect-buffer t))) 1746 (if-let ((buf (comint-indirect-buffer t)))
1746 (with-current-buffer buf 1747 (with-current-buffer buf
@@ -1748,7 +1749,7 @@ works better if `comint-fl-mode' is enabled."
1748 (add-hook 'comint-indirect-setup-hook setup nil t))) 1749 (add-hook 'comint-indirect-setup-hook setup nil t)))
1749 (t (funcall setup)))) 1750 (t (funcall setup))))
1750 1751
1751 (add-hook 'comint-fl-mode-hook 1752 (add-hook 'comint-fontify-input-mode-hook
1752 #'shell-highlight-undef-mode-restart nil t)) 1753 #'shell-highlight-undef-mode-restart nil t))
1753 1754
1754 (font-lock-flush)) 1755 (font-lock-flush))
@@ -1756,9 +1757,9 @@ works better if `comint-fl-mode' is enabled."
1756(defun shell-highlight-undef-mode-restart () 1757(defun shell-highlight-undef-mode-restart ()
1757 "If `shell-highlight-undef-mode' is on, restart it. 1758 "If `shell-highlight-undef-mode' is on, restart it.
1758`shell-highlight-undef-mode' performs its setup differently 1759`shell-highlight-undef-mode' performs its setup differently
1759depending on `comint-fl-mode'. It's useful to call this function 1760depending on `comint-fontify-input-mode'. It's useful to call
1760when switching `comint-fl-mode' in order to make 1761this function when switching `comint-fontify-input-mode' in order
1761`shell-highlight-undef-mode' redo its setup." 1762to make `shell-highlight-undef-mode' redo its setup."
1762 (when shell-highlight-undef-mode 1763 (when shell-highlight-undef-mode
1763 (shell-highlight-undef-mode 1))) 1764 (shell-highlight-undef-mode 1)))
1764 1765