Added emacs prelude and config

This commit is contained in:
TuDatTr
2018-01-09 04:06:05 +01:00
parent 87a671756a
commit 505d3526b8
1129 changed files with 308314 additions and 5398 deletions

View File

@@ -0,0 +1,202 @@
;;; smartparens-autoloads.el --- automatically extracted autoloads
;;
;;; Code:
(add-to-list 'load-path (directory-file-name (or (file-name-directory #$) (car load-path))))
;;;### (autoloads nil "smartparens" "smartparens.el" (23122 58423
;;;;;; 396029 548000))
;;; Generated autoloads from smartparens.el
(autoload 'sp-cheat-sheet "smartparens" "\
Generate a cheat sheet of all the smartparens interactive functions.
Without a prefix argument, print only the short documentation and examples.
With non-nil prefix argument ARG, show the full documentation for each function.
You can follow the links to the function or variable help page.
To get back to the full list, use \\[help-go-back].
You can use `beginning-of-defun' and `end-of-defun' to jump to
the previous/next entry.
Examples are fontified using the `font-lock-string-face' for
better orientation.
\(fn &optional ARG)" t nil)
(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'.
\(fn)" t nil)
(autoload 'sp-use-smartparens-bindings "smartparens" "\
Initiate `smartparens-mode-map' with `sp-smartparens-bindings'.
\(fn)" t nil)
(autoload 'smartparens-mode "smartparens" "\
Toggle smartparens mode.
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)
(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
keep the structure always valid (the same way as `paredit-mode'
does). This is accomplished by remapping them to
`sp-delete-char' and `sp-kill-word'. There is also function
`sp-kill-symbol' that deletes symbols instead of words, otherwise
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)
(defvar smartparens-global-strict-mode nil "\
Non-nil if Smartparens-Global-Strict mode is enabled.
See the `smartparens-global-strict-mode' command
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 positive;
otherwise, disable it. If called from Lisp, enable the mode if
ARG is omitted or nil.
Smartparens-Strict mode is enabled in all buffers where
`turn-on-smartparens-strict-mode' would do it.
See `smartparens-strict-mode' for more information on Smartparens-Strict mode.
\(fn &optional ARG)" t nil)
(autoload 'turn-on-smartparens-strict-mode "smartparens" "\
Turn on `smartparens-strict-mode'.
\(fn)" t nil)
(autoload 'turn-off-smartparens-strict-mode "smartparens" "\
Turn off `smartparens-strict-mode'.
\(fn)" t nil)
(defvar smartparens-global-mode nil "\
Non-nil if Smartparens-Global mode is enabled.
See the `smartparens-global-mode' command
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;
otherwise, disable it. If called from Lisp, enable the mode if
ARG is omitted or nil.
Smartparens mode is enabled in all buffers where
`turn-on-smartparens-mode' would do it.
See `smartparens-mode' for more information on Smartparens mode.
\(fn &optional ARG)" t nil)
(autoload 'turn-on-smartparens-mode "smartparens" "\
Turn on `smartparens-mode'.
This function is used to turn on `smartparens-global-mode'.
By default `smartparens-global-mode' ignores buffers with
`mode-class' set to special, but only if they are also not comint
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'.
\(fn)" t nil)
(autoload 'turn-off-smartparens-mode "smartparens" "\
Turn off `smartparens-mode'.
\(fn)" t nil)
(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.
\(fn &optional ARG)" t nil)
(defvar show-smartparens-global-mode nil "\
Non-nil if Show-Smartparens-Global mode is enabled.
See the `show-smartparens-global-mode' command
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 positive;
otherwise, disable it. If called from Lisp, enable the mode if
ARG is omitted or nil.
Show-Smartparens mode is enabled in all buffers where
`turn-on-show-smartparens-mode' would do it.
See `show-smartparens-mode' for more information on Show-Smartparens mode.
\(fn &optional ARG)" t nil)
(autoload 'turn-on-show-smartparens-mode "smartparens" "\
Turn on `show-smartparens-mode'.
\(fn)" t nil)
(autoload 'turn-off-show-smartparens-mode "smartparens" "\
Turn off `show-smartparens-mode'.
\(fn)" t nil)
;;;***
;;;### (autoloads nil nil ("smartparens-clojure.el" "smartparens-config.el"
;;;;;; "smartparens-elixir.el" "smartparens-ess.el" "smartparens-haskell.el"
;;;;;; "smartparens-html.el" "smartparens-javascript.el" "smartparens-latex.el"
;;;;;; "smartparens-lua.el" "smartparens-markdown.el" "smartparens-ml.el"
;;;;;; "smartparens-org.el" "smartparens-pkg.el" "smartparens-python.el"
;;;;;; "smartparens-racket.el" "smartparens-ruby.el" "smartparens-rust.el"
;;;;;; "smartparens-scala.el" "smartparens-text.el") (23122 58423
;;;;;; 452716 98000))
;;;***
;; Local Variables:
;; version-control: never
;; no-byte-compile: t
;; no-update-autoloads: t
;; End:
;;; smartparens-autoloads.el ends here

View File

@@ -0,0 +1,56 @@
;;; smartparens-clojure.el --- Additional configuration for Clojure mode.
;;
;; Author: Vitalie Spinu <spinuvit@gmail.com>
;; Maintainer: Matus Goljer <matus.goljer@gmail.com>
;; Created: 14 July 2016
;; Keywords: abbrev convenience editing
;; 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 <http://www.gnu.org/licenses/>.
;;
;;; Commentary:
;;
;; This file provides some additional configuration for Clojure mode. To use
;; it, simply add:
;;
;; (require 'smartparens-clojure)
;;
;; into your configuration. You can use this in conjunction with the
;; default config or your own configuration.
;;
;;; Code:
(require 'smartparens)
(defvar sp-clojure-prefix "\\(?:[@`'#~,_?^]+\\)"
"Prefix used in `sp-sepx-prefix' for clojure modes.")
(dolist (mode '(clojure-mode clojurescript-mode clojurec-mode cider-repl-mode))
(add-to-list 'sp-sexp-prefix `(,mode regexp ,sp-clojure-prefix)))
;; Match "`" with "`" in strings and comments
(sp-with-modes sp-clojure-modes
(sp-local-pair "`" "`"
:when '(sp-in-string-p
sp-in-comment-p)
:unless '(sp-lisp-invalid-hyperlink-p)))
(provide 'smartparens-clojure)
;;; smartparens-clojure.el ends here

View File

@@ -0,0 +1,129 @@
;;; smartparens-config.el --- Default configuration for smartparens package
;; Copyright (C) 2013-2016 Matus Goljer
;; Author: Matus Goljer <matus.goljer@gmail.com>
;; Maintainer: Matus Goljer <matus.goljer@gmail.com>
;; Created: 30 Jan 2013
;; Keywords: abbrev convenience editing
;; 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 <http://www.gnu.org/licenses/>.
;;; Commentary:
;; This is a default configuration for smartparens package. If you
;; wish to set up everything by yourself, you can instead require
;; smartparens directly.
;; However, some configuration is always loaded by default, most
;; notably the built-in list of supported pairs. If you want to erase
;; this list, simply use (setq sp-pairs nil) and then add your own
;; pairs.
;; For more info, see github readme at
;; https://github.com/Fuco1/smartparens
;;; Code:
(require 'smartparens)
(defun sp-lisp-invalid-hyperlink-p (id action context)
"Test if there is an invalid hyperlink in a Lisp docstring.
ID, ACTION, CONTEXT."
(when (eq action 'navigate)
;; Ignore errors due to us being at the start or end of the
;; buffer.
(ignore-errors
(or (and (looking-at "\\sw\\|\\s_")
(save-excursion
(backward-char 2)
(looking-at "\\sw\\|\\s_")))
(and (save-excursion
(backward-char 1)
(looking-at "\\sw\\|\\s_"))
(save-excursion
(forward-char 1)
(looking-at "\\sw\\|\\s_")))))))
;; emacs is lisp hacking enviroment, so we set up some most common
;; lisp modes too
(sp-with-modes sp-lisp-modes
;; disable ', it's the quote character!
(sp-local-pair "'" nil :actions nil))
(sp-with-modes (-difference sp-lisp-modes sp-clojure-modes)
;; also only use the pseudo-quote inside strings where it serve as
;; hyperlink.
(sp-local-pair "`" "'"
:when '(sp-in-string-p
sp-in-comment-p)
:unless '(sp-lisp-invalid-hyperlink-p)
:skip-match (lambda (ms mb me)
(cond
((equal ms "'")
(or (sp-lisp-invalid-hyperlink-p "`" 'navigate '_)
(not (sp-point-in-string-or-comment))))
(t (not (sp-point-in-string-or-comment)))))))
;; <rant>Unfortunately emacs devs in their glorious wisdom decided to
;; make @ no longer have prefix syntax, it is now a symbol... because
;; apparently its use in symbols is so frequent. Anyway, since we
;; can't really change that, let's use a regexp based solution</rant>
(add-to-list 'sp-sexp-prefix (list 'emacs-lisp-mode 'regexp "\\(?:['`]*,@?\\|[',`]\\)"))
;; TODO: this should only be active in docstring, otherwise we want
;; the regexp completion \\{\\}. To handle this feature, we must
;; allow multiple pairs on same opening (therefore, the unique ID must
;; become the opening and closing pair)
(sp-local-pair 'emacs-lisp-mode "\\\\{" "}" :when '(sp-in-docstring-p))
;; NOTE: Normally, `sp-local-pair' accepts list of modes (or a single
;; mode) as a first argument. The macro `sp-with-modes' adds this
;; automatically. If you want to call sp-local-pair outside this
;; macro, you MUST supply the major mode argument.
(eval-after-load 'clojure-mode '(require 'smartparens-clojure))
(eval-after-load 'elixir-mode '(require 'smartparens-elixir))
(eval-after-load 'enh-ruby-mode '(require 'smartparens-ruby))
(eval-after-load 'ess '(require 'smartparens-ess))
(eval-after-load 'haskell-interactive-mode '(require 'smartparens-haskell))
(eval-after-load 'haskell-mode '(require 'smartparens-haskell))
(--each sp--html-modes
(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 'markdown-mode '(require 'smartparens-markdown))
(--each '(python-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 'ruby-mode '(require 'smartparens-ruby))
(eval-after-load 'rust-mode '(require 'smartparens-rust))
(eval-after-load 'scala-mode '(require 'smartparens-scala))
(eval-after-load 'tex-mode '(require 'smartparens-latex))
(eval-after-load 'text-mode '(require 'smartparens-text))
(eval-after-load 'tuareg '(require 'smartparens-ml))
(eval-after-load 'fsharp-mode '(require 'smartparens-ml))
(--each '(js js2-mode)
(eval-after-load it '(require 'smartparens-javascript)))
(provide 'smartparens-config)
;;; smartparens-config.el ends here

View File

@@ -0,0 +1,134 @@
;;; smartparens-elixir.el --- Configuration for Elixir.
;; Copyright (C) 2017 Matúš Goljer
;; Author: Matúš Goljer <matus.goljer@gmail.com>
;; Maintainer: Matúš Goljer <matus.goljer@gmail.com>
;; Version: 0.0.1
;; Created: 15th January 2017
;; Keywords: languages
;; This program 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.
;; This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;;; Code:
(require 'smartparens)
(--each '(elixir-mode)
(add-to-list 'sp-sexp-suffix (list it 'regexp "")))
(defun sp-elixir-def-p (id)
"Return non-nil if the \"do\" keyword is part of definition.
ID is the opening delimiter.
Definitions are the constructions of the form defmodule-do-end,
def-do-end and similar pairs."
(save-excursion
(when (equal "do" id)
(back-to-indentation)
(looking-at (regexp-opt '(
"defmodule"
"defmacro"
"defmacrop"
"quote"
"def"
"defp"
"if"
"unless"
"case"
"cond"
"with"
"for"
"receive"
"try"
))))))
(defun sp-elixir-skip-def-p (ms mb me)
"Test if \"do\" is part of definition.
MS, MB, ME."
(sp-elixir-def-p ms))
(defun sp-elixir-do-block-post-handler (id action context)
"Insert \"do\" keyword and indent the new block.
ID, ACTION, CONTEXT."
(when (eq action 'insert)
(let ((m (make-marker)))
(save-excursion
(forward-word) ;; over the "end"
(move-marker m (point)))
(save-excursion (newline))
(save-excursion (insert " do"))
(indent-region (line-beginning-position) m)
(move-marker m nil nil))))
(defun sp-elixir-empty-do-block-post-handler (id action context)
"Insert empty \"do\" keyword and indent the new block.
This is used for receive-do-end expression.
ID, ACTION, CONTEXT."
(when (eq action 'insert)
(let ((m (make-marker)))
(save-excursion
(forward-word) ;; over the "end"
(move-marker m (point)))
(save-excursion
(forward-line -1)
(end-of-line)
(insert " do"))
(save-excursion (newline))
(indent-region (line-beginning-position) m)
(indent-according-to-mode)
(move-marker m nil nil))))
(sp-with-modes 'elixir-mode
(sp-local-pair "do" "end"
:when '(("SPC" "RET" "<evil-ret>"))
:skip-match 'sp-elixir-skip-def-p)
(sp-local-pair "def" "end"
:when '(("SPC" "RET" "<evil-ret>"))
:post-handlers '(sp-elixir-do-block-post-handler)
:unless '(sp-in-comment-p))
(sp-local-pair "defp" "end"
:when '(("SPC" "RET" "<evil-ret>"))
:post-handlers '(sp-elixir-do-block-post-handler)
:unless '(sp-in-comment-p))
(sp-local-pair "defmodule" "end"
:when '(("SPC" "RET" "<evil-ret>"))
:post-handlers '(sp-elixir-do-block-post-handler)
:unless '(sp-in-comment-p))
(sp-local-pair "fn" "end"
:when '(("SPC" "RET" "<evil-ret>"))
:post-handlers '("| "))
(sp-local-pair "if" "end"
:when '(("SPC" "RET" "<evil-ret>"))
:post-handlers '(sp-elixir-do-block-post-handler)
:unless '(sp-in-comment-p))
(sp-local-pair "unless" "end"
:when '(("SPC" "RET" "<evil-ret>"))
:post-handlers '(sp-elixir-do-block-post-handler)
:unless '(sp-in-comment-p))
(sp-local-pair "case" "end"
:when '(("SPC" "RET" "<evil-ret>"))
:post-handlers '(sp-elixir-do-block-post-handler)
:unless '(sp-in-comment-p))
(sp-local-pair "receive" "end"
:when '(("RET" "<evil-ret>"))
:post-handlers '(sp-elixir-empty-do-block-post-handler))
)
(provide 'smartparens-elixir)
;;; smartparens-elixir.el ends here

View File

@@ -0,0 +1,224 @@
;;; smartparens-ess.el --- Smartparens Extension for Emacs Speaks Statistics
;; Copyright (c) 2015-2016 Bernhard Pröll
;; Author: Bernhard Pröll
;; 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.
;; This program 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.
;; This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;;
;; This file provides some additional configuration for ESS. To use
;; it, simply add:
;;
;; (require 'smartparens-ess)
;;
;; into your configuration. You can use this in conjunction with the
;; default config or your own configuration.
;;
;;; Code:
(require 'smartparens)
(require 'rx)
;; avoid traveling commas when slurping
;; (|a, b), c ---> (|a, b, c)
(dolist (mode '(ess-mode inferior-ess-mode))
(add-to-list 'sp-sexp-suffix (list mode 'regexp "")))
;; `sp-sexp-prefix' for ESS
(add-to-list 'sp-sexp-prefix
(list 'ess-mode 'regexp
(rx (zero-or-more (or word (syntax symbol))))))
;; slurping follows Google's R style guide
;; see https://google.github.io/styleguide/Rguide.xml
(defun sp-ess-pre-handler (id action context)
"Remove spaces before opening parenthesis in a function call.
Remove redundant space around commas.
ID, ACTION, CONTEXT."
(when (equal action 'slurp-forward)
(let ((sxp (sp-get-thing 'back)))
(save-excursion
(goto-char (sp-get sxp :beg-prf))
;; (|) x ---> (x)
(when (looking-back (rx (syntax open-parenthesis)
(one-or-more space)))
(cycle-spacing 0 nil 'single-shot))
(cond
;; (|)if(cond) ---> (|if (cond))
((member (sp-get sxp :prefix) '("if" "for" "while"))
(goto-char (sp-get sxp :beg))
(cycle-spacing 1 nil 'single-shot))
;; (|)v [,2] <- if(x > 1) ---> (v[,2] <- if (x > 1))
((and
(member (sp-get sxp :op) '("[" "("))
(equal (sp-get sxp :prefix) "")
(looking-back
(rx (and (not-char "%" ",")
(not (syntax close-parenthesis)))
(one-or-more space)))
(not (member
(save-excursion
(sp-backward-sexp)
(thing-at-point 'word 'noprop))
'("if" "for" "while"))))
(cycle-spacing 0 nil 'single-shot))
;; (|[...])%in% ---> ([...] %in%|)
((or (looking-at "%") (looking-back "%"))
(just-one-space))
;; (|)a , b, c ---> (|a, b, c)
((looking-back
(rx (zero-or-more space) "," (zero-or-more space))
(line-beginning-position) 'greedy)
(replace-match ", "))))))
(when (equal action 'slurp-backward)
(let ((sxp (sp-get-thing)))
(save-excursion
(goto-char (sp-get sxp :end))
;; x (|) ---> (x)
(when (looking-at (rx (one-or-more space)
(syntax close-parenthesis)))
(cycle-spacing 0 nil 'single-shot))
;; if(cond){} (|) ---> (if (cond) {}|)
(cond ((member (sp-get sxp :prefix) '("if" "for" "while"))
(goto-char (sp-get sxp :beg))
(cycle-spacing 1 nil 'single-shot))
;; for style reasons there should be a space before curly
;; brackets and binary operators
((and (member (sp-get sxp :op) '("{" "%"))
(not (looking-at (rx (syntax close-parenthesis)))))
(cycle-spacing 1 nil 'single-shot))
;; v[2](|) ---> (v[2]|)
((and
(not (member (thing-at-point 'word 'noprop)
'("if" "for" "while")))
(looking-at
(rx (and (zero-or-more space)
(not-char "{")
(or (syntax close-parenthesis)
(char "(")
(char "["))))))
(cycle-spacing 0 nil 'single-shot))
;; 1 , 2 (|) ---> (1, 2)
((looking-at
(rx (zero-or-more space) "," (zero-or-more space)))
(replace-match ", ")))))))
;; function(x) {|} ---> function(x) {\n|\n}
;; ##' \tabular{rrr}{|} --->
;; ##' \tabular{rrr}{
;; ##' |
;; ##' }
(defun sp-ess-open-sexp-indent (&rest args)
"Open new brace or bracket with indentation.
ARGS."
(if (and (fboundp 'ess-roxy-entry-p) (ess-roxy-entry-p))
(progn
(save-excursion (ess-roxy-indent-on-newline))
(when (looking-back ess-roxy-str nil)
(cycle-spacing 3 nil t)))
(newline)
(indent-according-to-mode)
(forward-line -1)
(indent-according-to-mode)))
(defun sp-ess-roxy-str-p (id action context)
"Test if looking back at `ess-roxy-re'.
ID, ACTION, CONTEXT."
(when (and (boundp 'ess-roxy-re) (eq action 'insert))
(sp--looking-back-p ess-roxy-re)))
(sp-with-modes 'ess-mode
(sp-local-pair "{" nil
:pre-handlers '(sp-ess-pre-handler)
;; the more reasonable C-j interferes with default binding for
;; `ess-eval-line'
:post-handlers '((sp-ess-open-sexp-indent "M-j")))
(sp-local-pair "(" nil
:pre-handlers '(sp-ess-pre-handler)
:post-handlers '((sp-ess-open-sexp-indent "M-j")))
(sp-local-pair "[" nil
:pre-handlers '(sp-ess-pre-handler)
:post-handlers '((sp-ess-open-sexp-indent "M-j")))
(sp-local-pair "'" nil
:unless '(sp-ess-roxy-str-p sp-in-comment-p sp-in-string-quotes-p)))
;;; roxygen2 markup
;; see https://cran.r-project.org/web/packages/roxygen2/vignettes/formatting.html
(sp-with-modes 'ess-mode
(sp-local-pair "\\strong{" "}"
:when '(sp-in-comment-p)
:trigger "\\strong")
(sp-local-pair "\\emph{" "}"
:when '(sp-in-comment-p)
:trigger "\\emph")
(sp-local-pair "\\code{" "}"
:when '(sp-in-comment-p)
:trigger "\\code")
(sp-local-pair "\\url{" "}"
:when '(sp-in-comment-p)
:trigger "\\url")
(sp-local-pair "\\link{" "}"
:when '(sp-in-comment-p)
:trigger "\\link")
(sp-local-pair "\\href{" "}"
:when '(sp-in-comment-p)
:trigger "\\href"
:suffix "{[^}]*}")
(sp-local-pair "\\email{" "}"
:when '(sp-in-comment-p)
:trigger "\\email")
(sp-local-pair "\\pkg{" "}"
:when '(sp-in-comment-p)
:trigger "\\pkg")
(sp-local-pair "\\item{" "}"
:when '(sp-in-comment-p)
:post-handlers '((sp-ess-open-sexp-indent "M-j"))
:trigger "\\item{")
(sp-local-pair "\\enumerate{" "}"
:when '(sp-in-comment-p)
:post-handlers '((sp-ess-open-sexp-indent "M-j"))
:trigger "\\enumerate")
(sp-local-pair "\\itemize{" "}"
:when '(sp-in-comment-p)
:post-handlers '((sp-ess-open-sexp-indent "M-j"))
:trigger "\\itemize")
(sp-local-pair "\\describe{" "}"
:when '(sp-in-comment-p)
:post-handlers '((sp-ess-open-sexp-indent "M-j"))
:trigger "\\describe")
(sp-local-pair "\\eqn{" "}"
:when '(sp-in-comment-p)
:trigger "\\eqn")
(sp-local-pair "\\deqn{" "}"
:when '(sp-in-comment-p)
:trigger "\\deqn")
(sp-local-pair "\\tabular{" "}"
:when '(sp-in-comment-p)
:trigger "\\tabular"
:post-handlers '((sp-ess-open-sexp-indent "M-j"))
:suffix "{[^}]*}"))
(provide 'smartparens-ess)
;;; smartparens-ess ends here

View File

@@ -0,0 +1,113 @@
;;; smartparens-haskell.el --- Additional configuration for Haskell based modes.
;; Copyright (C) 2015 Michael Xavier
;; Author: Michael Xavier <michael@michaelxavier.net>
;; Maintainer: Michael Xavier <michael@michaelxavier.net>
;; Created: 29 Apr 2016
;; Keywords: abbrev convenience editing
;; 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 <http://www.gnu.org/licenses/>.
;;; Commentary:
;; This file provides some additional configuration for Haskell based
;; modes. To use it, simply add:
;;
;; (require 'smartparens-haskell)
;;
;; 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)
(defun sp-haskell-skip-apostrophe (ms mb me)
(save-excursion
;; We test the syntax class because haskell mode overrides
;; the class for ' on the fly when it run the syntax pass of
;; font-lock... so that if '' is a valid string (char) it
;; gets an override via 'syntax-table property. In which
;; case we just agree with haskell mode and let it be used as
;; a pair.
(not (eq (syntax-class (syntax-after mb)) 7))))
(defun sp-haskell-strict-ignore-apostrophe-after-word (_id action _context)
"Ignore trailing ' when navigating.
Because ' in haskell is symbol class it gets picked up as part of
a words such as myFunction', and then strict mode won't allow us
to delete it. Also show-smartparens-mode incorrectly highlights
it as missing an opener.
So we ignore that pair when at the end of word."
(when (eq action 'navigate)
(sp--looking-back-p (concat "\\(\\sw\\|\\s_\\)'+"))))
(sp-with-modes '(haskell-mode haskell-interactive-mode)
(sp-local-pair "{-" "-}")
(sp-local-pair "{-#" "#-}")
(sp-local-pair "{-@" "@-}")
(sp-local-pair "'" nil
:unless '(sp-point-after-word-p
sp-haskell-strict-ignore-apostrophe-after-word)
:skip-match 'sp-haskell-skip-apostrophe)
(sp-local-pair "\\(" nil :actions nil))
(defun sp--inferior-haskell-mode-backward-bound-fn ()
"Limit the backward search to the prompt if point is on prompt."
(-when-let (limit (cond ((bound-and-true-p comint-last-prompt)
(marker-position (cdr comint-last-prompt)))
((bound-and-true-p comint-last-prompt-overlay)
(overlay-end comint-last-prompt-overlay))
(t nil)))
(and (> (point) limit) limit)))
(defun sp--inferior-haskell-mode-forward-bound-fn ()
"Limit the forward search to exclude the prompt if point is before prompt."
(-when-let (limit (cond ((bound-and-true-p comint-last-prompt)
(marker-position (car comint-last-prompt)))
((bound-and-true-p comint-last-prompt-overlay)
(overlay-start comint-last-prompt-overlay))
(t nil)))
(and (< (point) limit) limit)))
(defun sp--setup-inferior-haskell-mode-search-bounds ()
"Setup the search bound.
If the point is after the last prompt, limit the backward search
only for the propmt.
If the point is before the last prompt, limit the forward search up until the prompt start."
(setq sp-forward-bound-fn 'sp--inferior-haskell-mode-forward-bound-fn)
(setq sp-backward-bound-fn 'sp--inferior-haskell-mode-backward-bound-fn))
(add-hook 'inferior-haskell-mode-hook 'sp--setup-inferior-haskell-mode-search-bounds)
(provide 'smartparens-haskell)
;;; smartparens-haskell.el ends here

View File

@@ -0,0 +1,170 @@
;;; smartparens-html.el --- Additional configuration for HTML based modes.
;; Copyright (C) 2013-2014 Matus Goljer
;; Author: Matus Goljer <matus.goljer@gmail.com>
;; Maintainer: Matus Goljer <matus.goljer@gmail.com>
;; Created: 14 Sep 2013
;; Keywords: abbrev convenience editing
;; 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 <http://www.gnu.org/licenses/>.
;;; Commentary:
;; This file provides some additional configuration for HTML based
;; modes. To use it, simply add:
;;
;; (require 'smartparens-html)
;;
;; into your configuration. You can use this in conjunction with the
;; default config or your own configuration.
;; This file provides these interactive functions:
;; `sp-html-next-tag' - Recommended binding: C-c C-f
;; `sp-html-previous-tag' - Recommended binding: C-c C-b
;;
;; (These two bindings are used for navigation by tags forward or
;; backward, but `sp-forward-sexp' already does that.)
;; 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)
(defun sp-html-next-tag (arg)
"Move point to the beginning of next SGML tag.
With ARG positive N > 1, move N tags forward.
With ARG raw prefix argument \\[universal-argument] move out of
the current tag and to the beginning of enclosing tag.
Note: this function is based on `sp-beginning-of-sexp' but
specialized to only work with SGML tags and to always move
forward."
(interactive "P")
(let ((sp-prefix-tag-object t))
(if (sp--raw-argument-p arg)
(sp-beginning-of-sexp arg)
(sp-beginning-of-sexp (1+ (prefix-numeric-value arg))))))
(defun sp-html-previous-tag (arg)
"Move point to the beginning of previous SGML tag.
With ARG positive N > 1, move N tags backward.
With ARG raw prefix argument \\[universal-argument] move out of
the current tag and to the beginning of enclosing tag.
Note: this function is based on `sp-beginning-of-sexp' but
specialized to only work with SGML tags and to always move
backward."
(interactive "P")
(let ((sp-prefix-tag-object t))
(if (sp--raw-argument-p arg)
(sp-beginning-of-sexp arg)
(sp-beginning-of-sexp (1- (- (prefix-numeric-value arg)))))))
(defun sp-html-post-handler (&optional id action context)
"Post-action hooks for `html-mode'.
ID is the tag being processed, ACTION is the action and CONTEXT
specifies if we are inside a string or code."
(cl-case action
(slurp-forward
(save-excursion
(let ((sp-prefix-pair-object t))
(sp-backward-sexp))
(-when-let (enc (sp-get-enclosing-sexp))
(sp-get enc
(goto-char :beg-in)
(when (looking-at-p "[ \t]*$")
(goto-char :end-in)
(save-excursion
(sp-backward-sexp)
(forward-line -1)
(when (sp-point-in-blank-line)
(delete-region (line-beginning-position) (1+ (line-end-position)))))
(newline-and-indent))))))
(slurp-backward
(save-excursion
(-when-let (enc (sp-get-enclosing-sexp))
(sp-get enc
(goto-char :end-in)
(when (sp--looking-back-p "^[ \t]*")
(save-excursion
(goto-char :beg-in)
(newline-and-indent)
(sp-forward-sexp)
(forward-line)
(when (sp-point-in-blank-line)
(delete-region (line-beginning-position) (1+ (line-end-position))))))))))
(barf-forward
(save-excursion
(let ((sp-prefix-pair-object t))
(sp-backward-sexp))
(-when-let (enc (sp-get-enclosing-sexp))
(sp-get enc
(goto-char :beg-in)
(when (looking-at-p "[ \t]*$")
(goto-char :end-in)
(newline-and-indent)))))
(save-excursion
(sp-forward-sexp)
(forward-line)
(when (sp-point-in-blank-line)
(delete-region (line-beginning-position) (1+ (line-end-position))))))
(barf-backward
(save-excursion
(-when-let (enc (sp-get-enclosing-sexp))
(sp-get enc
(goto-char :end-in)
(when (sp--looking-back-p "^[ \t]*")
(goto-char :beg-in)
(newline-and-indent)
(sp-backward-up-sexp)
(sp-backward-sexp)
(forward-line -1)
(when (sp-point-in-blank-line)
(delete-region (line-beginning-position) (1+ (line-end-position)))))))))
(beginning-of-sexp
(when (looking-at-p "[ \t]*$")
(sp-next-sexp)))
(end-of-sexp
(when (sp--looking-back-p "^[ \t]*" nil t)
(sp-previous-sexp)))))
(sp-with-modes sp--html-modes
(sp-local-pair "<" ">")
(sp-local-tag "<" "<_>" "</_>" :transform 'sp-match-sgml-tags :post-handlers '(sp-html-post-handler)))
(--each sp--html-modes
(add-to-list 'sp-navigate-consider-sgml-tags it))
(provide 'smartparens-html)
;;; smartparens-html.el ends here

View File

@@ -0,0 +1,55 @@
;;; smartparens-javascript.el --- Additional configuration for JavaScript based modes.
;; Copyright (c) 2017 Marinin Tim
;; Author: Tim Marinin <mt@marinin.xyz>
;; Maintainer: Tim Marinin <mt@marinin.xyz>
;; Created: 2017-03-03
;; Keywords: abbrev convenience editing javascript
;; 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 <http://www.gnu.org/licenses/>.
;;; Commentary:
;; This file provides some additional configuration for JavaScript based
;; modes. To use it, simply add:
;;
;; (require 'smartparens-javascript)
;;
;; 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)
;; (|sys).path.append---the dot should not travel with the closing
;; paren
(--each '(js-mode javascript-mode js2-mode typescript-mode)
(add-to-list 'sp-sexp-suffix (list it 'regexp "")))
(provide 'smartparens-javascript)
;;; smartparens-javasript.el ends here

View File

@@ -0,0 +1,185 @@
;;; smartparens-latex.el --- Additional configuration for (La)TeX based modes.
;; Copyright (C) 2013-2016 Matus Goljer
;; Author: Matus Goljer <matus.goljer@gmail.com>
;; Maintainer: Matus Goljer <matus.goljer@gmail.com>
;; Created: 14 Feb 2013
;; Keywords: abbrev convenience editing
;; 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 <http://www.gnu.org/licenses/>.
;;; Commentary:
;; This file provides some additional configuration for (La)TeX based
;; modes. To use it, simply add:
;;
;; (require 'smartparens-latex)
;;
;; 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)
(defun sp-latex-insert-spaces-inside-pair (id action context)
"ID, ACTION, CONTEXT."
(when (eq action 'insert)
(insert " ")
(backward-char 1))
(when (and (eq action 'wrap)
(save-excursion
(goto-char (sp-get sp-last-wrapped-region :beg-in))
(not (sp--looking-back-p "[[{(]"))))
(save-excursion
(goto-char (sp-get sp-last-wrapped-region :end-in))
(insert " ")
(goto-char (sp-get sp-last-wrapped-region :beg-in))
(insert " "))))
(defun sp-latex-skip-match-apostrophe (ms mb me)
"MS, MB, ME."
(when (equal ms "'")
(save-excursion
(goto-char me)
(looking-at-p "\\sw"))))
(defun sp-latex-skip-double-quote (id action context)
"ID, ACTION, CONTEXT."
(when (eq action 'insert)
(when (looking-at-p "''''")
(delete-char -2)
(delete-char 2)
(forward-char 2))))
(defun sp-latex-point-after-backslash (id action context)
"Return t if point follows a backslash, nil otherwise.
This predicate is only tested on \"insert\" action.
ID, ACTION, CONTEXT."
(when (eq action 'insert)
(let ((trigger (sp-get-pair id :trigger)))
(looking-back (concat "\\\\" (regexp-quote (if trigger trigger id)))))))
(add-to-list 'sp-navigate-skip-match
'((tex-mode plain-tex-mode latex-mode) . sp--backslash-skip-match))
(sp-with-modes '(
tex-mode
plain-tex-mode
latex-mode
LaTeX-mode
)
(sp-local-pair "`" "'"
:actions '(:rem autoskip)
:skip-match 'sp-latex-skip-match-apostrophe
:unless '(sp-latex-point-after-backslash))
;; math modes, yay. The :actions are provided automatically if
;; these pairs do not have global definitions.
(sp-local-pair "$" "$")
(sp-local-pair "\\[" "\\]"
:unless '(sp-latex-point-after-backslash))
;; disable useless pairs. Maybe also remove " ' and \"?
(sp-local-pair "/*" nil :actions nil)
(sp-local-pair "\\\\(" nil :actions nil)
(sp-local-pair "'" nil :actions nil)
(sp-local-pair "\\\"" nil :actions nil)
;; quote should insert ``'' instead of double quotes. If we ever
;; need to insert ", C-q is our friend.
(sp-local-pair "``" "''"
:trigger "\""
:unless '(sp-latex-point-after-backslash)
:post-handlers '(sp-latex-skip-double-quote))
;; add the prefix function sticking to {} pair
(sp-local-pair "{" nil :prefix "\\\\\\(\\sw\\|\\s_\\)*")
;; do not add more space when slurping
(sp-local-pair "{" "}")
(sp-local-pair "(" ")")
(sp-local-pair "[" "]")
;; pairs for big brackets. Needs more research on what pairs are
;; useful to add here. Post suggestions if you know some.
(sp-local-pair "\\left(" "\\right)"
:trigger "\\l("
:when '(sp-in-math-p)
:post-handlers '(sp-latex-insert-spaces-inside-pair))
(sp-local-pair "\\left[" "\\right]"
:trigger "\\l["
:when '(sp-in-math-p)
:post-handlers '(sp-latex-insert-spaces-inside-pair))
(sp-local-pair "\\left\\{" "\\right\\}"
:trigger "\\l{"
:when '(sp-in-math-p)
:post-handlers '(sp-latex-insert-spaces-inside-pair))
(sp-local-pair "\\left|" "\\right|"
:trigger "\\l|"
:when '(sp-in-math-p)
:post-handlers '(sp-latex-insert-spaces-inside-pair))
(sp-local-pair "\\bigl(" "\\bigr)"
:post-handlers '(sp-latex-insert-spaces-inside-pair))
(sp-local-pair "\\biggl(" "\\biggr)"
:post-handlers '(sp-latex-insert-spaces-inside-pair))
(sp-local-pair "\\Bigl(" "\\Bigr)"
:post-handlers '(sp-latex-insert-spaces-inside-pair))
(sp-local-pair "\\Biggl(" "\\Biggr)"
:post-handlers '(sp-latex-insert-spaces-inside-pair))
(sp-local-pair "\\bigl[" "\\bigr]"
:post-handlers '(sp-latex-insert-spaces-inside-pair))
(sp-local-pair "\\biggl[" "\\biggr]"
:post-handlers '(sp-latex-insert-spaces-inside-pair))
(sp-local-pair "\\Bigl[" "\\Bigr]"
:post-handlers '(sp-latex-insert-spaces-inside-pair))
(sp-local-pair "\\Biggl[" "\\Biggr]"
:post-handlers '(sp-latex-insert-spaces-inside-pair))
(sp-local-pair "\\bigl\\{" "\\bigr\\}"
:post-handlers '(sp-latex-insert-spaces-inside-pair))
(sp-local-pair "\\biggl\\{" "\\biggr\\}"
:post-handlers '(sp-latex-insert-spaces-inside-pair))
(sp-local-pair "\\Bigl\\{" "\\Bigr\\}"
:post-handlers '(sp-latex-insert-spaces-inside-pair))
(sp-local-pair "\\Biggl\\{" "\\Biggr\\}"
:post-handlers '(sp-latex-insert-spaces-inside-pair))
(sp-local-pair "\\lfloor" "\\rfloor"
:post-handlers '(sp-latex-insert-spaces-inside-pair))
(sp-local-pair "\\lceil" "\\rceil"
:post-handlers '(sp-latex-insert-spaces-inside-pair))
(sp-local-pair "\\langle" "\\rangle"
:post-handlers '(sp-latex-insert-spaces-inside-pair))
;; some common wrappings
(sp-local-tag "\"" "``" "''" :actions '(wrap))
(sp-local-tag "\\b" "\\begin{_}" "\\end{_}")
(sp-local-tag "bi" "\\begin{itemize}" "\\end{itemize}")
(sp-local-tag "be" "\\begin{enumerate}" "\\end{enumerate}"))
(provide 'smartparens-latex)
;;; smartparens-latex.el ends here

View File

@@ -0,0 +1,90 @@
;;; smartparens-lua.el --- Additional configuration for Lua based modes.
;; Copyright (C) 2013-2014 Matus Goljer
;; Author: Matus Goljer <matus.goljer@gmail.com>
;; Maintainer: Matus Goljer <matus.goljer@gmail.com>
;; Created: 3 August 2013
;; Keywords: abbrev convenience editing
;; 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 <http://www.gnu.org/licenses/>.
;;; Commentary:
;; This file provides some additional configuration for Lua based
;; modes. To use it, simply add:
;;
;; (require 'smartparens-lua)
;;
;; 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)
(defun sp-lua-post-keyword-insert (id action context)
"ID, ACTION, CONTEXT."
(cond
((eq action 'insert)
(cond
((member id '("while" "for"))
(insert " do")
(save-excursion (newline-and-indent))
(backward-char 3))
((equal id "if")
(insert " then")
(save-excursion (newline-and-indent))
(backward-char 5))
((equal id "function")
(save-excursion (newline-and-indent))
(insert " "))))))
;; 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-local-pair "if" "end"
:when '(("SPC"))
:unless '(sp-in-comment-p)
:post-handlers '(sp-lua-post-keyword-insert))
(sp-local-pair "function" "end"
:when '(("SPC"))
:unless '(sp-in-comment-p)
:post-handlers '(sp-lua-post-keyword-insert))
(sp-local-pair "for" "end"
:when '(("SPC"))
:unless '(sp-in-comment-p)
:post-handlers '(sp-lua-post-keyword-insert))
(sp-local-pair "while" "end"
:when '(("SPC"))
:unless '(sp-in-comment-p)
:post-handlers '(sp-lua-post-keyword-insert))
)
(provide 'smartparens-lua)
;;; smartparens-lua.el ends here

View File

@@ -0,0 +1,86 @@
;;; smartparens-markdown.el --- Additional configuration for Markdown based modes.
;; Copyright (C) 2017 Matus Goljer
;; Author: Matus Goljer <matus.goljer@gmail.com>
;; Maintainer: Matus Goljer <matus.goljer@gmail.com>
;; Created: 11th May 2017
;; Keywords: abbrev convenience editing
;; 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 <http://www.gnu.org/licenses/>.
;;; Commentary:
;; This file provides some additional configuration for Markdown based
;; modes. To use it, simply add:
;;
;; (require 'smartparens-markdown)
;;
;; 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)
(require 'markdown-mode)
(defun sp-gfm-electric-backquote-p (_id action _context)
"Do not insert ```...``` pair if that would be handled by `markdown-electric-backquote'."
(and (eq action 'insert)
markdown-gfm-use-electric-backquote
(sp--looking-back-p "^```")))
(defun sp--gfm-point-after-word-p (id action context)
"Return t if point is after a word, nil otherwise.
This predicate is only tested on \"insert\" action."
(when (eq action 'insert)
(sp--looking-back-p (concat "\\(\\sw\\)" (regexp-quote id)))))
(defun sp--gfm-skip-asterisk (ms mb me)
"Non-nil if we should ignore this asterisk as a delimiter."
(save-excursion
(goto-char mb)
(save-match-data (looking-at "^\\* "))))
(sp-with-modes '(markdown-mode gfm-mode)
(sp-local-pair "*" "*"
:unless '(sp--gfm-point-after-word-p sp-point-at-bol-p)
:post-handlers '(("[d1]" "SPC"))
:skip-match 'sp--gfm-skip-asterisk)
(sp-local-pair "**" "**")
(sp-local-pair "_" "_" :unless '(sp-point-after-word-p)))
(sp-with-modes 'markdown-mode
(sp-local-pair "```" "```"))
(sp-with-modes 'gfm-mode
(sp-local-pair "`" "`" :unless '(:add sp-gfm-electric-backquote-p))
(sp-local-pair "```" "```" :unless '(:add sp-gfm-electric-backquote-p)))
(provide 'smartparens-markdown)
;;; smartparens-markdown.el ends here

View File

@@ -0,0 +1,57 @@
;;; smartparens-ml.el --- Additional configuration for ML languages
;; Copyright (C) 2016-2017 Ta Quang Trung
;; Copyright (C) 2017 Matus Goljer
;; Author: Ta Quang Trung <taquangtrungvn@gmail.com>
;; Matus Goljer <matus.goljer@gmail.com>
;; Maintainer: Matus Goljer <matus.goljer@gmail.com>
;; Created: 14 July 2016
;; Keywords: smartparens, ML, ocaml, reason
;; 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 <http://www.gnu.org/licenses/>.
;;; Commentary:
;; This file provides some additional configuration for ML languages.
;; To use it, simply add:
;;
;; (require 'smartparens-ml)
;;
;; 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)
;;; Local pairs for ML-family languages
(sp-with-modes '(tuareg-mode fsharp-mode) (sp-local-pair "(*" "*)" ))
(sp-with-modes '(reason-mode) (sp-local-pair "/*" "*/" ))
(provide 'smartparens-ml)
;;; smartparens-ml.el ends here

View File

@@ -0,0 +1,65 @@
;;; smartparens-org.el --- Configuration for Org mode.
;; Copyright (C) 2017 Matúš Goljer
;; Author: Matúš Goljer <matus.goljer@gmail.com>
;; Maintainer: Matúš Goljer <matus.goljer@gmail.com>
;; Version: 0.0.1
;; Created: 15th January 2017
;; Keywords: languages
;; This program 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.
;; This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; This file provides some additional configuration for Org based
;; modes. To use it, simply add:
;;
;; (require 'smartparens-org)
;;
;; 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)
(defun sp--org-skip-asterisk (ms mb me)
"Non-nil if the asterisk is part of the outline marker."
(save-excursion
(goto-char mb)
(beginning-of-line)
(let ((skip-distance (skip-chars-forward "*")))
(if (= skip-distance 1)
(not (memq (syntax-class (syntax-after (point))) '(2 3)))
(<= me (point))))))
(sp-with-modes 'org-mode
(sp-local-pair "*" "*"
:unless '(sp-point-after-word-p sp-point-at-bol-p)
:skip-match 'sp--org-skip-asterisk)
(sp-local-pair "_" "_" :unless '(sp-point-after-word-p))
(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 "=" "=" :unless '(sp-point-after-word-p) :post-handlers '(("[d1]" "SPC")))
(sp-local-pair "«" "»"))
(provide 'smartparens-org)
;;; smartparens-org.el ends here

View File

@@ -0,0 +1,6 @@
(define-package "smartparens" "20171201.242" "Automatic insertion, wrapping and paredit-like navigation with user defined pairs."
'((dash "2.13.0")
(cl-lib "0.3")))
;; Local Variables:
;; no-byte-compile: t
;; End:

View File

@@ -0,0 +1,92 @@
;;; smartparens-python.el --- Additional configuration for Python based modes.
;; Copyright (C) 2015-2016 Matus Goljer
;; Author: Matus Goljer <matus.goljer@gmail.com>
;; Maintainer: Matus Goljer <matus.goljer@gmail.com>
;; Created: 8 February 2015
;; Keywords: abbrev convenience editing
;; 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 <http://www.gnu.org/licenses/>.
;;; Commentary:
;; This file provides some additional configuration for Python based
;; modes. To use it, simply add:
;;
;; (require 'smartparens-python)
;;
;; 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)
;; 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)
(add-to-list 'sp-sexp-suffix (list it 'regexp "")))
(sp-with-modes 'python-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 "'''" "'''")
(sp-local-pair "\\'" "\\'")
(sp-local-pair "\"\"\"" "\"\"\""))
(defun sp-python-fix-tripple-quotes (id action _context)
"Properly rewrap tripple quote pairs.
When the user rewraps a tripple quote pair to the other pair
type (i.e. ''' to \") we check if the old pair was a
tripple-quote pair and if so add two pairs to beg/end of the
newly formed pair (which was a single-quote \"...\" pair)."
(when (eq action 'rewrap-sexp)
(let ((old (plist-get sp-handler-context :parent)))
(when (or (and (equal old "'''") (equal id "\""))
(and (equal old "\"\"\"") (equal id "'")))
(save-excursion
(sp-get sp-last-wrapped-region
(goto-char :end-in)
(insert (make-string 2 (aref id 0)))
(goto-char :beg)
(insert (make-string 2 (aref id 0)))))))))
(defadvice python-indent-dedent-line-backspace
(around sp-backward-delete-char-advice activate)
"Fix indend."
(if smartparens-strict-mode
(cl-letf (((symbol-function 'delete-backward-char)
(lambda (arg &optional killp)
(sp-backward-delete-char arg))))
ad-do-it)
ad-do-it))
(provide 'smartparens-python)
;;; smartparens-python.el ends here

View File

@@ -0,0 +1,55 @@
;;; smartparens-racket.el --- Additional configuration for Racket based modes.
;; Copyright (C) 2015 Vikraman Choudhury
;; Author: Vikraman Choudhury <git@vikraman.org>
;; Maintainer: Vikraman Choudhury <git@vikraman.org>
;; Created: 26 Oct 2015
;; Keywords: abbrev convenience editing
;; 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 <http://www.gnu.org/licenses/>.
;;; Commentary:
;; This file provides some additional configuration for Racket based
;; modes. To use it, simply add:
;;
;; (require 'smartparens-racket)
;;
;; 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 '(racket-mode racket-repl-mode)
(sp-local-pair "`" nil :actions nil)
(sp-local-pair "#|" "|#"))
(provide 'smartparens-racket)
;;; smartparens-racket.el ends here

View File

@@ -0,0 +1,407 @@
;;; smartparens-ruby.el --- Additional configuration for Ruby based modes.
;; Copyright (C) 2013-2014 Jean-Louis Giordano
;; Author: Jean-Louis Giordano <jean-louis@jawaninja.com>
;; Maintainer: Matus Goljer <matus.goljer@gmail.com>
;; Created: 16 June 2013
;; Keywords: abbrev convenience editing
;; 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 <http://www.gnu.org/licenses/>.
;;; Commentary:
;; This file provides some additional configuration for Ruby based
;; modes. To use it, simply add:
;;
;; (require 'smartparens-ruby)
;;
;; 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)
(defun sp-ruby-forward-sexp ()
"Wrapper for `ruby-forward-sexp' based on `enh-ruby-mode'."
(interactive)
(if (boundp '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)
(enh-ruby-backward-sexp)
(ruby-backward-sexp)))
(defun sp-ruby-maybe-one-space ()
"Turn whitespace around point to just one space."
(while (looking-back " ") (backward-char))
(when (or (looking-at-p " ")
(looking-at-p "}")
(looking-back "{")
(and (looking-at-p "\\sw")
(looking-back ":")))
(save-excursion (just-one-space)))
(when (and (not (looking-back "^.?"))
(save-excursion
(backward-char 2)
(or (looking-at-p ".[^:] [.([,;]")
(looking-at-p ".. ::")
(looking-at-p ".[.@$] ")
(looking-at-p ":: "))))
(delete-char 1)))
(defun sp-ruby-delete-indentation (&optional arg)
"Better way of joining ruby lines.
ARG is how many indentation to delete."
(delete-indentation arg)
(sp-ruby-maybe-one-space))
(defun sp-ruby-block-post-handler (id action context)
"Handler for ruby block-like insertions.
ID, ACTION, CONTEXT."
(when (equal action 'insert)
(save-excursion
(newline)
(indent-according-to-mode))
(indent-according-to-mode))
(sp-ruby-post-handler id action context))
(defun sp-ruby-def-post-handler (id action context)
"Handler for ruby def-like insertions.
ID, ACTION, CONTEXT."
(when (equal action 'insert)
(save-excursion
(insert "x")
(newline)
(indent-according-to-mode))
(delete-char 1))
(sp-ruby-post-handler id action context))
(defun sp-ruby-post-handler (id action context)
"Ruby post handler.
ID, ACTION, CONTEXT."
(-let (((&plist :arg arg :enc enc) sp-handler-context))
(when (equal action 'barf-backward)
(sp-ruby-delete-indentation 1)
(indent-according-to-mode)
(save-excursion
(sp-backward-sexp) ; move to begining of current sexp
(sp-backward-sexp arg)
(sp-ruby-maybe-one-space)))
(when (equal action 'barf-forward)
(sp-get enc
(let ((beg-line (line-number-at-pos :beg-in))
(end-line (line-number-at-pos :end-in)))
(sp-forward-sexp arg)
(sp-ruby-maybe-one-space)
(when (not (= (line-number-at-pos) beg-line))
(sp-ruby-delete-indentation -1))
(indent-according-to-mode))))))
(defun sp-ruby-pre-handler (id action context)
"Handler for ruby slurp and barf.
ID, ACTION, CONTEXT."
(let ((enc (plist-get sp-handler-context :enc)))
(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)
(save-excursion
(sp-forward-sexp)
(when (looking-at-p ";") (forward-char))
(sp-ruby-maybe-one-space)
(when (not (= (line-number-at-pos) end-line))
(sp-ruby-delete-indentation -1)))
(when (looking-at-p "::")
(while (and (looking-back "\\sw")
(--when-let (sp-get-symbol t)
(sp-get it (goto-char :beg-prf))))))
(while (thing-at-point-looking-at "\\.[[:blank:]\n]*")
(sp-backward-sexp))
(when (looking-back "[@$:&?!]")
(backward-char)
(when (looking-back "[@&:]")
(backward-char)))
(just-one-space)
(save-excursion
(if (= (line-number-at-pos) end-line)
(insert " ")
(newline))))
(when (equal action 'barf-backward)
;; Barf whole method chains
(while (thing-at-point-looking-at "[(.:[][\n[:blank:]]*")
(sp-forward-sexp))
(if (looking-at-p " *$")
(newline)
(save-excursion (newline))))
(when (equal action 'slurp-forward)
(save-excursion
(sp-backward-sexp)
(when (looking-back "\.") (backward-char))
(sp-ruby-maybe-one-space)
(when (not (= (line-number-at-pos) beg-line))
(if (thing-at-point-looking-at "\\.[[:blank:]\n]*")
(progn
(forward-symbol -1)
(sp-ruby-delete-indentation -1))
(sp-ruby-delete-indentation))))
(while (looking-at-p "::") (sp-forward-symbol))
(when (looking-at-p "[?!;]") (forward-char))
(if (= (line-number-at-pos) beg-line)
(insert " ")
(newline)))
(when (equal action 'barf-forward)
(when (looking-back "\\.") (backward-char))
(when (looking-at-p "::")
(while (and (looking-back "\\sw")
(--when-let (sp-get-symbol t)
(sp-get it (goto-char :beg-prf))))))
(if (= (line-number-at-pos) end-line)
(insert " ")
(if (looking-back "^[[:blank:]]*")
(save-excursion (newline))
(newline))))))))
(defun sp-ruby-inline-p (id)
"Test if ID is inline."
(save-excursion
(when (looking-back id)
(backward-word))
(when (not (or (looking-back "^[[:blank:]]*")
(looking-back "= *")))
(or (save-excursion
(forward-symbol -1)
(forward-symbol 1)
(looking-at-p (concat " *" id)))
(save-excursion
;; This does not seem to make emacs snapshot happy
(ignore-errors
(sp-ruby-backward-sexp)
(sp-ruby-forward-sexp)
(looking-at-p (concat "[^[:blank:]]* *" id))))))))
(defun sp-ruby-method-p (id)
"Test if ID is a method."
(save-excursion
(when (looking-back id)
(backward-word))
(and (looking-at-p id)
(or
;; fix for def_foo
(looking-at-p (concat id "[_?!:]"))
;; fix for foo_def
(looking-back "[_:@$.]")
;; fix for def for; end
(looking-back "def \\|class \\|module ")
;; Check if multiline method call
;; But beware of comments!
(and (looking-back "\\.[[:blank:]\n]*")
(not (save-excursion
(search-backward ".")
(sp-point-in-comment))))))))
(defun sp-ruby-skip-inline-match-p (ms mb me)
"If non-nil, skip inline match.
MS, MB, ME."
(or (sp-ruby-method-p ms)
(sp-ruby-inline-p ms)))
(defun sp-ruby-skip-method-p (ms mb me)
"If non-nil, skip method.
MS, MB, ME."
(sp-ruby-method-p ms))
(defun sp-ruby-in-string-or-word-p (id action context)
"Test if point is inside string or word.
ID, ACTION, CONTEXT."
(or (sp-in-string-p id action context)
(and (looking-back id)
(not (looking-back (sp--strict-regexp-quote id))))
(sp-ruby-method-p id)))
(defun sp-ruby-in-string-word-or-inline-p (id action context)
"Test if point is inside string, word or inline.
ID, ACTION, CONTEXT."
(or (sp-ruby-in-string-or-word-p id action context)
(and (looking-back id)
(sp-ruby-inline-p id))))
(defun sp-ruby-pre-pipe-handler (id action context)
"Ruby pipe handler.
ID, ACTION, CONTEXT."
(when (equal action 'insert)
(save-excursion
(just-one-space))
(save-excursion
(search-backward id)
(just-one-space))))
(defun sp-ruby-should-insert-pipe-close (id action context)
"Test whether to insert the closing pipe for a lambda-binding pipe pair.
ID, ACTION, CONTEXT"
(if (eq action 'insert)
(thing-at-point-looking-at
(rx-to-string `(and (or "do" "{") (* space) ,id)))
t))
(defun sp--ruby-skip-match (ms me mb)
"Ruby skip match.
MS, ME, MB."
(when (string= ms "end")
(or (sp-in-string-p 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))
(dolist (mode '(ruby-mode motion-mode))
(add-to-list 'sp-sexp-suffix `(,mode syntax "")))
(sp-with-modes '(ruby-mode enh-ruby-mode motion-mode)
(sp-local-pair "do" "end"
:when '(("SPC" "RET" "<evil-ret>"))
:unless '(sp-ruby-in-string-or-word-p sp-in-comment-p)
:actions '(insert navigate)
:pre-handlers '(sp-ruby-pre-handler)
:post-handlers '(sp-ruby-block-post-handler)
:skip-match 'sp-ruby-skip-method-p
:suffix "")
(sp-local-pair "{" "}"
:pre-handlers '(sp-ruby-pre-handler)
:post-handlers '(sp-ruby-post-handler)
:suffix "")
(sp-local-pair "begin" "end"
:when '(("SPC" "RET" "<evil-ret>"))
:unless '(sp-ruby-in-string-or-word-p sp-in-comment-p)
:actions '(insert navigate)
:pre-handlers '(sp-ruby-pre-handler)
:post-handlers '(sp-ruby-block-post-handler)
:skip-match 'sp-ruby-skip-method-p
:suffix "")
(sp-local-pair "def" "end"
:when '(("SPC" "RET" "<evil-ret>"))
:unless '(sp-ruby-in-string-or-word-p sp-in-comment-p)
:actions '(insert navigate)
:pre-handlers '(sp-ruby-pre-handler)
:post-handlers '(sp-ruby-def-post-handler)
:skip-match 'sp-ruby-skip-method-p
:suffix "")
(sp-local-pair "class" "end"
:when '(("SPC" "RET" "<evil-ret>"))
:unless '(sp-ruby-in-string-or-word-p sp-in-comment-p)
:actions '(insert navigate)
:pre-handlers '(sp-ruby-pre-handler)
:post-handlers '(sp-ruby-def-post-handler)
:skip-match 'sp-ruby-skip-method-p
:suffix "")
(sp-local-pair "module" "end"
:when '(("SPC" "RET" "<evil-ret>"))
:unless '(sp-ruby-in-string-or-word-p sp-in-comment-p)
:actions '(insert navigate)
:pre-handlers '(sp-ruby-pre-handler)
:post-handlers '(sp-ruby-def-post-handler)
:skip-match 'sp-ruby-skip-method-p
:suffix "")
(sp-local-pair "case" "end"
:when '(("SPC" "RET" "<evil-ret>"))
:unless '(sp-ruby-in-string-or-word-p sp-in-comment-p)
:actions '(insert navigate)
:pre-handlers '(sp-ruby-pre-handler)
:post-handlers '(sp-ruby-def-post-handler)
:skip-match 'sp-ruby-skip-method-p
:suffix "")
(sp-local-pair "for" "end"
:when '(("SPC" "RET" "<evil-ret>"))
:unless '(sp-ruby-in-string-or-word-p sp-in-comment-p)
:actions '(insert navigate)
:pre-handlers '(sp-ruby-pre-handler)
:post-handlers '(sp-ruby-def-post-handler)
:skip-match 'sp-ruby-skip-inline-match-p)
(sp-local-pair "if" "end"
:when '(("SPC" "RET" "<evil-ret>"))
:unless '(sp-ruby-in-string-word-or-inline-p sp-in-comment-p)
:actions '(insert navigate)
:pre-handlers '(sp-ruby-pre-handler)
:post-handlers '(sp-ruby-def-post-handler)
:skip-match 'sp-ruby-skip-inline-match-p
:suffix "")
(sp-local-pair "unless" "end"
:when '(("SPC" "RET" "<evil-ret>"))
:unless '(sp-ruby-in-string-word-or-inline-p sp-in-comment-p)
:actions '(insert navigate)
:pre-handlers '(sp-ruby-pre-handler)
:post-handlers '(sp-ruby-def-post-handler)
:skip-match 'sp-ruby-skip-inline-match-p
:suffix "")
(sp-local-pair "while" "end"
:when '(("SPC" "RET" "<evil-ret>"))
:unless '(sp-ruby-in-string-word-or-inline-p sp-in-comment-p)
:actions '(insert navigate)
:pre-handlers '(sp-ruby-pre-handler)
:post-handlers '(sp-ruby-def-post-handler)
:skip-match 'sp-ruby-skip-inline-match-p
:suffix "")
(sp-local-pair "until" "end"
:when '(("SPC" "RET" "<evil-ret>"))
:unless '(sp-ruby-in-string-word-or-inline-p sp-in-comment-p)
:actions '(insert navigate)
:pre-handlers '(sp-ruby-pre-handler)
:post-handlers '(sp-ruby-def-post-handler)
:skip-match 'sp-ruby-skip-inline-match-p
:suffix "")
(sp-local-pair "|" "|"
:when '(sp-ruby-should-insert-pipe-close)
:pre-handlers '(sp-ruby-pre-pipe-handler)
:suffix ""))
(provide 'smartparens-ruby)
;;; smartparens-ruby.el ends here

View File

@@ -0,0 +1,138 @@
;;; smartparens-rust.el --- Additional configuration for Rust based modes.
;; Copyright (C) 2015 Wilfred Hughes
;; Created: 3 November 2015
;; Keywords: abbrev convenience editing
;; 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 <http://www.gnu.org/licenses/>.
;;; Commentary:
;; This file provides some additional configuration for Rust. To use
;; it, simply add:
;;
;; (require 'smartparens-config)
;;
;; alternatively, you can explicitly load these preferences:
;;
;; (require 'smartparens-rust)
;;
;; in your configuration.
;; For more info, see github readme at
;; https://github.com/Fuco1/smartparens
;;; Code:
(require 'smartparens)
(defun sp-in-rust-lifetime-context (&rest args)
"Return t if point is in a Rust context where ' represents a lifetime.
If we return nil, ' should be used for character literals.
ARGS."
(or
(condition-case nil
;; If point is just after a &', it's probably a &'foo.
(save-excursion
(backward-char 2)
(looking-at "&"))
;; If we're at the beginning of the buffer, just carry on.
(beginning-of-buffer))
;; If point is inside < > it's probably a parameterised function.
(let ((paren-pos (nth 1 (syntax-ppss))))
(and paren-pos
(save-excursion
(goto-char paren-pos)
(looking-at "<"))))))
(defun sp-rust-skip-match-angle-bracket (ms mb me)
"Non-nil if we should ignore the bracket as valid delimiter."
(save-excursion
(goto-char me)
(let ((on-fn-return-type
(sp--looking-back-p (rx "->") nil))
(on-match-branch
(sp--looking-back-p (rx "=>") nil))
(on-comparison
(sp--looking-back-p (rx (or
(seq space "<")
(seq space ">")
(seq space "<<")
(seq space ">>")))
nil)))
(or on-comparison on-fn-return-type on-match-branch))))
(defun sp-rust-filter-angle-brackets (id action context)
"Non-nil if we should allow ID's ACTION in CONTEXT for angle brackets."
;; See the docstring for `sp-pair' for the possible values of ID,
;; ACTION and CONTEXT.
(cond
;; Inside strings, don't do anything with < or >.
((eq context 'string)
nil)
;; Don't do any smart pairing inside comments either.
((eq context 'comment)
nil)
;; Otherwise, we're in code.
((eq context 'code)
(let ((on-fn-return-type
(looking-back (rx "->") nil))
(on-match-branch
(looking-back (rx "=>") nil))
(on-comparison
(looking-back (rx (or
(seq space "<")
(seq space ">")
(seq space "<<")
(seq space ">>")))
nil)))
(cond
;; Only insert a matching > if we're not looking at a
;; comparison.
((eq action 'insert)
(and (not on-comparison) (not on-fn-return-type) (not on-match-branch)))
;; Always allow wrapping in a pair if the region is active.
((eq action 'wrap)
(not on-match-branch))
;; When pressing >, autoskip if we're not looking at a
;; comparison.
((eq action 'autoskip)
(and (not on-comparison) (not on-fn-return-type) (not on-match-branch)))
;; Allow navigation, highlighting and strictness checks if it's
;; not a comparison.
((eq action 'navigate)
(and (not on-comparison) (not on-fn-return-type) (not on-match-branch))))))))
(sp-with-modes '(rust-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))
(sp-local-pair "<" ">"
:when '(sp-rust-filter-angle-brackets)
:skip-match 'sp-rust-skip-match-angle-bracket))
;; Rust has no sexp suffices. This fixes slurping
;; (|foo).bar -> (foo.bar)
(add-to-list 'sp-sexp-suffix (list #'rust-mode 'regexp ""))
(provide 'smartparens-rust)
;;; smartparens-rust.el ends here

View File

@@ -0,0 +1,80 @@
;;; smartparens-scala.el --- Additional configuration for Scala based modes.
;; Copyright (C) 2015 Greg Nwosu
;; Author: Greg Nwosu <greg.nwosu@gmail.com>
;; Maintainer: Greg Nwosu <greg.nwosu@gmail.com>
;; Created: 8 July 2015
;; Keywords: abbrev convenience editing
;; 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 <http://www.gnu.org/licenses/>.
;;; Commentary:
;; This file provides some additional configuration for Scala based
;; modes. To use it, simply add:
;;
;; (require 'smartparens-scala)
;;
;; 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)
;; Scala has no sexp suffices. This fixes slurping
;; import scala.mutable{|} ListBuffer, Set ---the comma should not travel with the closing
;; paren
(--each '(scala-mode inferior-scala-mode)
(add-to-list 'sp-sexp-suffix (list it 'regexp "")))
(defun sp-scala-wrap-with-indented-newlines (_ action _)
"Post handler for the wrap ACTION, putting the region on indented newlines."
(when (eq action 'wrap)
(sp-get sp-last-wrapped-region
(let ((beg :beg-in)
(end :end-in))
(save-excursion
(goto-char end)
(newline-and-indent))
(save-excursion
(goto-char beg)
(newline))
(indent-region beg end)))))
(sp-local-pair 'scala-mode "(" nil
:post-handlers '(("||\n[i]" "RET")
("| " "SPC")))
(sp-local-pair 'scala-mode "{" nil
:post-handlers '(("||\n[i]" "RET")
("| " "SPC")
sp-scala-wrap-with-indented-newlines))
(provide 'smartparens-scala)
;;; smartparens-scala.el ends here

View File

@@ -0,0 +1,65 @@
;;; smartparens-latex.el --- Additional configuration for text-mode.
;; Copyright (C) 2017 Matus Goljer
;; Author: Matus Goljer <matus.goljer@gmail.com>
;; Maintainer: Matus Goljer <matus.goljer@gmail.com>
;; Created: 16 July 2017
;; Keywords: abbrev convenience editing
;; 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 <http://www.gnu.org/licenses/>.
;;; Commentary:
;; This file provides some additional configuration for `text-mode'.
;; To use it, simply add:
;;
;; (require 'smartparens-text)
;;
;; 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)
(defun sp-text-mode-emoticon-p (_id action _context)
(when (memq action '(insert navigate))
(sp--looking-back-p ":-?[()]" 3)))
(defun sp-text-mode-skip-emoticon (ms mb me)
(when (member ms '("(" ")"))
(save-excursion
(goto-char mb)
(sp--looking-back-p ":-?" 2))))
(sp-local-pair 'text-mode "(" nil
:unless '(:add sp-text-mode-emoticon-p)
:skip-match 'sp-text-mode-skip-emoticon)
(provide 'smartparens-text)
;;; smartparens-text.el ends here

File diff suppressed because it is too large Load Diff