Fuco1 / smartparens

Minor mode for Emacs that deals with parens pairs and tries to be smart about it.
GNU General Public License v3.0
1.81k stars 193 forks source link

can't insert single quote (`'`) in expression minibuffer in strict mode #1036

Open Rogach opened 4 years ago

Rogach commented 4 years ago

Expected behavior

In strict mode M-: ' should result in single quote being typed in the expression minibuffer.

Actual behavior

Quote is doubled instead. And since this is strict mode, I can't delete the extra quote. Temporary workaround: use (quote).

Steps to reproduce the problem

Config that reproduces the problem:

(require 'smartparens-config)
(add-hook 'eval-expression-minibuffer-setup-hook #'smartparens-strict-mode)

Then type M-: (eval-expression) and then type single quote character (').

Environment & version information

andreyorst commented 3 years ago
(defun aorst/minibuffer-enable-sp ()
  "Enable `smartparens-strict-mode' in the minibuffer, during `eval-expression'."
  (when (eq this-command 'eval-expression)
    (setq-local comment-start ";")
    (sp-local-pair 'minibuffer-pairs "'" nil :actions nil)
    (sp-local-pair 'minibuffer-pairs "`" nil :actions nil)
    (sp-update-local-pairs 'minibuffer-pairs)
    (smartparens-strict-mode 1)))

I hook this funtion to minibuffer-setup hook and it seems to work

Rogach commented 3 years ago

@andreyorst Thank you, that works!

I found that it is possible to get rid of "(when (eq this-command ..." by hooking eval-expression-minibuffer-setup-hook instead of minibuffer-setup-hook.

andreyorst commented 3 years ago

oh, great! Did not knew of that hook, thanks for the tip!

andreyorst commented 3 years ago

Perhaps this should be documented, and tiket can be resolved?

Rogach commented 3 years ago

Up to the project owner, I guess. I saw that he marked the issue as a bug, so maybe he plans to do something else (one could argue that smartparens-strict-mode should allow quotes in minbuffer as well as in usual .el buffers - because in both cases we have elisp as a dialect).