From d3915356a192a841b17e7ad73f24c12710f3b5e8 Mon Sep 17 00:00:00 2001 From: Andreas Gerler Date: Sun, 22 Dec 2024 13:18:46 +0100 Subject: [PATCH] update smartparens Signed-off-by: Andreas Gerler --- .../smartparens-pkg.el | 13 - .../smartparens-autoloads.el | 223 +++------ .../smartparens-c.el | 0 .../smartparens-clojure.el | 10 +- .../smartparens-config.el | 25 +- .../smartparens-coq.el | 60 +++ .../smartparens-crystal.el | 0 .../smartparens-elixir.el | 1 - .../smartparens-erlang.el | 0 .../smartparens-ess.el | 1 - .../smartparens-go.el | 0 .../smartparens-haskell.el | 0 .../smartparens-html.el | 0 .../smartparens-javascript.el | 22 +- .../smartparens-latex.el | 0 .../smartparens-lua.el | 2 +- .../smartparens-markdown.el | 0 .../smartparens-ml.el | 0 .../smartparens-org.el | 21 +- .../smartparens-pkg.el | 10 + .../smartparens-python.el | 4 +- .../smartparens-racket.el | 0 .../smartparens-rst.el | 0 .../smartparens-ruby.el | 12 +- .../smartparens-rust.el | 4 +- .../smartparens-scala.el | 0 .../smartparens-swift.el | 0 .../smartparens-text.el | 0 .../smartparens-unison.el | 0 .../smartparens.el | 471 ++++++++++++++---- .../sp-sublimetext-like.el | 0 elpa/smartparens-readme.txt | 17 - 32 files changed, 614 insertions(+), 282 deletions(-) delete mode 100644 elpa/smartparens-20230529.1017/smartparens-pkg.el rename elpa/{smartparens-20230529.1017 => smartparens-20241220.1254}/smartparens-autoloads.el (71%) rename elpa/{smartparens-20230529.1017 => smartparens-20241220.1254}/smartparens-c.el (100%) rename elpa/{smartparens-20230529.1017 => smartparens-20241220.1254}/smartparens-clojure.el (87%) rename elpa/{smartparens-20230529.1017 => smartparens-20241220.1254}/smartparens-config.el (85%) create mode 100644 elpa/smartparens-20241220.1254/smartparens-coq.el rename elpa/{smartparens-20230529.1017 => smartparens-20241220.1254}/smartparens-crystal.el (100%) rename elpa/{smartparens-20230529.1017 => smartparens-20241220.1254}/smartparens-elixir.el (99%) rename elpa/{smartparens-20230529.1017 => smartparens-20241220.1254}/smartparens-erlang.el (100%) rename elpa/{smartparens-20230529.1017 => smartparens-20241220.1254}/smartparens-ess.el (99%) rename elpa/{smartparens-20230529.1017 => smartparens-20241220.1254}/smartparens-go.el (100%) rename elpa/{smartparens-20230529.1017 => smartparens-20241220.1254}/smartparens-haskell.el (100%) rename elpa/{smartparens-20230529.1017 => smartparens-20241220.1254}/smartparens-html.el (100%) rename elpa/{smartparens-20230529.1017 => smartparens-20241220.1254}/smartparens-javascript.el (69%) rename elpa/{smartparens-20230529.1017 => smartparens-20241220.1254}/smartparens-latex.el (100%) rename elpa/{smartparens-20230529.1017 => smartparens-20241220.1254}/smartparens-lua.el (98%) rename elpa/{smartparens-20230529.1017 => smartparens-20241220.1254}/smartparens-markdown.el (100%) rename elpa/{smartparens-20230529.1017 => smartparens-20241220.1254}/smartparens-ml.el (100%) rename elpa/{smartparens-20230529.1017 => smartparens-20241220.1254}/smartparens-org.el (75%) create mode 100644 elpa/smartparens-20241220.1254/smartparens-pkg.el rename elpa/{smartparens-20230529.1017 => smartparens-20241220.1254}/smartparens-python.el (97%) rename elpa/{smartparens-20230529.1017 => smartparens-20241220.1254}/smartparens-racket.el (100%) rename elpa/{smartparens-20230529.1017 => smartparens-20241220.1254}/smartparens-rst.el (100%) rename elpa/{smartparens-20230529.1017 => smartparens-20241220.1254}/smartparens-ruby.el (97%) rename elpa/{smartparens-20230529.1017 => smartparens-20241220.1254}/smartparens-rust.el (96%) rename elpa/{smartparens-20230529.1017 => smartparens-20241220.1254}/smartparens-scala.el (100%) rename elpa/{smartparens-20230529.1017 => smartparens-20241220.1254}/smartparens-swift.el (100%) rename elpa/{smartparens-20230529.1017 => smartparens-20241220.1254}/smartparens-text.el (100%) rename elpa/{smartparens-20230529.1017 => smartparens-20241220.1254}/smartparens-unison.el (100%) rename elpa/{smartparens-20230529.1017 => smartparens-20241220.1254}/smartparens.el (96%) rename elpa/{smartparens-20230529.1017 => smartparens-20241220.1254}/sp-sublimetext-like.el (100%) delete mode 100644 elpa/smartparens-readme.txt diff --git a/elpa/smartparens-20230529.1017/smartparens-pkg.el b/elpa/smartparens-20230529.1017/smartparens-pkg.el deleted file mode 100644 index 14574d7b..00000000 --- a/elpa/smartparens-20230529.1017/smartparens-pkg.el +++ /dev/null @@ -1,13 +0,0 @@ -(define-package "smartparens" "20230529.1017" "Automatic insertion, wrapping and paredit-like navigation with user defined pairs." - '((dash "2.13.0") - (cl-lib "0.3")) - :commit "79a338db115f441cd47bb91e6f75816c5e78a772" :authors - '(("Matus Goljer" . "matus.goljer@gmail.com")) - :maintainer - '("Matus Goljer" . "matus.goljer@gmail.com") - :keywords - '("abbrev" "convenience" "editing") - :url "https://github.com/Fuco1/smartparens") -;; Local Variables: -;; no-byte-compile: t -;; End: diff --git a/elpa/smartparens-20230529.1017/smartparens-autoloads.el b/elpa/smartparens-20241220.1254/smartparens-autoloads.el similarity index 71% rename from elpa/smartparens-20230529.1017/smartparens-autoloads.el rename to elpa/smartparens-20241220.1254/smartparens-autoloads.el index 5135ae0d..9a8a9fcc 100644 --- a/elpa/smartparens-20230529.1017/smartparens-autoloads.el +++ b/elpa/smartparens-20241220.1254/smartparens-autoloads.el @@ -1,12 +1,14 @@ -;;; smartparens-autoloads.el --- automatically extracted autoloads -*- lexical-binding: t -*- -;; +;;; smartparens-autoloads.el --- automatically extracted autoloads (do not edit) -*- lexical-binding: t -*- +;; Generated by the `loaddefs-generate' function. + +;; This file is part of GNU Emacs. + ;;; Code: -(add-to-list 'load-path (directory-file-name - (or (file-name-directory #$) (car load-path)))) +(add-to-list 'load-path (or (and load-file-name (directory-file-name (file-name-directory load-file-name))) (car load-path))) + -;;;### (autoloads nil "smartparens" "smartparens.el" (0 0 0 0)) ;;; Generated autoloads from smartparens.el (autoload 'sp-cheat-sheet "smartparens" "\ @@ -25,59 +27,39 @@ the previous/next entry. Examples are fontified using the `font-lock-string-face' for better orientation. -\(fn &optional ARG)" t nil) - +(fn &optional ARG)" t) (defvar smartparens-mode-map (make-sparse-keymap) "\ Keymap used for `smartparens-mode'.") - (autoload 'sp-use-paredit-bindings "smartparens" "\ -Initiate `smartparens-mode-map' with `sp-paredit-bindings'." t nil) - +Initiate `smartparens-mode-map' with `sp-paredit-bindings'." t) (autoload 'sp-use-smartparens-bindings "smartparens" "\ -Initiate `smartparens-mode-map' with `sp-smartparens-bindings'." t nil) - +Initiate `smartparens-mode-map' with `sp-smartparens-bindings'." t) (autoload 'smartparens-mode "smartparens" "\ Toggle smartparens mode. -This is a minor mode. If called interactively, toggle the -`Smartparens mode' mode. If the prefix argument is positive, -enable the mode, and if it is zero or negative, disable the mode. - -If called from Lisp, toggle the mode if ARG is `toggle'. Enable -the mode if ARG is nil, omitted, or is a positive number. -Disable the mode if ARG is a negative number. - -To check whether the minor mode is enabled in the current buffer, -evaluate `smartparens-mode'. - -The mode's hook is called both when the mode is enabled and when -it is disabled. - You can enable pre-set bindings by customizing `sp-base-key-bindings' variable. The current content of `smartparens-mode-map' is: \\{smartparens-mode-map} -\(fn &optional ARG)" t nil) +This is a minor mode. If called interactively, toggle the `Smartparens +mode' mode. If the prefix argument is positive, enable the mode, and if +it is zero or negative, disable the mode. -(autoload 'smartparens-strict-mode "smartparens" "\ -Toggle the strict smartparens mode. - -This is a minor mode. If called interactively, toggle the -`Smartparens-Strict mode' mode. If the prefix argument is -positive, enable the mode, and if it is zero or negative, disable -the mode. - -If called from Lisp, toggle the mode if ARG is `toggle'. Enable -the mode if ARG is nil, omitted, or is a positive number. -Disable the mode if ARG is a negative number. +If called from Lisp, toggle the mode if ARG is `toggle'. Enable the +mode if ARG is nil, omitted, or is a positive number. Disable the mode +if ARG is a negative number. To check whether the minor mode is enabled in the current buffer, -evaluate `smartparens-strict-mode'. +evaluate the variable `smartparens-mode'. + +The mode's hook is called both when the mode is enabled and when it is +disabled. -The mode's hook is called both when the mode is enabled and when -it is disabled. +(fn &optional ARG)" t) +(autoload 'smartparens-strict-mode "smartparens" "\ +Toggle the strict smartparens mode. When strict mode is active, `delete-char', `kill-word' and their backward variants will skip over the pair delimiters in order to @@ -90,10 +72,24 @@ working exactly the same (it is not bound to any key by default). When strict mode is active, this is indicated with \"/s\" after the smartparens indicator in the mode list. -\(fn &optional ARG)" t nil) +This is a minor mode. If called interactively, toggle the +`Smartparens-Strict mode' mode. If the prefix argument is positive, +enable the mode, and if it is zero or negative, disable the mode. -(put 'smartparens-global-strict-mode 'globalized-minor-mode t) +If called from Lisp, toggle the mode if ARG is `toggle'. Enable the +mode if ARG is nil, omitted, or is a positive number. Disable the mode +if ARG is a negative number. + +To check whether the minor mode is enabled in the current buffer, +evaluate the variable `smartparens-strict-mode'. + +The mode's hook is called both when the mode is enabled and when it is +disabled. + +\\{smartparens-strict-mode-map} +(fn &optional ARG)" t) +(put 'smartparens-global-strict-mode 'globalized-minor-mode t) (defvar smartparens-global-strict-mode nil "\ Non-nil if Smartparens-Global-Strict mode is enabled. See the `smartparens-global-strict-mode' command @@ -101,9 +97,7 @@ for a description of this minor mode. Setting this variable directly does not take effect; either customize it (see the info node `Easy Customization') or call the function `smartparens-global-strict-mode'.") - (custom-autoload 'smartparens-global-strict-mode "smartparens" nil) - (autoload 'smartparens-global-strict-mode "smartparens" "\ Toggle Smartparens-Strict mode in all buffers. With prefix ARG, enable Smartparens-Global-Strict mode if ARG is @@ -119,16 +113,12 @@ Smartparens-Strict mode is enabled in all buffers where See `smartparens-strict-mode' for more information on Smartparens-Strict mode. -\(fn &optional ARG)" t nil) - +(fn &optional ARG)" t) (autoload 'turn-on-smartparens-strict-mode "smartparens" "\ -Turn on `smartparens-strict-mode'." t nil) - +Turn on `smartparens-strict-mode'." t) (autoload 'turn-off-smartparens-strict-mode "smartparens" "\ -Turn off `smartparens-strict-mode'." t nil) - +Turn off `smartparens-strict-mode'." t) (put 'smartparens-global-mode 'globalized-minor-mode t) - (defvar smartparens-global-mode nil "\ Non-nil if Smartparens-Global mode is enabled. See the `smartparens-global-mode' command @@ -136,9 +126,7 @@ for a description of this minor mode. Setting this variable directly does not take effect; either customize it (see the info node `Easy Customization') or call the function `smartparens-global-mode'.") - (custom-autoload 'smartparens-global-mode "smartparens" nil) - (autoload 'smartparens-global-mode "smartparens" "\ Toggle Smartparens mode in all buffers. With prefix ARG, enable Smartparens-Global mode if ARG is positive; @@ -153,8 +141,7 @@ Smartparens mode is enabled in all buffers where See `smartparens-mode' for more information on Smartparens mode. -\(fn &optional ARG)" t nil) - +(fn &optional ARG)" t) (autoload 'turn-on-smartparens-mode "smartparens" "\ Turn on `smartparens-mode'. @@ -167,37 +154,33 @@ buffers. 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'." t nil) - +in mode's startup-hook etc.) by calling `smartparens-mode'." t) (autoload 'turn-off-smartparens-mode "smartparens" "\ -Turn off `smartparens-mode'." t nil) - +Turn off `smartparens-mode'." t) (autoload 'show-smartparens-mode "smartparens" "\ Toggle visualization of matching pairs. When enabled, any + matching pair is highlighted after `sp-show-pair-delay' seconds of Emacs idle time if the point is immediately in front or after a pair. This mode works similarly to `show-paren-mode', but support custom pairs. This is a minor mode. If called interactively, toggle the -`Show-Smartparens mode' mode. If the prefix argument is -positive, enable the mode, and if it is zero or negative, disable -the mode. +`Show-Smartparens mode' mode. If the prefix argument is positive, +enable the mode, and if it is zero or negative, disable the mode. -If called from Lisp, toggle the mode if ARG is `toggle'. Enable -the mode if ARG is nil, omitted, or is a positive number. -Disable the mode if ARG is a negative number. +If called from Lisp, toggle the mode if ARG is `toggle'. Enable the +mode if ARG is nil, omitted, or is a positive number. Disable the mode +if ARG is a negative number. To check whether the minor mode is enabled in the current buffer, -evaluate `show-smartparens-mode'. +evaluate the variable `show-smartparens-mode'. -The mode's hook is called both when the mode is enabled and when -it is disabled. - -\(fn &optional ARG)" t nil) +The mode's hook is called both when the mode is enabled and when it is +disabled. +(fn &optional ARG)" t) (put 'show-smartparens-global-mode 'globalized-minor-mode t) - (defvar show-smartparens-global-mode nil "\ Non-nil if Show-Smartparens-Global mode is enabled. See the `show-smartparens-global-mode' command @@ -205,9 +188,7 @@ for a description of this minor mode. Setting this variable directly does not take effect; either customize it (see the info node `Easy Customization') or call the function `show-smartparens-global-mode'.") - (custom-autoload 'show-smartparens-global-mode "smartparens" nil) - (autoload 'show-smartparens-global-mode "smartparens" "\ Toggle Show-Smartparens mode in all buffers. With prefix ARG, enable Show-Smartparens-Global mode if ARG is @@ -223,181 +204,131 @@ Show-Smartparens mode is enabled in all buffers where See `show-smartparens-mode' for more information on Show-Smartparens mode. -\(fn &optional ARG)" t nil) - +(fn &optional ARG)" t) (autoload 'turn-on-show-smartparens-mode "smartparens" "\ -Turn on `show-smartparens-mode'." t nil) +Turn on `show-smartparens-mode'. -(autoload 'turn-off-show-smartparens-mode "smartparens" "\ -Turn off `show-smartparens-mode'." t nil) +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.]" t) +(autoload 'turn-off-show-smartparens-mode "smartparens" "\ +Turn off `show-smartparens-mode'." t) (register-definition-prefixes "smartparens" '("smartparens-" "sp-")) -;;;*** -;;;### (autoloads nil "smartparens-clojure" "smartparens-clojure.el" -;;;;;; (0 0 0 0)) ;;; Generated autoloads from smartparens-clojure.el (register-definition-prefixes "smartparens-clojure" '("sp-clojure-prefix")) -;;;*** -;;;### (autoloads nil "smartparens-config" "smartparens-config.el" -;;;;;; (0 0 0 0)) ;;; Generated autoloads from smartparens-config.el -(register-definition-prefixes "smartparens-config" '("sp-lisp-invalid-hyperlink-p")) +(register-definition-prefixes "smartparens-config" '("sp-lisp-in")) -;;;*** -;;;### (autoloads nil "smartparens-crystal" "smartparens-crystal.el" -;;;;;; (0 0 0 0)) ;;; Generated autoloads from smartparens-crystal.el (register-definition-prefixes "smartparens-crystal" '("sp-crystal-")) -;;;*** -;;;### (autoloads nil "smartparens-elixir" "smartparens-elixir.el" -;;;;;; (0 0 0 0)) ;;; Generated autoloads from smartparens-elixir.el (register-definition-prefixes "smartparens-elixir" '("sp-elixir-")) -;;;*** -;;;### (autoloads nil "smartparens-ess" "smartparens-ess.el" (0 0 -;;;;;; 0 0)) ;;; Generated autoloads from smartparens-ess.el (register-definition-prefixes "smartparens-ess" '("sp-ess-")) -;;;*** -;;;### (autoloads nil "smartparens-haskell" "smartparens-haskell.el" -;;;;;; (0 0 0 0)) ;;; Generated autoloads from smartparens-haskell.el (register-definition-prefixes "smartparens-haskell" '("sp-")) -;;;*** -;;;### (autoloads nil "smartparens-html" "smartparens-html.el" (0 -;;;;;; 0 0 0)) ;;; Generated autoloads from smartparens-html.el (register-definition-prefixes "smartparens-html" '("sp-html-")) -;;;*** -;;;### (autoloads nil "smartparens-latex" "smartparens-latex.el" -;;;;;; (0 0 0 0)) +;;; Generated autoloads from smartparens-javascript.el + +(register-definition-prefixes "smartparens-javascript" '("sp-")) + + ;;; Generated autoloads from smartparens-latex.el (register-definition-prefixes "smartparens-latex" '("sp-latex-")) -;;;*** -;;;### (autoloads nil "smartparens-lua" "smartparens-lua.el" (0 0 -;;;;;; 0 0)) ;;; Generated autoloads from smartparens-lua.el (register-definition-prefixes "smartparens-lua" '("sp-lua-post-keyword-insert")) -;;;*** -;;;### (autoloads nil "smartparens-markdown" "smartparens-markdown.el" -;;;;;; (0 0 0 0)) ;;; Generated autoloads from smartparens-markdown.el (register-definition-prefixes "smartparens-markdown" '("sp-")) -;;;*** -;;;### (autoloads nil "smartparens-org" "smartparens-org.el" (0 0 -;;;;;; 0 0)) ;;; Generated autoloads from smartparens-org.el (register-definition-prefixes "smartparens-org" '("sp-")) -;;;*** -;;;### (autoloads nil "smartparens-python" "smartparens-python.el" -;;;;;; (0 0 0 0)) ;;; Generated autoloads from smartparens-python.el (register-definition-prefixes "smartparens-python" '("sp-python-")) -;;;*** -;;;### (autoloads nil "smartparens-rst" "smartparens-rst.el" (0 0 -;;;;;; 0 0)) ;;; Generated autoloads from smartparens-rst.el (register-definition-prefixes "smartparens-rst" '("sp-rst-point-after-backtick")) -;;;*** -;;;### (autoloads nil "smartparens-ruby" "smartparens-ruby.el" (0 -;;;;;; 0 0 0)) ;;; Generated autoloads from smartparens-ruby.el (register-definition-prefixes "smartparens-ruby" '("sp-")) -;;;*** -;;;### (autoloads nil "smartparens-rust" "smartparens-rust.el" (0 -;;;;;; 0 0 0)) ;;; Generated autoloads from smartparens-rust.el (register-definition-prefixes "smartparens-rust" '("sp-")) -;;;*** -;;;### (autoloads nil "smartparens-scala" "smartparens-scala.el" -;;;;;; (0 0 0 0)) ;;; Generated autoloads from smartparens-scala.el (register-definition-prefixes "smartparens-scala" '("sp-scala-wrap-with-indented-newlines")) -;;;*** -;;;### (autoloads nil "smartparens-swift" "smartparens-swift.el" -;;;;;; (0 0 0 0)) ;;; Generated autoloads from smartparens-swift.el (register-definition-prefixes "smartparens-swift" '("sp-swift-")) -;;;*** -;;;### (autoloads nil "smartparens-text" "smartparens-text.el" (0 -;;;;;; 0 0 0)) ;;; Generated autoloads from smartparens-text.el (register-definition-prefixes "smartparens-text" '("sp-text-mode-")) -;;;*** -;;;### (autoloads nil "sp-sublimetext-like" "sp-sublimetext-like.el" -;;;;;; (0 0 0 0)) ;;; Generated autoloads from sp-sublimetext-like.el (register-definition-prefixes "sp-sublimetext-like" '("sp-point-not-before-word")) - -;;;*** -;;;### (autoloads nil nil ("smartparens-c.el" "smartparens-erlang.el" -;;;;;; "smartparens-go.el" "smartparens-javascript.el" "smartparens-ml.el" -;;;;;; "smartparens-pkg.el" "smartparens-racket.el" "smartparens-unison.el") -;;;;;; (0 0 0 0)) +;;; End of scraped data + +(provide 'smartparens-autoloads) -;;;*** - ;; Local Variables: ;; version-control: never ;; no-byte-compile: t ;; no-update-autoloads: t -;; coding: utf-8 +;; no-native-compile: t +;; coding: utf-8-emacs-unix ;; End: + ;;; smartparens-autoloads.el ends here diff --git a/elpa/smartparens-20230529.1017/smartparens-c.el b/elpa/smartparens-20241220.1254/smartparens-c.el similarity index 100% rename from elpa/smartparens-20230529.1017/smartparens-c.el rename to elpa/smartparens-20241220.1254/smartparens-c.el diff --git a/elpa/smartparens-20230529.1017/smartparens-clojure.el b/elpa/smartparens-20241220.1254/smartparens-clojure.el similarity index 87% rename from elpa/smartparens-20230529.1017/smartparens-clojure.el rename to elpa/smartparens-20241220.1254/smartparens-clojure.el index 4408e8ae..a38ebce7 100644 --- a/elpa/smartparens-20230529.1017/smartparens-clojure.el +++ b/elpa/smartparens-20241220.1254/smartparens-clojure.el @@ -44,7 +44,15 @@ (defvar sp-clojure-prefix "\\(?:[@`'#~,_?^]+\\)" "Prefix used in `sp-sexp-prefix' for clojure modes.") -(dolist (mode '(clojure-mode clojurescript-mode clojurec-mode cider-repl-mode)) +(dolist (mode '( + cider-repl-mode + clojure-mode + clojure-ts-mode + clojurec-mode + clojurec-ts-mode + clojurescript-mode + clojurescript-ts-mode + )) (add-to-list 'sp-sexp-prefix `(,mode regexp ,sp-clojure-prefix))) ;; Match "`" with "`" in strings and comments diff --git a/elpa/smartparens-20230529.1017/smartparens-config.el b/elpa/smartparens-20241220.1254/smartparens-config.el similarity index 85% rename from elpa/smartparens-20230529.1017/smartparens-config.el rename to elpa/smartparens-20241220.1254/smartparens-config.el index 7bfcfe08..981641f5 100644 --- a/elpa/smartparens-20230529.1017/smartparens-config.el +++ b/elpa/smartparens-20241220.1254/smartparens-config.el @@ -70,9 +70,21 @@ ID, ACTION, CONTEXT." ;; do not consider punctuation (not (looking-at "[?.,;!]")))))))) +(defun sp-lisp-insert-space-after-slurp (_id action _context) + (-let (((&plist :ok-orig :next-thing) sp-handler-context)) + (when (and (eq action 'slurp-forward) + (sp-get ok-orig (/= :beg-in :end-in))) + (save-excursion + (sp-get ok-orig (goto-char :end-in)) + (skip-syntax-backward " ") + (unless (looking-at-p (rx (or whitespace eol))) + (insert " ")))))) + ;; emacs is lisp hacking environment, so we set up some most common ;; lisp modes too (sp-with-modes sp-lisp-modes + (sp-local-pair "(" nil :post-handlers '(:add sp-lisp-insert-space-after-slurp)) + (sp-local-pair "[" nil :post-handlers '(:add sp-lisp-insert-space-after-slurp)) ;; disable ', it's the quote character! (sp-local-pair "'" nil :actions nil)) @@ -116,8 +128,11 @@ ID, ACTION, CONTEXT." ;; automatically. If you want to call sp-local-pair outside this ;; macro, you MUST supply the major mode argument. -(eval-after-load 'cc-mode '(require 'smartparens-c)) -(eval-after-load 'clojure-mode '(require 'smartparens-clojure)) +(--each '(cc-mode c-ts-mode) + (eval-after-load it '(require 'smartparens-c))) +(--each '(clojure-mode clojure-ts-mode) + (eval-after-load it '(require 'smartparens-clojure))) +(eval-after-load 'coq-mode '(require 'smartparens-coq)) (eval-after-load 'crystal-mode '(require 'smartparens-crystal)) (eval-after-load 'elixir-mode '(require 'smartparens-elixir)) (eval-after-load 'elixir-ts-mode '(require 'smartparens-elixir)) @@ -131,14 +146,16 @@ ID, ACTION, CONTEXT." (eval-after-load it '(require 'smartparens-html))) (eval-after-load 'latex '(require 'smartparens-latex)) (eval-after-load 'lua-mode '(require 'smartparens-lua)) +(eval-after-load 'lua-ts-mode '(require 'smartparens-lua)) (eval-after-load 'markdown-mode '(require 'smartparens-markdown)) -(--each '(python-mode python) +(--each '(python-mode python-ts-mode python) (eval-after-load it '(require 'smartparens-python))) (eval-after-load 'org '(require 'smartparens-org)) (eval-after-load 'racket-mode '(require 'smartparens-racket)) (eval-after-load 'rst '(require 'smartparens-rst)) (eval-after-load 'ruby-mode '(require 'smartparens-ruby)) (eval-after-load 'rust-mode '(require 'smartparens-rust)) +(eval-after-load 'rust-ts-mode '(require 'smartparens-rust)) (eval-after-load 'rustic '(require 'smartparens-rust)) (eval-after-load 'scala-mode '(require 'smartparens-scala)) (eval-after-load 'swift-mode '(require 'smartparens-swift)) @@ -147,7 +164,7 @@ ID, ACTION, CONTEXT." (eval-after-load 'tuareg '(require 'smartparens-ml)) (eval-after-load 'fsharp-mode '(require 'smartparens-ml)) (eval-after-load 'unisonlang-mode '(require 'smartparens-unison)) -(--each '(js js2-mode) +(--each '(js js2-mode typescript-ts-mode) (eval-after-load it '(require 'smartparens-javascript))) (provide 'smartparens-config) diff --git a/elpa/smartparens-20241220.1254/smartparens-coq.el b/elpa/smartparens-20241220.1254/smartparens-coq.el new file mode 100644 index 00000000..c84a6cfc --- /dev/null +++ b/elpa/smartparens-20241220.1254/smartparens-coq.el @@ -0,0 +1,60 @@ +;;; smartparens-coq.el --- Additional configuration for Coq proof assistant -*- lexical-binding: t; -*- + +;; Copyright (C) 2024 Matus Goljer + +;; Author: Matus Goljer +;; Maintainer: Matus Goljer +;; Created: 29 June 2024 +;; Keywords: smartparens, coq +;; URL: https://github.com/Fuco1/smartparens + +;; This file is not part of GNU Emacs. + +;;; License: + +;; This file is part of Smartparens. + +;; Smartparens is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; Smartparens is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with Smartparens. If not, see . + +;;; Commentary: + +;; This file provides some additional configuration for Coq proof +;; assistant. To use it, simply add: +;; +;; (require 'smartparens-coq) +;; +;; into your configuration. You can use this in conjunction with the +;; default config or your own configuration. +;; +;; If you have good ideas about what should be added please file an +;; issue on the github tracker. +;; +;; For more info, see github readme at +;; https://github.com/Fuco1/smartparens + +;;; Code: + +(require 'smartparens) + +(sp-with-modes '(coq-mode) + ;; Disable ' because it is used in pattern-matching + (sp-local-pair "'" nil :actions nil) + ;; Disable ` because it is used in polymorphic variants + (sp-local-pair "`" nil :actions nil) + (sp-local-pair "(*" "*)" + :post-handlers '(("| " "SPC") + (" | " "*")))) + +(provide 'smartparens-coq) +;;; smartparens-coq.el ends here diff --git a/elpa/smartparens-20230529.1017/smartparens-crystal.el b/elpa/smartparens-20241220.1254/smartparens-crystal.el similarity index 100% rename from elpa/smartparens-20230529.1017/smartparens-crystal.el rename to elpa/smartparens-20241220.1254/smartparens-crystal.el diff --git a/elpa/smartparens-20230529.1017/smartparens-elixir.el b/elpa/smartparens-20241220.1254/smartparens-elixir.el similarity index 99% rename from elpa/smartparens-20230529.1017/smartparens-elixir.el rename to elpa/smartparens-20241220.1254/smartparens-elixir.el index bf416486..c8dccc27 100644 --- a/elpa/smartparens-20230529.1017/smartparens-elixir.el +++ b/elpa/smartparens-20241220.1254/smartparens-elixir.el @@ -4,7 +4,6 @@ ;; Author: Matúš Goljer ;; Maintainer: Matúš Goljer -;; Version: 0.0.1 ;; Created: 15th January 2017 ;; Keywords: languages diff --git a/elpa/smartparens-20230529.1017/smartparens-erlang.el b/elpa/smartparens-20241220.1254/smartparens-erlang.el similarity index 100% rename from elpa/smartparens-20230529.1017/smartparens-erlang.el rename to elpa/smartparens-20241220.1254/smartparens-erlang.el diff --git a/elpa/smartparens-20230529.1017/smartparens-ess.el b/elpa/smartparens-20241220.1254/smartparens-ess.el similarity index 99% rename from elpa/smartparens-20230529.1017/smartparens-ess.el rename to elpa/smartparens-20241220.1254/smartparens-ess.el index 9d5de2c4..9de17056 100644 --- a/elpa/smartparens-20230529.1017/smartparens-ess.el +++ b/elpa/smartparens-20241220.1254/smartparens-ess.el @@ -6,7 +6,6 @@ ;; Maintainer: Bernhard Pröll ;; URL: https://github.com/Fuco1/smartparens ;; Created: 2015-02-26 -;; Version: 0.2 ;; Keywords: abbrev convenience editing ;; This file is NOT part of GNU Emacs. diff --git a/elpa/smartparens-20230529.1017/smartparens-go.el b/elpa/smartparens-20241220.1254/smartparens-go.el similarity index 100% rename from elpa/smartparens-20230529.1017/smartparens-go.el rename to elpa/smartparens-20241220.1254/smartparens-go.el diff --git a/elpa/smartparens-20230529.1017/smartparens-haskell.el b/elpa/smartparens-20241220.1254/smartparens-haskell.el similarity index 100% rename from elpa/smartparens-20230529.1017/smartparens-haskell.el rename to elpa/smartparens-20241220.1254/smartparens-haskell.el diff --git a/elpa/smartparens-20230529.1017/smartparens-html.el b/elpa/smartparens-20241220.1254/smartparens-html.el similarity index 100% rename from elpa/smartparens-20230529.1017/smartparens-html.el rename to elpa/smartparens-20241220.1254/smartparens-html.el diff --git a/elpa/smartparens-20230529.1017/smartparens-javascript.el b/elpa/smartparens-20241220.1254/smartparens-javascript.el similarity index 69% rename from elpa/smartparens-20230529.1017/smartparens-javascript.el rename to elpa/smartparens-20241220.1254/smartparens-javascript.el index 95e6e5dc..7295435f 100644 --- a/elpa/smartparens-20230529.1017/smartparens-javascript.el +++ b/elpa/smartparens-20241220.1254/smartparens-javascript.el @@ -46,10 +46,30 @@ (require 'smartparens) +(defvar sp--javascript-modes '( + js-mode + javascript-mode + js2-mode + typescript-mode + rjsx-mode + js-ts-mode + typescript-ts-mode + tsx-ts-mode + ) + "List of JavaScript modes.") + ;; (|sys).path.append---the dot should not travel with the closing ;; paren -(--each '(js-mode javascript-mode js2-mode typescript-mode rjsx-mode) +(--each sp--javascript-modes (add-to-list 'sp-sexp-suffix (list it 'regexp ""))) +(defun sp-javascript-skip-match-angle-bracket (ms mb _me) + "Non-nil if we should ignore the bracket as valid delimiter." + (and (string= ms ">") (= (char-before mb) ?=))) + +(sp-with-modes sp--javascript-modes + (sp-local-pair "<" ">" + :skip-match 'sp-javascript-skip-match-angle-bracket)) + (provide 'smartparens-javascript) ;;; smartparens-javascript.el ends here diff --git a/elpa/smartparens-20230529.1017/smartparens-latex.el b/elpa/smartparens-20241220.1254/smartparens-latex.el similarity index 100% rename from elpa/smartparens-20230529.1017/smartparens-latex.el rename to elpa/smartparens-20241220.1254/smartparens-latex.el diff --git a/elpa/smartparens-20230529.1017/smartparens-lua.el b/elpa/smartparens-20241220.1254/smartparens-lua.el similarity index 98% rename from elpa/smartparens-20230529.1017/smartparens-lua.el rename to elpa/smartparens-20241220.1254/smartparens-lua.el index 0b7512a3..e6b4c90c 100644 --- a/elpa/smartparens-20230529.1017/smartparens-lua.el +++ b/elpa/smartparens-20241220.1254/smartparens-lua.el @@ -66,7 +66,7 @@ ;; all the pairs are expanded only if followed by "SPC" event. This ;; will reduce false positives like 'dIFficult' to trigger. -(sp-with-modes '(lua-mode) +(sp-with-modes '(lua-mode lua-ts-mode) (sp-local-pair "if" "end" :when '(("SPC")) :unless '(sp-in-comment-p sp-in-string-p) diff --git a/elpa/smartparens-20230529.1017/smartparens-markdown.el b/elpa/smartparens-20241220.1254/smartparens-markdown.el similarity index 100% rename from elpa/smartparens-20230529.1017/smartparens-markdown.el rename to elpa/smartparens-20241220.1254/smartparens-markdown.el diff --git a/elpa/smartparens-20230529.1017/smartparens-ml.el b/elpa/smartparens-20241220.1254/smartparens-ml.el similarity index 100% rename from elpa/smartparens-20230529.1017/smartparens-ml.el rename to elpa/smartparens-20241220.1254/smartparens-ml.el diff --git a/elpa/smartparens-20230529.1017/smartparens-org.el b/elpa/smartparens-20241220.1254/smartparens-org.el similarity index 75% rename from elpa/smartparens-20230529.1017/smartparens-org.el rename to elpa/smartparens-20241220.1254/smartparens-org.el index 8b864b1d..cc1892ad 100644 --- a/elpa/smartparens-20230529.1017/smartparens-org.el +++ b/elpa/smartparens-20241220.1254/smartparens-org.el @@ -4,7 +4,6 @@ ;; Author: Matúš Goljer ;; Maintainer: Matúš Goljer -;; Version: 0.0.1 ;; Created: 15th January 2017 ;; Keywords: languages @@ -58,12 +57,26 @@ This predicate is only tested on \"insert\" action." (when (eq action 'insert) (sp--looking-back-p (concat "\\[" (regexp-quote id))))) +(defun sp-org-inside-inline-code (_id action _context) + (when (eq action 'insert) + (when-let ((expr (sp-get-stringlike-expression))) + (sp-get expr (member :op '("~" "=")))))) + (sp-with-modes 'org-mode (sp-local-pair "*" "*" - :unless '(sp-point-after-word-p sp-point-at-bol-p) + :unless '(sp-point-after-word-p + sp-point-at-bol-p + sp-org-inside-inline-code + ) :skip-match 'sp--org-skip-asterisk) - (sp-local-pair "_" "_" :unless '(sp-point-after-word-p)) - (sp-local-pair "/" "/" :unless '(sp-point-after-word-p sp-org-point-after-left-square-bracket-p) :post-handlers '(("[d1]" "SPC"))) + (sp-local-pair "_" "_" :unless '(sp-point-after-word-p + sp-org-inside-inline-code + )) + (sp-local-pair "/" "/" :unless '(sp-point-after-word-p + sp-org-point-after-left-square-bracket-p + sp-org-inside-inline-code + ) + :post-handlers '(("[d1]" "SPC"))) (sp-local-pair "~" "~" :unless '(sp-point-after-word-p) :post-handlers '(("[d1]" "SPC"))) (sp-local-pair "=" "=" :unless '(sp-point-after-word-p) :post-handlers '(("[d1]" "SPC"))) (sp-local-pair "«" "»")) diff --git a/elpa/smartparens-20241220.1254/smartparens-pkg.el b/elpa/smartparens-20241220.1254/smartparens-pkg.el new file mode 100644 index 00000000..a505d8d2 --- /dev/null +++ b/elpa/smartparens-20241220.1254/smartparens-pkg.el @@ -0,0 +1,10 @@ +;; -*- no-byte-compile: t; lexical-binding: nil -*- +(define-package "smartparens" "20241220.1254" + "Automatic insertion, wrapping and paredit-like navigation with user defined pairs." + '((dash "2.13.0")) + :url "https://github.com/Fuco1/smartparens" + :commit "b0d935c11813bcd40f8d35bae8800e0741334c29" + :revdesc "b0d935c11813" + :keywords '("abbrev" "convenience" "editing") + :authors '(("Matus Goljer" . "matus.goljer@gmail.com")) + :maintainers '(("Matus Goljer" . "matus.goljer@gmail.com"))) diff --git a/elpa/smartparens-20230529.1017/smartparens-python.el b/elpa/smartparens-20241220.1254/smartparens-python.el similarity index 97% rename from elpa/smartparens-20230529.1017/smartparens-python.el rename to elpa/smartparens-20241220.1254/smartparens-python.el index dbe63338..2c342b13 100644 --- a/elpa/smartparens-20230529.1017/smartparens-python.el +++ b/elpa/smartparens-20241220.1254/smartparens-python.el @@ -65,7 +65,7 @@ Supported definitions are: ;; Python has no sexp suffices. This fixes slurping ;; (|sys).path.append---the dot should not travel with the closing ;; paren -(--each '(python-mode inferior-python-mode) +(--each '(python-mode python-ts-mode inferior-python-mode) (add-to-list 'sp-sexp-suffix (list it 'regexp ""))) (defun sp-python-maybe-add-colon-python (_id action _context) @@ -93,7 +93,7 @@ See also the option `sp-python-insert-colon-in-function-definitions'." (forward-char) ;; skip closing paren (insert ":")))) -(sp-with-modes 'python-mode +(sp-with-modes '(python-mode python-ts-mode) (sp-local-pair "'" "'" :unless '(sp-in-comment-p sp-in-string-quotes-p) :post-handlers '(:add sp-python-fix-tripple-quotes)) (sp-local-pair "\"" "\"" :post-handlers '(:add sp-python-fix-tripple-quotes)) (sp-local-pair "'''" "'''") diff --git a/elpa/smartparens-20230529.1017/smartparens-racket.el b/elpa/smartparens-20241220.1254/smartparens-racket.el similarity index 100% rename from elpa/smartparens-20230529.1017/smartparens-racket.el rename to elpa/smartparens-20241220.1254/smartparens-racket.el diff --git a/elpa/smartparens-20230529.1017/smartparens-rst.el b/elpa/smartparens-20241220.1254/smartparens-rst.el similarity index 100% rename from elpa/smartparens-20230529.1017/smartparens-rst.el rename to elpa/smartparens-20241220.1254/smartparens-rst.el diff --git a/elpa/smartparens-20230529.1017/smartparens-ruby.el b/elpa/smartparens-20241220.1254/smartparens-ruby.el similarity index 97% rename from elpa/smartparens-20230529.1017/smartparens-ruby.el rename to elpa/smartparens-20241220.1254/smartparens-ruby.el index 237eea90..27b9c365 100644 --- a/elpa/smartparens-20230529.1017/smartparens-ruby.el +++ b/elpa/smartparens-20241220.1254/smartparens-ruby.el @@ -56,14 +56,14 @@ (defun sp-ruby-forward-sexp () "Wrapper for `ruby-forward-sexp' based on `enh-ruby-mode'." (interactive) - (if (boundp 'enh-ruby-forward-sexp) + (if (fboundp 'enh-ruby-forward-sexp) (enh-ruby-forward-sexp) (ruby-forward-sexp))) (defun sp-ruby-backward-sexp () "Wrapper for `ruby-backward-sexp' based on `enh-ruby-mode'." (interactive) - (if (boundp 'enh-ruby-backward-sexp) + (if (fboundp 'enh-ruby-backward-sexp) (enh-ruby-backward-sexp) (ruby-backward-sexp))) @@ -142,8 +142,8 @@ ID, ACTION, CONTEXT." (sp-get enc (let ((beg-line (line-number-at-pos :beg-in)) (end-line (line-number-at-pos :end-in))) - (when (equal action 'slurp-backward) + (setq end-line (- end-line :op-l)) (save-excursion (sp-forward-sexp) (when (looking-at-p ";") (forward-char)) @@ -293,12 +293,12 @@ MS, ME, MB." (sp-ruby-method-p "end")))) (add-to-list 'sp-navigate-skip-match - '((ruby-mode enh-ruby-mode motion-mode) . sp--ruby-skip-match)) + '((ruby-mode ruby-ts-mode enh-ruby-mode motion-mode) . sp--ruby-skip-match)) -(dolist (mode '(ruby-mode motion-mode)) +(dolist (mode '(ruby-mode ruby-ts-mode motion-mode)) (add-to-list 'sp-sexp-suffix `(,mode syntax ""))) -(sp-with-modes '(ruby-mode enh-ruby-mode motion-mode) +(sp-with-modes '(ruby-mode ruby-ts-mode enh-ruby-mode motion-mode) (sp-local-pair "do" "end" :when '(("SPC" "RET" "")) :unless '(sp-ruby-in-string-or-word-p sp-in-comment-p) diff --git a/elpa/smartparens-20230529.1017/smartparens-rust.el b/elpa/smartparens-20241220.1254/smartparens-rust.el similarity index 96% rename from elpa/smartparens-20230529.1017/smartparens-rust.el rename to elpa/smartparens-20241220.1254/smartparens-rust.el index 42996d84..f5058610 100644 --- a/elpa/smartparens-20230529.1017/smartparens-rust.el +++ b/elpa/smartparens-20241220.1254/smartparens-rust.el @@ -45,6 +45,7 @@ (require 'smartparens) (declare-function rust-mode "rust-mode") +(declare-function rust-ts-mode "rust-ts-mode") (declare-function rustic-mode "rustic-mode") (defun sp-in-rust-lifetime-context (&rest _args) @@ -124,7 +125,7 @@ ARGS." ((eq action 'navigate) (and (not on-comparison) (not on-fn-return-type) (not on-match-branch)))))))) -(sp-with-modes '(rust-mode rustic-mode) +(sp-with-modes '(rust-mode rust-ts-mode rustic-mode) (sp-local-pair "'" "'" :unless '(sp-in-comment-p sp-in-string-quotes-p sp-in-rust-lifetime-context) :post-handlers'(:rem sp-escape-quotes-after-insert)) @@ -135,6 +136,7 @@ ARGS." ;; Rust has no sexp suffices. This fixes slurping ;; (|foo).bar -> (foo.bar) (add-to-list 'sp-sexp-suffix (list #'rust-mode 'regexp "")) +(add-to-list 'sp-sexp-suffix (list #'rust-ts-mode 'regexp "")) (add-to-list 'sp-sexp-suffix (list #'rustic-mode 'regexp "")) (provide 'smartparens-rust) diff --git a/elpa/smartparens-20230529.1017/smartparens-scala.el b/elpa/smartparens-20241220.1254/smartparens-scala.el similarity index 100% rename from elpa/smartparens-20230529.1017/smartparens-scala.el rename to elpa/smartparens-20241220.1254/smartparens-scala.el diff --git a/elpa/smartparens-20230529.1017/smartparens-swift.el b/elpa/smartparens-20241220.1254/smartparens-swift.el similarity index 100% rename from elpa/smartparens-20230529.1017/smartparens-swift.el rename to elpa/smartparens-20241220.1254/smartparens-swift.el diff --git a/elpa/smartparens-20230529.1017/smartparens-text.el b/elpa/smartparens-20241220.1254/smartparens-text.el similarity index 100% rename from elpa/smartparens-20230529.1017/smartparens-text.el rename to elpa/smartparens-20241220.1254/smartparens-text.el diff --git a/elpa/smartparens-20230529.1017/smartparens-unison.el b/elpa/smartparens-20241220.1254/smartparens-unison.el similarity index 100% rename from elpa/smartparens-20230529.1017/smartparens-unison.el rename to elpa/smartparens-20241220.1254/smartparens-unison.el diff --git a/elpa/smartparens-20230529.1017/smartparens.el b/elpa/smartparens-20241220.1254/smartparens.el similarity index 96% rename from elpa/smartparens-20230529.1017/smartparens.el rename to elpa/smartparens-20241220.1254/smartparens.el index bf99f5f7..21191268 100644 --- a/elpa/smartparens-20230529.1017/smartparens.el +++ b/elpa/smartparens-20241220.1254/smartparens.el @@ -5,7 +5,9 @@ ;; Author: Matus Goljer ;; Maintainer: Matus Goljer ;; Created: 17 Nov 2012 -;; Version: 1.11.0 +;; Package-Version: 20241220.1254 +;; Package-Revision: b0d935c11813 +;; Package-Requires: ((dash "2.13.0")) ;; Keywords: abbrev convenience editing ;; URL: https://github.com/Fuco1/smartparens @@ -565,6 +567,9 @@ Symbol is defined as a chunk of text recognized by clojurec-mode clojurescript-mode clojurex-mode + clojure-ts-mode + clojurescript-ts-mode + clojurec-ts-mode common-lisp-mode emacs-lisp-mode eshell-mode @@ -597,6 +602,9 @@ Symbol is defined as a chunk of text recognized by clojurec-mode clojurescript-mode clojurex-mode + clojure-ts-mode + clojurescript-ts-mode + clojurec-ts-mode inf-clojure-mode ) "List of Clojure-related modes." @@ -606,6 +614,8 @@ Symbol is defined as a chunk of text recognized by (defcustom sp-c-modes '( c-mode c++-mode + c-ts-mode + c++-ts-mode ) "List of C-related modes." :type '(repeat symbol) @@ -613,10 +623,12 @@ Symbol is defined as a chunk of text recognized by (defcustom sp-no-reindent-after-kill-modes '( python-mode + python-ts-mode coffee-mode asm-mode makefile-gmake-mode haml-mode + yaml-mode ) "List of modes that should not reindent after kill." :type '(repeat symbol) @@ -642,6 +654,7 @@ Symbol is defined as a chunk of text recognized by js-jsx-mode js2-jsx-mode rjsx-mode + tsx-ts-mode ) "List of HTML modes.") @@ -734,6 +747,8 @@ You can enable pre-set bindings by customizing (add-hook 'pre-command-hook 'sp--save-pre-command-state nil 'local) (add-hook 'post-command-hook 'sp--post-command-hook-handler nil 'local) (run-hooks 'smartparens-enabled-hook)) + (when smartparens-strict-mode + (smartparens-strict-mode -1)) (remove-hook 'self-insert-uses-region-functions 'sp-wrap--can-wrap-p 'local) (remove-hook 'post-self-insert-hook 'sp--post-self-insert-hook-handler 'local) (remove-hook 'pre-command-hook 'sp--save-pre-command-state 'local) @@ -810,9 +825,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 @@ -821,6 +834,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. @@ -940,6 +957,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'. @@ -955,10 +981,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 () @@ -966,6 +990,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'." @@ -1511,6 +1539,15 @@ kill \"subwords\" when `subword-mode' is active." :type 'boolean :group 'smartparens) +(defcustom sp-delete-blank-sexps nil + "If non-nil, automatically delete enclosing pair when it only +contains whitespace. + +This setting only has effect if `smartparens-strict-mode' is +active." + :type 'boolean + :group 'smartparens) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Selection mode handling @@ -1805,14 +1842,19 @@ If optional argument P is present test this instead of point." If optional argument P is present test this instead of point. +If the sexp around the point is blank, the return value is a cons +containing the beginning and end of the expression. + Warning: it is only safe to call this when point is inside a sexp, otherwise the call may be very slow." (save-excursion (when p (goto-char p)) (-when-let (enc (sp-get-enclosing-sexp)) - (sp-get enc (string-match-p - "\\`[ \t\n]*\\'" - (buffer-substring-no-properties :beg-in :end-in)))))) + (sp-get enc + (when (string-match-p + "\\`[ \t\n]*\\'" + (buffer-substring-no-properties :beg-in :end-in)) + (cons :beg :end)))))) (defun sp-char-is-escaped-p (&optional point) "Test if the char at POINT is escaped or not. @@ -1842,6 +1884,113 @@ P is the point at which we run `syntax-ppss'" (list p (point-min) (point-max)) (sp-state-last-syntax-ppss-result sp-state) (syntax-ppss p))))) +;; `syntax-class-to-char' is new in Emacs 28.1. +(defalias 'sp--syntax-class-to-char + (if (fboundp 'syntax-class-to-char) + #'syntax-class-to-char + (lambda (syntax) + "Return the syntax char of CLASS, described by an integer. +For example, if SYNTAX is word constituent (the integer 2), the +character ‘w’ (119) is returned. + +This is a compat function for `syntax-class-to-char'." + (let ((spec " .w_()'\"$\\/<>@!|")) + (if (and (fixnump syntax) + (>= syntax 0) + (< syntax 16)) + (aref spec syntax) + (error "args out of range")))))) + +(defun sp-get-buffer-char-syntax (&optional p) + "Get syntax class of a character at P. + +If P is nil, defaults to `point'. + +This function takes into account text property `syntax-table' +which can override mode-specific syntax for a character and so +only makes sense to retrieve information about a character at a +specific position in a specific buffer. + +The raw syntax descriptor is retrieved using `syntax-after' and +the code is decoded with `syntax-class'." + (setq p (or p (point))) + (let ((parse-sexp-lookup-properties t)) + (if-let ((syntax (syntax-after p))) + (sp--syntax-class-to-char (syntax-class syntax)) + ;; This is a fallback compatible with (char-syntax + ;; (following-char)) or `previous-char'. They return 0 as the + ;; character code, for which syntax is 95 (?_) for some reason + ;; (probably to make the first/last character of the buffer have + ;; symbol boundary so the whole word counts as a symbol, including + ;; the very first character) + ?_))) + +(defun sp-syntax-after (&optional p) + "Get syntax descriptor of a character after P. + +Syntax descriptor is a character describing the syntax +code (integer). + +See `sp-get-buffer-char-syntax'." + (setq p (or p (point))) + (sp-get-buffer-char-syntax p)) + +(defun sp-syntax-before (&optional p) + "Get syntax descriptor of a character before P. + +Syntax descriptor is a character describing the syntax +code (integer). + +See `sp-get-buffer-char-syntax'." + (setq p (or p (point))) + (sp-get-buffer-char-syntax (1- p))) + +(defun sp-syntax-after-is-prefix (&optional p) + "Check that the character after P has prefix syntax. + +Prefix syntax can either come from the global major-mode syntax +table, from the text property syntax-table or from the syntax +flag (20)." + (setq p (or p (point))) + (let ((parse-sexp-lookup-properties t)) + (when-let ((syntax (syntax-after p))) + (or (= (syntax-class syntax) 6) + (/= 0 (logand (lsh 1 20) (car syntax))))))) + +(defun sp-syntax-before-is-prefix (&optional p) + "Check that the character before P has prefix syntax. + +Prefix syntax can either come from the global major-mode syntax +table, from the text property syntax-table or from the syntax +flag (20)." + (setq p (or p (point))) + (let ((parse-sexp-lookup-properties t)) + (when-let ((syntax (syntax-after (1- p)))) + (or (= (syntax-class syntax) 6) + (/= 0 (logand (lsh 1 20) (car syntax))))))) + +(defun sp-syntax-after-is-word-or-symbol (&optional p) + "Check that the character after P has word or symbol syntax. + +In case the character has a special syntax flag 'p', meaning a +prefix, it is not recognized as a word or symbol syntax even when +regularly the character would be (for example according to the +syntax table)." + (setq p (or p (point))) + (and (memq (sp-syntax-after p) '(?w ?_)) + (not (sp-syntax-after-is-prefix p)))) + +(defun sp-syntax-before-is-word-or-symbol (&optional p) + "Check that the character before P has word or symbol syntax. + +In case the character has a special syntax flag 'p', meaning a +prefix, it is not recognized as a word or symbol syntax even when +regularly the character would be (for example according to the +syntax table)." + (setq p (or p (point))) + (and (memq (sp-syntax-before p) '(?w ?_)) + (not (sp-syntax-before-is-prefix p)))) + (defun sp-point-in-string (&optional p) "Return non-nil if point is inside string or documentation string. @@ -1870,7 +2019,7 @@ If optional argument P is present test this instead off point." ;; ender" class in elisp-mode, but we just want it to be ;; treated as whitespace (and (< p (point-max)) - (memq (char-syntax (char-after p)) '(?< ?>)) + (memq (sp-syntax-after p) '(?< ?>)) (not (eq (char-after p) ?\n))) ;; we also need to test the special syntax flag for comment ;; starters and enders, because `syntax-ppss' does not yet @@ -1905,8 +2054,8 @@ are in either word or symbol class." (save-excursion (goto-char p) (and (/= 0 (following-char)) - (memq (char-syntax (following-char)) '(?w ?_)) - (memq (char-syntax (preceding-char)) '(?w ?_))))) + (memq (sp-syntax-after) '(?w ?_)) + (memq (sp-syntax-before) '(?w ?_))))) (defun sp--single-key-description (event) "Return a description of the last EVENT. @@ -1980,7 +2129,8 @@ BODY, do nothing." (defvar sp--self-insert-commands '(self-insert-command org-self-insert-command - LaTeX-insert-left-brace) + LaTeX-insert-left-brace + latex-insert-left-brace) "List of commands that are some sort of `self-insert-command'. Many modes rebind \"self-inserting\" keys to \"smart\" versions @@ -1994,6 +2144,12 @@ of pairs and wraps.") '( TeX-insert-dollar TeX-insert-quote + ;; At some point the TeX and LaTeX functions were renamed to + ;; lower-case names. This broke some code dealing with these + ;; modes, so we just add both versions for now. + tex-insert-dollar + tex-insert-quote + latex-insert-quote quack-insert-opening-paren quack-insert-closing-paren quack-insert-opening-bracket @@ -2209,6 +2365,27 @@ The value is fetched from `sp-local-pairs'. If PROP is non-nil, return the value of that property instead." (sp--get-pair-definition open sp-local-pairs prop)) +(defun sp-get-pairs-from-match (match) + "Get the definition of local pairs from MATCH. + +MATCH can be either opening or closing delimiter. Since one +closing delimiter can be shared by multiple pair definitions (for +example ruby def-end and module-end pairs), this function returns +a list of possible pairs. + +The pairs are fetched from `sp-local-pairs'." + (--filter + (or (equal (plist-get it :open) match) + (equal (plist-get it :close) match)) + sp-local-pairs)) + +(defun sp-get-skip-function-from-match (match) + "Get the :skip-match property of a pair from MATCH. + +MATCH can be either opening or closing delimiter, see +`sp-get-pairs-from-match'." + (plist-get (car (sp-get-pairs-from-match match)) :skip-match)) + (defun sp--merge-pair-configurations (specific &optional current) "Merge SPECIFIC pair configuration to the CURRENT configuration. @@ -2295,7 +2472,10 @@ is wrapped instead. This is useful with selection functions in wrap bind insert) - "Add a pair definition. + "Add, remove or update a pair definition. + +The pair definition is removed if ACTIONS is :rem, added if it +does not exist, and updated otherwise. OPEN is the opening delimiter. Every pair is uniquely determined by this string. @@ -2543,7 +2723,16 @@ can use this to skip over expressions that serve multiple functions, such as if/end pair or unary if in Ruby or * in markdown when it signifies list item instead of emphasis. In addition, there is a global per major-mode option, see -`sp-navigate-skip-match'." +`sp-navigate-skip-match'. + +Please take notice that in case of multiple pairs sharing the +same closing delimiter, they must all use the same SKIP-MATCH +function or at least handle the skip logic for the closing +delimiter in the same way, without assuming what the +corresponding opening delimiter is. This is because when the +search is performed smartparens doesn't know yet which concrete +pair it would parse upon only encountering the closing +delimiter." (if (eq actions :rem) (dolist (m (-flatten (list modes))) (let ((mode-pairs (assq m sp-pairs))) @@ -3217,7 +3406,7 @@ this value during execution of the handler." If ACTION is nil, evaluate FORMS and set it to the value of the last form; otherwise do nothing." - (declare (debug (form body))) + (declare (debug (symbolp body))) `(unless ,action (setq ,action (progn ,@forms)))) @@ -3230,7 +3419,7 @@ last form; otherwise do nothing." (when smartparens-mode (sp--with-case-sensitive (catch 'done - (let (action) + (let ((action nil)) (when (region-active-p) (condition-case err (sp-wrap--initialize) @@ -4052,21 +4241,23 @@ achieve this by using `sp-pair' or `sp-local-pair' with (cl-letf (((symbol-function 'sp--get-allowed-stringlike-list) (lambda () (--filter (and (sp--do-action-p (car it) 'autoskip) - (equal (car it) (cdr it))) sp-pair-list)))) + (equal (car it) (cdr it))) + sp-pair-list)))) ;; these two are pretty hackish ~_~ - (cl-labels ((get-sexp + (cl-labels ((inc-end + (thing) + (when thing + (plist-put thing :end (1+ (sp-get thing :end))))) + (get-sexp (last) (delete-char -1) - (insert " ") - (prog1 (sp-get-sexp) - (delete-char -1) + (prog1 (inc-end (sp-get-sexp)) (insert last))) (get-enclosing-sexp (last) (delete-char -1) - (insert " ") - (prog1 (sp-get-enclosing-sexp) - (delete-char -1) + (prog1 (inc-end (sp-get-enclosing-sexp)) + (sp-get-enclosing-sexp) (insert last)))) (let ((last (or last (sp--single-key-description last-command-event)))) (-if-let (active-sexp @@ -4120,7 +4311,7 @@ achieve this by using `sp-pair' or `sp-local-pair' with (or (not (sp-point-in-string)) (not (sp-char-is-escaped-p (1- (point)))))) (-when-let (re (cond - ((= (point) (sp-get active-sexp :beg)) + ((= (1- (point)) (sp-get active-sexp :beg)) ;; we are in front of a string-like sexp (when sp-autoskip-opening-pair (if test-only t @@ -4191,6 +4382,7 @@ is remove the just added wrapping." ;; multiple character, so let him do that (sp--with-case-sensitive (when (and (= arg 1) + (not (use-region-p)) smartparens-mode) (if (and sp-autodelete-wrap (eq sp-last-operation 'sp-wrap-region)) @@ -4415,8 +4607,7 @@ If the point is not inside a quoted string, return nil." (when (not (or (eobp) (sp-point-in-comment) (looking-at "[[:space:]]+\\s<") - (and (eq (char-syntax - (char-after pp)) ?>) + (and (eq (sp-syntax-after pp) ?>) (not (eq (char-after pp) ?\n))) (/= (logand (lsh 1 18) @@ -4445,8 +4636,11 @@ If the point is not inside a quoted string, return nil." (cl-defun sp--skip-match-p (ms mb me &key - (global-skip (cdr (--first (memq major-mode (car it)) sp-navigate-skip-match))) - (pair-skip (sp-get-pair ms :skip-match))) + (global-skip + (cdr (--first + (memq major-mode (car it)) + sp-navigate-skip-match))) + (pair-skip (sp-get-skip-function-from-match ms))) "Return non-nil if this match should be skipped. This function uses two tests, one specified in @@ -4468,11 +4662,7 @@ be a function call that sets the match data." (pair-skip (make-symbol "pair-skip"))) `(and ,form (let* ((,match (match-string 0)) - (,pair-skip (or (sp-get-pair ,match :skip-match) - (sp-get-pair (car (--first - (equal (cdr it) ,match) - sp-pair-list)) - :skip-match)))) + (,pair-skip (sp-get-skip-function-from-match ,match))) (not (sp--skip-match-p ,match (match-beginning 0) @@ -4723,15 +4913,30 @@ and the skip-match predicate." (unless (or (save-match-data (save-excursion (goto-char (match-beginning 0)) - (or (sp--looking-back-p "\\\\" 2) ;; assumes \ is always the escape... bad? + ;; assumes \ is always the escape... bad? + (or (sp--looking-back-p "\\\\" 2) (and (eq major-mode 'emacs-lisp-mode) (not (sp-point-in-string)) (sp--looking-back-p "?" 1))))) ;; TODO: HACK: global-skip is hack here!!! - (sp--skip-match-p match (match-beginning 0) (match-end 0) - :pair-skip (or skip-fn - (sp-get-pair match :skip-match)) - :global-skip nil)) + (sp--skip-match-p + match (match-beginning 0) (match-end 0) + :pair-skip (or skip-fn + (sp-get-skip-function-from-match match)) + ;; TODO: should this be removed? + :global-skip nil)) + (setq hit (match-data))))) + hit)) + +(defun sp--find-next-paired-delimiter (needle search-fn-f &optional limit) + "Find the next paired delimiter, considering the escapes +and the skip-match predicate." + (let (hit match) + (while (and (not hit) + (funcall search-fn-f needle limit t)) + (save-match-data + (setq match (match-string-no-properties 0)) + (unless (sp--skip-match-p match (match-beginning 0) (match-end 0)) (setq hit (match-data))))) hit)) @@ -4938,7 +5143,7 @@ on it when calling directly." ;; `sp-get-string' (if (and delimiter (= (length delimiter) 1) - (eq (char-syntax (string-to-char delimiter)) 34)) + (eq (char-syntax (string-to-char delimiter)) ?\")) (sp-get-string-or-nested-string back) (sp-get-stringlike-expression back)))) @@ -4953,11 +5158,20 @@ By default, this is enabled in all modes derived from (let ((pre (sp--get-allowed-regexp)) (sre (sp--get-stringlike-regexp)) (search-fn (if (not back) 'sp--search-forward-regexp 'sp--search-backward-regexp)) + ;; start of paired delimiter (ps (if back (1- (point-min)) (1+ (point-max)))) + ;; start of string delimiter (ss (if back (1- (point-min)) (1+ (point-max)))) - (string-delim nil)) + (string-delim nil) + (paired-delim nil)) (setq ps (if (equal pre "") ps - (or (save-excursion (funcall search-fn pre nil t)) ps))) + (or (--when-let (save-excursion + (sp--find-next-paired-delimiter pre search-fn)) + (setq paired-delim (match-string 0)) + (save-match-data + (set-match-data it) + (if back (match-beginning 0) (match-end 0)))) + ps))) (setq ss (if (equal sre "") ss (or (--when-let (save-excursion (sp--find-next-stringlike-delimiter sre search-fn)) @@ -5351,7 +5565,13 @@ returned. Symbol is defined as a chunk of text recognized by `sp-forward-symbol'. The return value is a plist with the same format as the value -returned by `sp-get-sexp'." +returned by `sp-get-sexp'. + +A symbol can also be a prefix of a sexp as determined by +`sp-sexp-prefix' or a suffix as determined by `sp-sexp-suffix'. +Such a symbol is not returned by this function because it is +semantically not a symbol but a part of the next paired +expression." (sp--maybe-init) (let (b e last-or-first) (save-excursion @@ -5521,7 +5741,7 @@ both have to be considered by the parser." PAIRS is either an opening delimiter of a list of opening delimiters. -FUNCTION is a function symbol. +FUNCTION is an interactive function (command) symbol. For example, you can restrict function `sp-down-sexp' to the pair (\"{\" . \"}\") for easier navigation of blocks in C-like @@ -5637,7 +5857,7 @@ Pair object is anything delimited by pairs from `sp-pair-list'." (execute-kbd-macro cmd)))) (defun sp-prefix-symbol-object (&optional _arg) - "Read the command and invoke it on the next pair object. + "Read the command and invoke it on the next symbol object. If you specify a regular emacs prefix argument this is passed to the executed command. Therefore, executing @@ -6619,6 +6839,36 @@ Note: prefix argument is shown after the example in (when (= 0 sp-successive-kill-preserve-whitespace) (kill-append sp-last-kill-whitespace nil))))))))) +(defmacro sp-save-kill-ring (&rest forms) + "Run FORMS while preserving `kill-ring'. + +Any changes to `kill-ring' inside this macro will be reversed +after exiting. + +The changes are usually done by functions suck as `kill-region', +`copy-region-as-kill', `kill-append' and similar." + (declare (indent 0)) + `(let* ((kill-ring nil) + (kill-ring-yank-pointer nil) + (select-enable-clipboard nil)) + ,@forms)) + +(defun sp-delete-sexp (&optional arg) + "Delete the balanced expression following point. + +This is exactly like calling `sp-kill-sexp' +except deleted sexp does not go to the clipboard or kill ring. + +With ARG being positive number N, repeat that many times. + +With ARG being Negative number -N, repeat that many times in +backward direction. + +See also `sp-kill-sexp' examples." + (interactive "*p") + (sp-save-kill-ring + (sp-kill-sexp arg))) + (defun sp--cleanup-after-kill () (unless (save-match-data (looking-back "^[\t\s]+" (1- (line-beginning-position)))) (let ((bdel (save-excursion @@ -6673,6 +6923,22 @@ Examples: (interactive "*P") (sp-kill-sexp (sp--negate-argument arg) dont-kill)) +(defun sp-backward-delete-sexp (&optional arg) + "Delete the balanced expression preceding point. + +This is exactly like calling `sp-backword-kill-sexp' +except deleted sexp does not go to the clipboard or kill ring. + +With ARG being positive number N, repeat that many times. + +With ARG being Negative number -N, repeat that many times in +forward direction. + +See also `sp-backward-kill-sexp' examples." + (interactive "*p") + (sp-save-kill-ring + (sp-backward-kill-sexp arg))) + (defun sp-copy-sexp (&optional arg) "Copy the following ARG expressions to the kill-ring. @@ -7122,7 +7388,12 @@ Examples: (let ((n (abs (prefix-numeric-value arg))) (enc (sp-get-enclosing-sexp)) (in-comment (sp-point-in-comment)) - next-thing ok) + next-thing ok + ;; At some places we mutate the value of `ok' + ;; destructively (updating the end). The original value + ;; is useful in the handlers for manipulating the + ;; surroundings, so we copy it here. + ok-orig) (when enc (save-excursion (if (sp--raw-argument-p arg) @@ -7147,6 +7418,7 @@ Examples: (goto-char (sp-get next-thing :end-suf)) (setq ok next-thing) (setq next-thing (sp-get-thing nil))) + (setq ok-orig (copy-sequence ok)) ;; do not allow slurping into a different context from ;; inside a comment (if (and in-comment @@ -7187,14 +7459,14 @@ Examples: (insert " ")))) (sp--run-hook-with-args (sp-get enc :op) :pre-handlers 'slurp-forward - (list :arg arg :enc enc :ok ok :next-thing next-thing)) + (list :arg arg :enc enc :ok ok :ok-orig ok-orig :next-thing next-thing)) (sp-get ok (insert :cl :suffix)) (sp--indent-region (sp-get ok :beg-prf) (point)) ;; HACK: update the "enc" data structure if ok==enc (when (= (sp-get enc :beg) (sp-get ok :beg)) (plist-put enc :end (point))) (sp--run-hook-with-args (sp-get enc :op) :post-handlers 'slurp-forward - (list :arg arg :enc enc :ok ok :next-thing next-thing))) + (list :arg arg :enc enc :ok ok :ok-orig ok-orig :next-thing next-thing))) (setq n (1- n))) (sp-message :cant-slurp) (setq n -1)))))))) @@ -7530,14 +7802,19 @@ Examples: (sp-point-in-string) (not (sp-point-in-string (,inc (point))))) (and (,looking allowed-pairs) - (or in-comment (not (sp-point-in-comment)))) + (or in-comment (not (sp-point-in-comment))) + (not (sp--skip-match-p + (match-string-no-properties 0) + (match-beginning 0) + (match-end 0)))) (and (,looking allowed-strings) (or in-comment (not (sp-point-in-comment)))))) - (or (member (char-syntax (,next-char-fn)) '(?< ?> ?! ?| ?\ ?\\ ?\" ?' ?.)) - (/= 0 (logand (lsh 1 20) (car (syntax-after - ,(if forward - '(point) - '(1- (point))))))) + (or (member + ,(if forward '(sp-syntax-after) '(sp-syntax-before)) + '(?< ?> ?! ?| ?\ ?\\ ?\" ?' ?.)) + ,(if forward + '(sp-syntax-after-is-prefix (point)) + '(sp-syntax-before-is-prefix (point))) (unless in-comment (sp-point-in-comment)) ;; This is the case where we are starting at ;; pair (looking at it) and there is some @@ -7651,7 +7928,7 @@ Examples: ;; something in \sw or \s_ (while (cond ((eobp) nil) - ((not (memq (char-syntax (following-char)) '(?w ?_))) + ((not (sp-syntax-after-is-word-or-symbol)) (forward-char) t) ;; if allowed is empty, the regexp matches anything @@ -7664,13 +7941,13 @@ Examples: (or (not allowed) (not (or (sp--valid-initial-delimiter-p (sp--looking-at open)) (sp--valid-initial-delimiter-p (sp--looking-at close))))) - (or (memq (char-syntax (following-char)) '(?w ?_)) + (or (sp-syntax-after-is-word-or-symbol) ;; Specifically for lisp, we consider ;; sequences of ?\ a symbol ;; sequence (and (eq (char-before) ??) - (eq (char-syntax (following-char)) ?\\)) - (and (eq (char-syntax (char-before)) ?\\)))) + (eq (sp-syntax-after) ?\\)) + (and (eq (sp-syntax-before) ?\\)))) (forward-char)) (setq n (1- n))) (sp-backward-symbol n))))) @@ -7709,7 +7986,7 @@ Examples: (while (> n 0) (while (cond ((bobp) nil) - ((not (memq (char-syntax (preceding-char)) '(?w ?_))) + ((not (sp-syntax-before-is-word-or-symbol)) (backward-char) t) ((sp--valid-initial-delimiter-p (sp--looking-back open)) @@ -7719,13 +7996,12 @@ Examples: (while (and (not (bobp)) (not (or (sp--valid-initial-delimiter-p (sp--looking-back open)) (sp--valid-initial-delimiter-p (sp--looking-back close)))) - (or (memq (char-syntax (preceding-char)) '(?w ?_)) + (or (sp-syntax-before-is-word-or-symbol) ;; Specifically for lisp, we consider ;; sequences of ?\ a symbol ;; sequence (and (eq (char-before (1- (point))) ??) - (eq (char-syntax (preceding-char)) ?\\)) - )) + (eq (sp-syntax-before) ?\\)))) (backward-char)) ;; skip characters which are symbols with prefix flag (while (and (not (eobp)) @@ -8883,6 +9159,8 @@ If on a closing delimiter, move backward into balanced expression. If on a opening delimiter, refuse to delete unless the balanced expression is empty, in which case delete the entire expression. +If `sp-delete-blank-sexps' is non-nil, the expression is also +considered empty if it contains only white-space. If the delimiter does not form a balanced expression, it will be deleted normally. @@ -8928,6 +9206,13 @@ Examples: ok) ;; make this customizable (setq n (1- n))) + ((and sp-delete-blank-sexps + (sp--looking-back (sp--get-opening-regexp (sp--get-pair-list-context 'navigate))) + (-when-let ((beg . end) (sp-point-in-blank-sexp)) + (goto-char beg) + (delete-char (- end beg)) + t)) + (setq n (1- n))) ((and (sp-point-in-string) (save-excursion (backward-char) (not (sp-point-in-string)))) (setq n 0)) @@ -9085,8 +9370,7 @@ backward direction. See `sp-forward-symbol' for what constitutes a symbol." (interactive "*p") - (let* ((kill-ring kill-ring) - (select-enable-clipboard nil)) + (sp-save-kill-ring (sp-kill-symbol arg word))) (defun sp-delete-word (&optional arg) @@ -9162,8 +9446,7 @@ forward direction. See `sp-backward-symbol' for what constitutes a symbol." (interactive "*p") - (let* ((kill-ring kill-ring) - (select-enable-clipboard nil)) + (sp-save-kill-ring (sp-backward-kill-symbol arg word))) (defun sp-backward-delete-word (&optional arg) @@ -9358,7 +9641,11 @@ After the next command the pair will automatically disappear." (defcustom sp-show-pair-from-inside nil "If non-nil, highlight the enclosing pair if immediately after -the opening delimiter or before the closing delimiter." +the opening delimiter or before the closing delimiter. + +This option does not disable highlighting of pairs from outside +the expression. If a pair can be highlighted from the outside, +it is preferred to the one highlighted from the inside." :type 'boolean :group 'show-smartparens) @@ -9417,16 +9704,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 () @@ -9434,6 +9728,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)) @@ -9522,26 +9820,28 @@ matching paren in the echo area if not visible on screen." (let* ((pair-list (sp--get-allowed-pair-list)) (opening (sp--get-opening-regexp pair-list)) (closing (sp--get-closing-regexp pair-list)) - (allowed (and sp-show-pair-from-inside (sp--get-allowed-regexp)))) + (allowed (sp--get-allowed-regexp pair-list)) + (stringlike (sp--get-stringlike-regexp))) (cond ;; if we are in a situation "()|", we should highlight the ;; regular pair and not the string pair "from inside" ((and (not (sp--evil-normal-state-p)) (not (sp--evil-motion-state-p)) (not (sp--evil-visual-state-p)) - (sp--looking-back (if sp-show-pair-from-inside allowed closing))) + (sp--looking-back (if sp-show-pair-from-inside allowed closing)) + (not (looking-at opening))) (scan-and-place-overlays (match-string 0) :back)) ((or (and (or (sp--evil-normal-state-p) (sp--evil-motion-state-p) (sp--evil-visual-state-p)) - (sp--looking-at (sp--get-allowed-regexp))) - (sp--looking-at (if sp-show-pair-from-inside allowed opening)) - (looking-at (sp--get-stringlike-regexp)) + (looking-at allowed)) + (looking-at (if sp-show-pair-from-inside allowed opening)) + (looking-at stringlike) (and (memq major-mode sp-navigate-consider-sgml-tags) (looking-at "<"))) (scan-and-place-overlays (match-string 0))) ((or (sp--looking-back (if sp-show-pair-from-inside allowed closing)) - (sp--looking-back (sp--get-stringlike-regexp)) + (sp--looking-back stringlike) (and (memq major-mode sp-navigate-consider-sgml-tags) (sp--looking-back ">"))) (scan-and-place-overlays (match-string 0) :back)) @@ -9661,12 +9961,15 @@ has been created." (defadvice company--insert-candidate (after sp-company--insert-candidate activate) "If `smartparens-mode' is active, we check if the completed string has a pair definition. If so, we insert the closing pair." - (when smartparens-mode + (when (and ad-return-value + smartparens-mode + (not (sp-get-enclosing-sexp))) (sp-insert-pair)) ad-return-value) (defadvice hippie-expand (after sp-auto-complete-advice activate) - (when smartparens-mode + (when (and smartparens-mode + (not (sp-get-enclosing-sexp))) (sp-insert-pair))) (defvar sp--mc/cursor-specific-vars diff --git a/elpa/smartparens-20230529.1017/sp-sublimetext-like.el b/elpa/smartparens-20241220.1254/sp-sublimetext-like.el similarity index 100% rename from elpa/smartparens-20230529.1017/sp-sublimetext-like.el rename to elpa/smartparens-20241220.1254/sp-sublimetext-like.el diff --git a/elpa/smartparens-readme.txt b/elpa/smartparens-readme.txt deleted file mode 100644 index 5185c3f3..00000000 --- a/elpa/smartparens-readme.txt +++ /dev/null @@ -1,17 +0,0 @@ -Smartparens is minor mode for Emacs that deals with parens pairs -and tries to be smart about it. It started as a unification effort -to combine functionality of several existing packages in a single, -compatible and extensible way to deal with parentheses, delimiters, -tags and the like. Some of these packages include autopair, -textmate, wrap-region, electric-pair-mode, paredit and others. With -the basic features found in other packages it also brings many -improvements as well as completely new features. - -For a basic overview, see github readme at -https://github.com/Fuco1/smartparens - -For the complete documentation visit the documentation wiki located -at https://github.com/Fuco1/smartparens/wiki - -If you like this project, you can donate here: -https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=CEYP5YVHDRX8C -- 2.47.3