[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Select Text Inside Parentheses

From: Esben Stien
Subject: Select Text Inside Parentheses
Date: Sat, 01 Sep 2012 14:11:27 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.3 (gnu/linux)

I'm trying to select text between parentheses. This text is not
code. This is my block of text: 


Problem is that it selects the whole first line after the first
parentheses, so I get a whole line of white space in front of the first
character. I'd like the selection to start at the first character after
the first parentheses and end at the last character before the last
parentheses. I tried adding (delete-horizontal-space).

Any pointers as to how I can do this?. 

(require 'simple)
(defun set-selection-around-parens()
  (let ( (right-paren (save-excursion ; using save-excursion because
                                      ; we don't want to move the
                                      ; point.
                        (re-search-forward ")" nil t))) ; bound nil
                                                        ; no-error t
         (left-paren (save-excursion (re-search-backward "(" nil t))))
    (when (and right-paren left-paren)
      ;; this is actually a way to activate a mark
      ;; you have to move your point to one side
      (push-mark (- right-paren 1))
      (goto-char (+ left-paren 1))

Esben Stien is b0ef@e     s      a             
         http://www. s     t    n m
          irc://irc.  b  -  i  .   e/%23contact
           sip:b0ef@   e     e 
           jid:b0ef@    n     n

reply via email to

[Prev in Thread] Current Thread [Next in Thread]