[OS X Emacs] Re: delete parantheses pair

Jack Repenning jrepenning at collab.net
Thu Feb 10 17:57:41 EST 2011

On Feb 10, 2011, at 8:42 AM, Marinos K wrote:

> (defun sc-delete-delimiters-and-msg ()

Two more minor notes:

Your call to (interactive) should be (interactive "*"), to verify in advance that you're allowed to modify this buffer.

The use of (let ...) to note the location of the open-paren is unnecessary; that's what (save-excursion is for. Just drop out the bottom of the save-excursion, and you're back at that open-paren.

(defun sc-delete-delimiters-and-msg ()
  "Deletes a pair of delimiters and the msg-expression attached in the
end (if one) leaving what' s inside intact. eg: [1,2,3].choose;->1,2,3"
  (interactive "*")
  (cond ((looking-at "\\s(")
	   (delete-char -1)
	   (if (char-equal (char-after) ?.)
	       (progn (kill-word 1)
		      (if (or (char-equal (char-after) ?\() (char-equal (char-after) ?\{))
	 (delete-char 1))
	 (error "Not looking at open parenthesis")

More information about the MacOSX-Emacs mailing list