emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/smartparens 1ffd35cd0f: feat: rework how globalized modes


From: ELPA Syncer
Subject: [nongnu] elpa/smartparens 1ffd35cd0f: feat: rework how globalized modes are initialized
Date: Wed, 3 Apr 2024 16:02:02 -0400 (EDT)

branch: elpa/smartparens
commit 1ffd35cd0f4bfd723c731d7f881735c527d10b23
Author: Matus Goljer <matus.goljer@gmail.com>
Commit: Matus Goljer <matus.goljer@gmail.com>

    feat: rework how globalized modes are initialized
    
    The sp-turn-off-* functions are marked as obsolete because they serve
    no purpose, every user can implement them with a lambda if necessary.
    
    The smartparens mode and strict mode now use common code to turn
    themselves on.
    
    The show-smartparens-mode only uses sp-ignore-modes-list and turns
    itself on in comint and special modes automatically.
---
 smartparens.el | 50 +++++++++++++++++++++++++++++++++++++-------------
 1 file changed, 37 insertions(+), 13 deletions(-)

diff --git a/smartparens.el b/smartparens.el
index f329e2c49e..d7c35e7e1b 100644
--- a/smartparens.el
+++ b/smartparens.el
@@ -813,9 +813,7 @@ after the smartparens indicator in the mode list."
 (defun turn-on-smartparens-strict-mode ()
   "Turn on `smartparens-strict-mode'."
   (interactive)
-  (unless (or (member major-mode sp-ignore-modes-list)
-              (and (not (derived-mode-p 'comint-mode))
-                   (eq (get major-mode 'mode-class) 'special)))
+  (when (sp--should-turn-on-p)
     (smartparens-strict-mode 1)))
 
 ;;;###autoload
@@ -824,6 +822,10 @@ after the smartparens indicator in the mode list."
   (interactive)
   (smartparens-strict-mode -1))
 
+(make-obsolete 'turn-off-smartparens-strict-mode
+               "this function is marked for deletion."
+               "2024-04-03")
+
 (defun sp--init ()
   "Initialize the buffer local smartparens state.
 
@@ -943,6 +945,15 @@ MODES."
   smartparens-mode
   turn-on-smartparens-mode)
 
+(defun sp--should-turn-on-p ()
+  "Return non-nil if `smartparens-global-mode' should be turned on.
+
+The same check is also used for
+`smartparens-global-strict-mode'."
+  (not (or (member major-mode sp-ignore-modes-list)
+           (and (not (derived-mode-p 'comint-mode))
+                (eq (get major-mode 'mode-class) 'special)))))
+
 ;;;###autoload
 (defun turn-on-smartparens-mode ()
   "Turn on `smartparens-mode'.
@@ -958,10 +969,8 @@ Additionally, buffers on `sp-ignore-modes-list' are 
ignored.
 You can still turn on smartparens in these mode manually (or
 in mode's startup-hook etc.) by calling `smartparens-mode'."
   (interactive)
-  (unless (or (member major-mode sp-ignore-modes-list)
-              (and (not (derived-mode-p 'comint-mode))
-                   (eq (get major-mode 'mode-class) 'special)))
-    (smartparens-mode t)))
+  (when (sp--should-turn-on-p)
+    (smartparens-mode 1)))
 
 ;;;###autoload
 (defun turn-off-smartparens-mode ()
@@ -969,6 +978,10 @@ in mode's startup-hook etc.) by calling 
`smartparens-mode'."
   (interactive)
   (smartparens-mode -1))
 
+(make-obsolete 'turn-off-smartparens-mode
+               "this function is marked for deletion."
+               "2024-04-03")
+
 ;; insert custom
 (defcustom sp-autoinsert-pair t
   "If non-nil, autoinsert pairs.  See `sp-insert-pair'."
@@ -9570,16 +9583,23 @@ support custom pairs."
 ;;;###autoload
 (define-globalized-minor-mode show-smartparens-global-mode
   show-smartparens-mode
-  turn-on-show-smartparens-mode)
+  turn-on-show-smartparens-mode
+  :group 'show-smartparens)
 
 ;;;###autoload
 (defun turn-on-show-smartparens-mode ()
-  "Turn on `show-smartparens-mode'."
+  "Turn on `show-smartparens-mode'.
+
+This function is used to turn on `show-smartparens-global-mode'.
+
+Major modes on `sp-ignore-modes-list' are ignored when turning on
+the globalized mode.
+
+You can still turn on `show-smartparens-mode' manually by calling
+\\[show-smartparens-mode.]"
   (interactive)
-  (unless (or (member major-mode sp-ignore-modes-list)
-              (and (not (derived-mode-p 'comint-mode))
-                   (eq (get major-mode 'mode-class) 'special)))
-    (show-smartparens-mode t)))
+  (unless (member major-mode sp-ignore-modes-list)
+    (show-smartparens-mode 1)))
 
 ;;;###autoload
 (defun turn-off-show-smartparens-mode ()
@@ -9587,6 +9607,10 @@ support custom pairs."
   (interactive)
   (show-smartparens-mode -1))
 
+(make-obsolete 'turn-off-show-smartparens-mode
+               "this function is marked for deletion."
+               "2024-04-03")
+
 (defun sp-show-enclosing-pair ()
   "Highlight the enclosing pair around point."
   (interactive))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]