all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* lisp function to search-forward for lines with same indent
@ 2006-08-28  8:16 Badari Kakumani
  2006-08-28 20:42 ` Malte Spiess
  2006-08-29 19:42 ` Kevin Rodgers
  0 siblings, 2 replies; 4+ messages in thread
From: Badari Kakumani @ 2006-08-28  8:16 UTC (permalink / raw)


folks,

i have a large call-tree hierarchy represented as indented lines shown
below:

  File::Spec::Functions::__ANON__ x 1  	0.00s = (0.00 + 0.00)s
    File::Spec::Unix::catfile x 1  	0.00s = (0.00 + 0.00)s
      File::Spec::Unix::canonpath x 1  	0.00s
      File::Spec::Unix::catdir x 1  	0.00s = (0.00 + 0.00)s
        File::Spec::Unix::canonpath x 1  	0.00s
  at::obj::BEGIN x 14  	19.07s = (0.12 + 18.95)s

if my cursor is positioned at the first line shown in the above output,
i want to develop a function such that it finds the last-line
in the output shown -- a line with exactly two-spaces in the beginning
and then a non-space-charcter.

i want this to work for any other lines with a differing starting
indentation.

any clues on how to go about developing this lisp function or
any pointers to existing functions that do this will help.

to my surprise, in emacs, when i press:
   Esc Ctr-s ^ Space \sw
emacs is matching all lines that start with any number of spaces
(instead of matching lines with exactly one-space in the beginning
of line and a non-space character). not sure why it is behaving this
way.

thanks,
-badari

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

* RE: lisp function to search-forward for lines with same indent
@ 2006-08-28 20:18 Jay Bingham
  0 siblings, 0 replies; 4+ messages in thread
From: Jay Bingham @ 2006-08-28 20:18 UTC (permalink / raw)


On Monday, August 28, 2006 3:17 AM Badari Kakumani wrote:

> to my surprise, in emacs, when i press:
>    Esc Ctr-s ^ Space \sw
> emacs is matching all lines that start with any number of spaces
> (instead of matching lines with exactly one-space in the beginning
> of line and a non-space character). not sure why it is behaving this
> way.

The variable search-whitespace-regexp provides a regular expression 
to be used
to match a sequence of white space in incremental searches.
Its default value is "\\s-+".

If you never want sequences of white space to be changed to this 
regexp set it
to nil in your .emacs or if you use customization it can be set to 
nil via
customization.

If you don't mind sequences of whit space being changed to this 
regexp most of
the time and just want to do specific numbers of spaces on occasion 
you can use
a regexp like this:
"^ \{2\}\sw"

__
J_)
C_)ingham 


_____________________________________________________________________
PrivatePhone - FREE telephone number & voicemail.
A number so private, you can make it public.
http://www.privatephone.com

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

* Re: lisp function to search-forward for lines with same indent
  2006-08-28  8:16 lisp function to search-forward for lines with same indent Badari Kakumani
@ 2006-08-28 20:42 ` Malte Spiess
  2006-08-29 19:42 ` Kevin Rodgers
  1 sibling, 0 replies; 4+ messages in thread
From: Malte Spiess @ 2006-08-28 20:42 UTC (permalink / raw)


"Badari Kakumani" <badarisj@gmail.com> writes:

> [...]
>
> any clues on how to go about developing this lisp function or
> any pointers to existing functions that do this will help.

Sorry, can't help you here, I hoped that some guru would answer, but as
it is I'll at least answer your 2nd question:

> to my surprise, in emacs, when i press:
>    Esc Ctr-s ^ Space \sw
> emacs is matching all lines that start with any number of spaces
> (instead of matching lines with exactly one-space in the beginning
> of line and a non-space character). not sure why it is behaving this
> way.

It's because spaces matches any number of spaces (and other whitespace).
If you really want a space, you have to press C-q space.

> thanks,
> -badari

HTH

Malte

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

* Re: lisp function to search-forward for lines with same indent
  2006-08-28  8:16 lisp function to search-forward for lines with same indent Badari Kakumani
  2006-08-28 20:42 ` Malte Spiess
@ 2006-08-29 19:42 ` Kevin Rodgers
  1 sibling, 0 replies; 4+ messages in thread
From: Kevin Rodgers @ 2006-08-29 19:42 UTC (permalink / raw)


Badari Kakumani wrote:
> folks,
> 
> i have a large call-tree hierarchy represented as indented lines shown
> below:
> 
>   File::Spec::Functions::__ANON__ x 1  	0.00s = (0.00 + 0.00)s
>     File::Spec::Unix::catfile x 1  	0.00s = (0.00 + 0.00)s
>       File::Spec::Unix::canonpath x 1  	0.00s
>       File::Spec::Unix::catdir x 1  	0.00s = (0.00 + 0.00)s
>         File::Spec::Unix::canonpath x 1  	0.00s
>   at::obj::BEGIN x 14  	19.07s = (0.12 + 18.95)s
> 
> if my cursor is positioned at the first line shown in the above output,
> i want to develop a function such that it finds the last-line
> in the output shown -- a line with exactly two-spaces in the beginning
> and then a non-space-charcter.
> 
> i want this to work for any other lines with a differing starting
> indentation.
> 
> any clues on how to go about developing this lisp function or
> any pointers to existing functions that do this will help.
> 
> to my surprise, in emacs, when i press:
>    Esc Ctr-s ^ Space \sw
> emacs is matching all lines that start with any number of spaces
> (instead of matching lines with exactly one-space in the beginning
> of line and a non-space character). not sure why it is behaving this
> way.

Here's what I came up with:

(defun next-line-same-indentation ()
   "Move point to the next line with the same indentation as the current 
line."
   (interactive)
   (let ((indentation (save-excursion
		       (buffer-substring (progn
					   (beginning-of-line)
					   (point))
					 (1- (re-search-forward "\\S "))))))
     (re-search-forward (concat "^" (regexp-quote indentation) "\\S "))
     (backward-char)))

-- 
Kevin

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

end of thread, other threads:[~2006-08-29 19:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-28  8:16 lisp function to search-forward for lines with same indent Badari Kakumani
2006-08-28 20:42 ` Malte Spiess
2006-08-29 19:42 ` Kevin Rodgers
  -- strict thread matches above, loose matches on Subject: below --
2006-08-28 20:18 Jay Bingham

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.