DogLooksGood / parinfer-mode

Parinfer for Emacs :)
GNU General Public License v3.0
407 stars 33 forks source link

Region gets deleted when region is deselected #51

Open arximboldi opened 7 years ago

arximboldi commented 7 years ago

This is a weird one. Steps to reproduce:

  1. Select a region (while in parinfer mode)
  2. Insert a character: the character gets inserted and the region gets de-selected, as expected.
  3. Press delete: the whole region that was last selected gets unexpectedly deleted. Since no region is visible, I expect it to only delete one character (the one inserted in step 2).

My configuration is:


(use-package parinfer
  :ensure t
  :config
  (parinfer-strategy-add 'instantly
    '(parinfer-smart-tab:dwim-right
      parinfer-smart-tab:dwim-left))
  :bind
  (:map parinfer-mode-map
        ("<tab>" . parinfer-smart-tab:dwim-right)
        ("S-<tab>" . parinfer-smart-tab:dwim-left)
        ("<backtab>" . parinfer-smart-tab:dwim-left)
        ("C-," . parinfer-toggle-mode)
        :map parinfer-region-mode-map
        ("<tab>" . parinfer-smart-tab:dwim-right)
        ("S-<tab>" . parinfer-smart-tab:dwim-left)
        ("<backtab>" . parinfer-smart-tab:dwim-left))
  :init
  (progn
    (setq parinfer-extensions
          '(defaults
             pretty-parens
             smart-tab
             smart-yank))))
DogLooksGood commented 7 years ago

issue reproduced, I'll try to make a fix.

DogLooksGood commented 7 years ago

here's a ugly fix, but seems work.

(defun parinfer-region-delete-region ()
  (interactive)
  (if (region-active-p)
      (call-interactively 'delete-region)
    (call-interactively 'parinfer-backward-delete-char))
  (deactivate-mark t)
  (parinfer-run))

the parinfer-region-mode can't disable in time when region deactivate, it seems there's no hook. I need to learn more Elisp.