all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Select Text Inside Parentheses
@ 2012-09-01 12:11 Esben Stien
  2012-09-01 16:34 ` Drew Adams
  2012-09-04 10:17 ` Andreas Röhler
  0 siblings, 2 replies; 8+ messages in thread
From: Esben Stien @ 2012-09-01 12:11 UTC (permalink / raw)
  To: help-gnu-emacs


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

(
foo
bar
baz
)

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()
  (interactive)
  (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))
      (delete-horizontal-space)
      (activate-mark)
)))

-- 
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



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-09-04 10:17 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-01 12:11 Select Text Inside Parentheses Esben Stien
2012-09-01 16:34 ` Drew Adams
2012-09-02  1:06   ` Esben Stien
2012-09-02  1:01     ` Drew Adams
2012-09-02 13:17       ` Esben Stien
2012-09-02 13:29         ` Drew Adams
2012-09-02 14:40         ` Le Wang
2012-09-04 10:17 ` Andreas Röhler

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.