hi joe,
thanks a bunch for the lisp function. i really appreciate the reply.
had to make just a few corrections to get it to work though... please
see inline below...
Joe Knapka wrote:
> Joe Knapka wrote:
>
> > ········@gmail.com 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.
>
> [snip]
>
> This one actually works (modulo typos; I tested it on a different
> machine):
>
> (defun b-same-indent (&optional where)
> (interactive)
> (when (null where) (setq where (point)))
> (goto-char where)
> (beginning-of-line)
> (when (looking-at "\\([ \t]\\)[^ \t]")
i needed to add + after that first closing-square-bracket above. the
regexp that worked for me is:
"\\([ \t]+\\)[^ \t]"
isn't a + needed to select all the spaces at the beginning of the line?
> (let ((indent) ; Get the indent from the front of the line.
> (buffer-substring (match-beginning 1) (match-end 1)))
i had to change the 'indent' variable assignment line as:
(let ((indent ; Get the indent from the front of the line.
(buffer-substring (match-beginning 1) (match-end 1))))
not sure how it worked for you without the above changes...
i am running GNU Emacs 21.2.95.2.
thanks,
-badari
> (end-of-line)
> (search-forward-regexp (concat "^" indent "[^ \t]")))))
>
> Emacs 21 defines character class [:blank:], but I can't
> figure out how to use it in regexps; hence the [ \t].
> Doing (search-forward-regexp "[:blank:]") finds occurrences
> of ':', 'b', etc. WTF?
>
> -- JK
········@gmail.com wrote:
> hi joe,
>
> thanks a bunch for the lisp function. i really appreciate the reply.
You're quite welcome.
> not sure how it worked for you without the above changes...
Well, I typed it in by hand while looking at the
monitor of a different machine, so that probably
explains everything :-)
-- JK