From: Kevin Rodgers <ihs_4664@yahoo.com>
Subject: Re: lisp function to search-forward for lines with same indent
Date: Tue, 29 Aug 2006 13:42:31 -0600 [thread overview]
Message-ID: <ed25cq$dja$1@sea.gmane.org> (raw)
In-Reply-To: <1156753011.964177.189840@b28g2000cwb.googlegroups.com>
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
next prev parent reply other threads:[~2006-08-29 19:42 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
-- strict thread matches above, loose matches on Subject: below --
2006-08-28 20:18 Jay Bingham
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='ed25cq$dja$1@sea.gmane.org' \
--to=ihs_4664@yahoo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).