[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Help with keybinding to delete between {}
From: |
Mike Mattie |
Subject: |
Re: Help with keybinding to delete between {} |
Date: |
Wed, 12 Dec 2007 19:59:16 -0800 |
On Thu, 6 Dec 2007 09:14:12 -0800 (PST)
Xah Lee <xah@xahlee.org> wrote:
> for some reason my code in the previous post is completely non-
> functional. (i swear i used it for few months. Perhaps when i put on
> the website i got smart and edited it "for the better" without
> testing)
>
> Here's the correct version:
>
> (defun delete-enclosed-text ()
> "Delete texts between any pair of delimiters.
> Note: if you have nested matching pairs, the cursor
> should be inside the inner most one. Else it gets confused.
> This code should to be fixed in the future."
> (interactive)
> (save-excursion
> (let (p1 p2)
> (skip-chars-backward "^(<["<<") (setq p1 (point))
> (skip-chars-forward "^)>]">>") (setq p2 (point))
> (delete-region p1 p2)
> )
> )
> )
I don't this this can be right. on a single line it has three string quotation
characters.
(defun delete-enclosed-text ()
"Delete texts between any pair of delimiters.
Note: if you have nested matching pairs, the cursor
should be inside the inner most one. Else it gets confused.
This code should to be fixed in the future."
(interactive)
(skip-chars-forward "^)>>")
(delete-backward-char (skip-chars-backward "^(<<")))
this version doesn't change the mark so I dropped the save-excursion. It is not
quite right because
it does not handle nested sexp at all. I don't understand the elisp flavor of
regex yet, so it's
probably an easy fix.
> Xah
> xah@xahlee.org
> ∑ http://xahlee.org/
> _______________________________________________
> help-gnu-emacs mailing list
> help-gnu-emacs@gnu.org
> http://lists.gnu.org/mailman/listinfo/help-gnu-emacs
signature.asc
Description: PGP signature
- Help with keybinding to delete between {}, lampshade, 2007/12/05
- Re: Help with keybinding to delete between {}, Bernardo Bacic, 2007/12/05
- Re: Help with keybinding to delete between {}, William Xu, 2007/12/05
- Re: Help with keybinding to delete between {}, Andreas Röhler, 2007/12/05
- Re: Help with keybinding to delete between {}, Ilya Zakharevich, 2007/12/05
- Re: Help with keybinding to delete between {}, Xah Lee, 2007/12/06
- Re: Help with keybinding to delete between {}, Xah Lee, 2007/12/14
Re: Help with keybinding to delete between {}, Stefan Monnier, 2007/12/07