6

Add the following to your emacs init file: (setq electric-pair-inhibit-predicate (lambda (c) (if (char-equal c ?\") t (electric-pair-default-inhibit c)))) Reference from my blog post: https://www.topbug.net/blog/2016/09/29/emacs-disable-certain-pairs-for-electric-pair-mode/


5

The syntax of ~ is changed by org-mode itself: as part of the definition of the mode, the file org.el contains (modify-syntax-entry ?~ "_") inside (define-derived-mode org-mode...). Since the command org-mode is not necessarily run at the time the file is loaded, you need to put your modification in to org-mode-hook instead, e.g. (add-hook 'org-mode-hook (...


3

Insert the following lisp snippet into your init-file: (add-hook 'LaTeX-mode-hook (lambda () (setq LaTeX-electric-left-right-brace t) (local-set-key "|" 'LaTeX-insert-left-brace))) Maybe, (setq LaTeX-electric-left-right-brace t) is not really necessary since you have it already customized or hooked in. Nevertheless, it does not hurt ...


3

You can also probably (setq-default electric-pair-inhibit-predicate (lambda (c) (if (looking-at "[ \n\t]") (electric-pair-default-inhibit c) t))) Seems a bit more correct in light of the actual question asked.


3

Change the way pair insertion is inhibited: (setq-default electric-pair-inhibit-predicate 'electric-pair-conservative-inhibit)


3

AUCTeX has a bultin support for pairing braces, and \{...\} is in the default set of supported braces. In order to enable this feature, just set LaTeX-electric-left-right-brace to non nil, either with customize interface (M-x customize-variable RET LaTeX-electric-left-right-brace RET) or by adding the following line to your init file: (setq LaTeX-electric-...


3

It appears you cannot. The various customizations only allow you to add pairs. If you're willing to use a different package to do your pairing, you can try smartparens. You can set quotation marks to not pair as follows: (sp-pair "'" nil :actions :rem) (sp-pair "\"" nil :actions :rem)


2

One way to deal with this is to use structural editing commands. So, instead of thinking "delete the character, add it at the end", I think something like "wrap the paren pair around the next token". One library that does this is called smartparens, and the function is #'sp-forward-slurp-sexp. Starting with this text (with the pipe marking point): wrapped(|...


2

Update: @xuhdev's answer is preferable as it doesn't interfere with Emacs' code. Might be worth a feature request having that customizable. For the moment, it looks trivial to modify the code in question. Afterwards load your own variant of electric-pair-post-self-insert-function Open elec-pair.el and copy from there (defun electric-pair-post-self-...


2

To continue this thread of alternatives... A better workflow than the one you describe is to use electric-pair-mode the way it is meant to so that it works for you instead of against you: Place the cursor inside the quotes. Select the contents inside the quotes. One of the most convenient ways of doing this is to use Magnar's change-inner.el and bind ...


2

I knew this was going to take some time, but in the end I couldn't resist the temptation to figure out how it's done properly. :) Enjoy! (defun toggle-quotes (uarg) "Toggle single and double quotes around a string. Does the change only if the point is inside quotes that are syntactically correct under the current major mode. For example, single quotes ...


2

As I explained in my comment, this is a bug. Until it is fixed, you can work around it like so (add-hook 'LaTeX-mode-hook 'fix-electric-pair-paired-delimiters-in-tex-mode) (defun fix-electric-pair-paired-delimiters-in-tex-mode () (add-function :around (local 'electric-pair-skip-self) (lambda (oldfun c) (pcase (electric-pair-...


2

Here is a trick that I learned from this answer to only use electric-pair-mode with specifically whitelisted modes: (defvar my-electic-pair-modes '(python-mode org-mode)) (defun my-inhibit-electric-pair-mode (char) (not (member major-mode my-electic-pair-modes))) (setq electric-pair-inhibit-predicate #'my-inhibit-electric-pair-mode) Then you can add ...


2

In elisp nil represents a false value. Try: (setq web-mode-enable-auto-closing nil) (setq web-mode-enable-auto-pairing nil) -1 is non-nil (see: (if -1 "true!" "false!")).


1

Looking at the source code for the minor-mode, I couldn't find any way of doing it. But if you really want to implement it for multi-char strings, you can write your own function and add it to post-self-insert-hook. This function would be called every time an self-inserting character is typed in the buffer, i.e. characters that you care about here. To see ...


1

You can disable pairing of <..> as follows: (add-function :before-until electric-pair-inhibit-predicate (lambda (c) (eq c ?<)))


1

You can delete chars from the buffer during expansion, but modifying the buffer during expansion is dicouraged. Deleting chars is pretty easy, because yasnippet allows to eval elisp code during expansion. You have to put this code into back-quotes Read more about it here. Your snippet would then look like this example (you need to refine this crude example,...


1

In addition to @jagrg suggestion (to add :trigger-wrap "$") I found everything works as expected if I don't remove the $ pair from my modes I.e., I had to comment out this line (sp-local-pair 'latex-mode "$" nil :actions :rem) This line alone does the trick (sp-local-pair 'latex-mode "\\(" "\\)" :trigger "$" :trigger-wrap "$")


1

slime-repl-mode overrides in slime-repl-mode-map the key-binding for electric-pair-delete-pair. The override is not very surprising. It is just backward-delete-char-untabify. The binding in global-map is delete-backward-char. If you do not really need the untabify part in the repl removing the override shouldn't do any harm. Just put the following Elisp ...


1

First of all, I disabled electric-pair-mode by: (setq-default c-electric-flag nil) To remove a pair of matching quotes/parens, we can: use expand-region to select the content without the quotes you wanna remove. copy the content. expand the region to include the pair of matching quotes/parens. paste the content. To add a new pair of quotes/parens, I ...


1

Try embrace. It’s easy to use and does what you want and more.


1

One option is to use Xah Lee's xah-change-bracket-pairs from http://ergoemacs.org/emacs/elisp_change_brackets.html. To get you started, here are two simple interactive functions that use it to do what you want. Bind them to your key of choice. You have to first select the quoted text, for example by placing the cursor inside the quotes and pressing your key ...


1

https://github.com/andreas-roehler/thing-at-point-utils comes with a ar-delimited2.el which provides for example a command ar-delimited2singlequoted


1

With smartparens, you can add a :post-handler, like this: (sp-pair "{" nil :post-handlers '(("| " "SPC"))) I use an additional handler for pressing return: (sp-pair "{" nil :post-handlers '(("||\n[i]" "RET") ("| " "SPC")))


1

The answer by legends2k is correct. However, if you want to fix the issue without having to modify your local emacs installation, you can also work around the issue by adding the following lines to your personal .emacs: (eval-after-load "cc-mode" (progn (require 'cc-mode) (put 'c-electric-paren 'delete-selection nil) (put 'c-electric-brace '...


1

This is a bug in CC mode which is already fixed in the master branch. Since you have an older stable build, you can replace your copies of the files emacs-24.5/lisp/delsel.el emacs-24.5/lisp/progmodes/cc-cmds.el from git and compile them within Emacs with M-x byte-compile-file or on terminal using emacs -Q -batch -f batch-byte-compile delsel.el progmodes/...


1

electric-pair-mode uses post-self-insert-hook to do the pairing. Inserting a string into the buffer with insert is not going to trigger the post-self-insert-hook because you never ran self-insert-command. Instead of using insert use execute-kbd-macro to treat the insertion as if you had pressed the key for a curly bracket. (defun my-insert-lcurly () (...


1

Personally, I don't like the default way Emacs on OS X use the modifier keys. I have the following in my init file, it places meta on Cmd and restore Alt to the normal OS X behaviour to access special keys. This way it just work with electric-pair-mode and you can drop all your special functions. (if (boundp 'ns-command-modifier) (setq ns-command-...


1

To specifically disable electric-pair-mode in the minibuffer change elethan's example to use the minibufferp function. Below is the relevant part from my Emacs configuration: ;; Enable smart paring (electric-pair-mode) (defun pvj/inhibit-electric-pair-mode (char) (minibufferp)) (setq electric-pair-inhibit-predicate #'pvj/inhibit-electric-pair-mode)


Only top voted, non community-wiki answers of a minimum length are eligible