avoid exiting yasnippet with escape while in evil mode's insert state - emacs

Is it possible to change yasnippet so it won't exit on escape during evil mode's insert state? I would like to be able to manipulate the text while still editing the snippet.
Thanks!

Related

How to disable text insertion in emacs when i particular minor mode?

How to make emacs not insert text when character keys are pressed?
For instance, I have a minor mode and when I enter it I want to disable text insertion.
(defun marko-enter-edit-mode ()
(interactive)
(set-cursor-color "#ffffff")
(marko-nav-mode -1))
To disable (or re-enable) text insertion, set buffer-read-only.
If you want to associate this action with a minor mode, you might prefer to use the mode hook rather than a separate function.
Recommended reading:
define-minor-mode
special-mode (if your mode is in fact major and read-only, you should inherit from this)

`C-[` does not escape from insert mode in evil local mode

I just started to use vim in my emacs. While most of the docs/wikis suggest turn on evil mode globally, I, being a emacs user at the first beginning, really prefer to keep evil mode local. That means, when I need model editing I will turn on the evil mode in that local buffer. I wrote a piece of elisp to toggle on/off evil mode for this purpose:
(defun toggle-evil-local-mode ()
"Toggle on and off evil mode in local buffer."
(interactive)
(if evil-local-mode
(turn-off-evil-mode)
(turn-on-evil-mode)))
(global-set-key (kbd "s-e") 'toggle-evil-local-mode)
However, there is one thing bothers me. I can not use C-[ to escape from insert or visual mode to normal mode (emacs reads the keystroke as ESC- and waiting for more input in the echo area ), Esc key works fine though. But if I turn on the evil mode globally, C-[ just work the same as Esc key.
You might notice that I am using a Mac from the keybinding. While I can use Esc key currently, but what if I upgrade to a new MBP with those evil touch bar in the future? So is there any way to fix this problem? Any suggestion will be appreciated.
Looks like a bug in Evil. Let me know if this works:
(defun turn-on-evil-mode-fixed-escape ()
"Turn on Evil in the current buffer AND `evil-esc-mode'. This makes C-[ work
like <escape> when using `evil-local-mode'."
(interactive)
(turn-on-evil-mode)
(evil-esc-mode 1))

Re-filling entire paragraph automatically with auto-fill-mode?

Motivation: Using the defaults, Auto Fill mode seems not as useful as I might
have hoped: If I insert a sentence in the middle of a paragraph, only the current
line is re-filled. When I insert a sentence, I want the entire paragraph to be re-filled.
Question: How can I set auto-fill-function (or perhaps
normal-auto-fill-function) in my .emacs
file so that the paragraph is re-filled whenever a single line overflows?
I tried setting it to fill-paragraph, but then I cannot insert any spaces at the end of a paragraph (e.g., to add another word).
More details: I primarily use Auto Fill mode in the AUCTeX major mode for LaTeX.
The built-in Emacs documentation for auto-fill-mode states:
When auto-fill-mode is on, the auto-fill-function variable is
non-nil.
The value of normal-auto-fill-function specifies the function to use
for auto-fill-function when turning Auto Fill mode on.
The documentation for the normal-auto-fill-function variable
says that it is the function to use for auto-fill-function if Auto Fill mode is
turned on, and that the initial value is do-auto-fill.
You might like to try refill-mode. But in general, it's just tricky to make such a feature work well. Another approach is to only do the refill as part of the redisplay (i.e. without affecting the buffer's actual content). For that, try setting word-wrap or enabling visual-line-mode.
For LaTeX files you can try (requires AUCTeX)
(add-hook 'LaTeX-mode-hook '(lambda ()
(setq auto-fill-function 'LaTeX-fill-paragraph)))
but use it with caution.

emacs icicles delete selection mode

When I turn on icicles mode in emacs, it kinda mess up delete-selection-mode.
After copied some text, if I try to yank it into a highlighted region, instead of replace that region, it will append at the end of the region. I say kinda because, I could still use backspace or directly type text to replace the highlighted region. Only yanking behavior is not right.
Is there some option in icicles mode to fix this yank behavior? So far I haven't found any.
Thank you
M-x icicle-send-bug-report RET
Yes, M-x icicle-send-bug-report RET
Give a complete recipe, starting from emacs -Q. It sounds like you have some other setting somewhere that is interfering. I use Icicles with delete-selection-mode all the time.

Disable auto indent globally in Emacs

How to disable auto indent in Emacs globally or only for some modes?
I have a number of packages installed for RubyOnRails (ruby, html, js, css).
Let's say I want to disable autoindent for css-mode.
For me, on emacs 24.x, M-xelectric-indent-mode toggled the behavior that I wanted to disable.
FWIW, the behavior was that RET was bound to the command newline which is defined in simple.el... Among other things, the behavior of that command is altered by electric-indent-mode.
You may want to look for variable names containing the word electric. (This is the common Emacs parlance for actions which occur automatically when particular visible characters are typed.)
In this instance, M-x apropos-variable RET electric RET shows me that there is a css-electric-keys variable containing a list of "Self inserting keys which should trigger re-indentation."
You could use M-x customize-variable RET css-electric-keys RET to set this list to nil, or add (setq css-electric-keys nil) to your init file.
Sometimes a minor mode is used to implement electric behaviours, so that you can switch them on and off more easily. Those would likely be found via M-x apropos-command RET electric RET, and you would probably use a major mode hook to ensure that the electric minor mode was disabled, in a similar fashion to this:
(add-hook 'MAJORMODE-mode-hook 'my-MAJORMODE-mode-hook)
(defun my-MAJORMODE-mode-hook ()
(ELECTRICMODE-mode 0))