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

smartparens still does not work with delete-selection-mode #926

Open DrWaleedAYousef opened 5 years ago

DrWaleedAYousef commented 5 years ago

Expected behavior

wrapping even if I do (delete-selection-mode 1) in the .emacs file

Actual behavior

the selection is deleted

Steps to reproduce the problem

just select any word and do, e.g., $ or \

Backtraces if necessary (M-x toggle-debug-on-error)

Environment & version information

In recent enough smartparens you can call M-x sp-describe-system to generate this report. Please fill manually what we could not detect automatically. Edit the output as you see fit to protect your privacy.

Fuco1 commented 5 years ago

I can not reproduce this. I'm on emacs -nw -q 26.1 with loading just dash and smartparens and smartparens-latex, enabling smartparens and delete-selection-mode. Both wrapping and delete selection works.

Can you try to reproduce this with a minimal setup?

Fuco1 commented 5 years ago

If you have cask you can clone this repo, then cask install and cask emacs -nw -q then load the necessary packages.

DrWaleedAYousef commented 5 years ago

Thanks so much; I, as well, have 26.1. Please find the minimal setup for reproducing the problem. Just highlight any word in a .tex file and press $ it will be deleted not wrapped. Another issue related to the tag wrapping; it does not work even when commenting the delete-selection-mode.

(package-initialize)

(delete-selection-mode 1)

(require 'smartparens-config)
(require 'smartparens-latex)
(add-hook 'js-mode-hook #'smartparens-mode)

(smartparens-global-mode t)
(show-smartparens-global-mode t)
(setq sp-base-key-bindings (quote sp))

;; Also, the following line does not wrap a selection even when commenting the delete-selection-mode
(sp-local-tag '(tex-mode plain-tex-mode latex-mode LaTeX) "\\b" "\\begin{_}" "\\end{_}")

(define-key smartparens-mode-map (kbd "<delete>") 'sp-delete-char)
(define-key smartparens-mode-map (kbd "M-<delete>") 'sp-kill-word)
(define-key smartparens-mode-map (kbd "C-<delete>") 'sp-unwrap-sexp)
(define-key smartparens-mode-map (kbd "C-M-<delete>") 'sp-kill-sexp)
(define-key smartparens-mode-map (kbd "C-k") 'sp-kill-hybrid-sexp)
(define-key smartparens-mode-map (kbd "C-S-<delete>") 'sp-splice-sexp-killing-forward)
(define-key smartparens-mode-map (kbd "<backspace>") 'sp-backward-delete-char)
(define-key smartparens-mode-map (kbd "M-<backspace>") 'sp-backward-kill-word)
(define-key smartparens-mode-map (kbd "C-<backspace>") 'sp-backward-unwrap-sexp)
(define-key smartparens-mode-map (kbd "C-M-<backspace>") 'sp-backward-kill-sexp)
(define-key smartparens-mode-map (kbd "C-S-<backspace>") 'sp-splice-sexp-killing-backward)
(bind-key "M-s r" 'sp-rewrap-sexp smartparens-mode-map)
(bind-key "M-s s" 'sp-split-sexp smartparens-mode-map)
(bind-key "M-s j" 'sp-join-sexp smartparens-mode-map)
(define-key smartparens-mode-map (kbd "C-<right>") 'sp-forward-slurp-sexp)
(define-key smartparens-mode-map (kbd "C-<left>") 'sp-forward-barf-sexp)
(define-key smartparens-mode-map (kbd "C-M-<left>") 'sp-backward-slurp-sexp)
(define-key smartparens-mode-map (kbd "C-M-<right>") 'sp-backward-barf-sexp)
(define-key smartparens-mode-map (kbd "C-M-f") 'sp-forward-sexp)
(define-key smartparens-mode-map (kbd "C-M-b") 'sp-backward-sexp)
(define-key smartparens-mode-map (kbd "C-M-e") 'sp-up-sexp)
(define-key smartparens-mode-map (kbd "C-M-a") 'sp-backward-up-sexp)

(use-package auctex
  :defer t
  :ensure t)
Fuco1 commented 5 years ago

Tags no longer work. I did not load auctex so I think that's where the problem is.

DrWaleedAYousef commented 5 years ago

You are right; I commented the auctex load and kept all of my .emacs configuration, and the problem gone. So, what do you suggest now? Are you planing to fix this in smartparens?

Fuco1 commented 5 years ago

Yes I think we need to fix it, auctex is pretty much the only sane way to author latex in emacs.

Fuco1 commented 5 years ago

By the way thanks for narrowing this down, good job! Makes it a lot easier to find a fix.

DrWaleedAYousef commented 5 years ago

Thanks so much for your support.

On Thu, Sep 6, 2018, 11:56 AM Matus Goljer notifications@github.com wrote:

By the way thanks for narrowing this down, good job! Makes it a lot easier to find a fix.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Fuco1/smartparens/issues/926#issuecomment-419036213, or mute the thread https://github.com/notifications/unsubscribe-auth/ALpbzXfs6e2mjf4HvpGJNbWIx_4dkiBFks5uYPFGgaJpZM4WZ_oe .

Fuco1 commented 5 years ago

There was a super nasty bug with some caching I've fixed this morning. Can you try the latest master to see if the issue persists?

DrWaleedAYousef commented 5 years ago

Thanks so much for your efforts, unfortunately, the problem is the same!

Fuco1 commented 5 years ago

@DrWaleedAYousef Thanks for confirming. I'm sure we'll figure it out eventually /shrug

temyurchenko commented 4 months ago

I confirm that the issue is still present.