Skip to content
This repository has been archived by the owner on Mar 20, 2023. It is now read-only.

electric-tads-brace misbehaves #6

Open
alexispurslane opened this issue Mar 17, 2023 · 5 comments
Open

electric-tads-brace misbehaves #6

alexispurslane opened this issue Mar 17, 2023 · 5 comments

Comments

@alexispurslane
Copy link

alexispurslane commented Mar 17, 2023

When entering an open curly brace, it puts the cursor outside of the braces instead of inside when auto-newline is enabled.

@BrettWitty
Copy link
Owner

I'm not seeing this behaviour. Do you have smartparens enabled? I see that buggy behaviour then. Might be a conflict with that and electric-tads-brace.

@alexispurslane
Copy link
Author

Ohhhh, I'll check on that. I'd removed that behavior entirely to make it more usable in the meantime but I can put it back.

@alexispurslane
Copy link
Author

Yup, it was a conflict with smartparens. I'm going to see if I can figure out how to modify the function so that it is compatible with smartparens being on.

@alexispurslane
Copy link
Author

Alright, I managed to get a (possibly simpleminded) prototype implementation of electric braces going that works with and without smartparens enabled. Here it is:

(defun electric-tads3-brace (arg)
    "Insert character and correct line's indentation."
    (interactive "P")
    (let (insertpos)
        (if (and tads3-auto-newline
                (not (save-excursion
                         (skip-chars-backward " \t")
                         (bolp))))
            (progn
                (tads3-indent-line)
                (newline)))
        (self-insert-command (prefix-numeric-value arg))
        (tads3-indent-line)
        (newline)
        (save-excursion
            (newline)
            (tads3-indent-line))
        (tads3-indent-line)))

@alexispurslane
Copy link
Author

I kept insertpos around bc if I need to expand this later to add some of the logic back, it might be needed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants