From: bill <please_post@nomail.edu>
Subject: Re: newbie tries to hack comint.el (help!)
Date: Tue, 8 Jun 2004 11:34:35 +0000 (UTC) [thread overview]
Message-ID: <ca488b$pbd$1@reader2.panix.com> (raw)
In-Reply-To: 877jujt2bx.fsf@tc-1-100.kawasaki.gol.ne.jp
In <877jujt2bx.fsf@tc-1-100.kawasaki.gol.ne.jp> Miles Bader <miles@gnu.org> writes:
>bill <please_post@nomail.edu> writes:
>> One thing that this function must do, but I have not been able to
>> figure out is how to to move the point to the beginning of the line
>> of the immediately preceding shell input. I've been able to handle
>> simple cases, but not tricky ones like:
>>
>> myhost:~/some/dir$ foo \
>>> bar \
>>> baz_
>>
>> where '_' immediately after 'baz' indicates the location of the
>> point at the time I want to move it to the beginning of the line
>> beginning with "myhost".
>Probably you're best bet is to write your own regexp that matches your
>own prompt, but not shell `subprompts' like ">" -- or perhaps a regexp
>that only matches prompts you want to avoid -- and then scan back
>through what comint things are prompts, until you find something that
>matches (or doesn't match).
>For instance:
> ;; Regexp matching prompts that `foo-beginning-of-previous-important-prompt'
> ;; should avoid.
> (defvar foo-avoid-prompt-regexp "^> *$")
> ;; Move to the beginning of the previous comint prompt that doesn't match
> ;; `foo-avoid-prompt-regexp'.
> (defun foo-beginning-of-previous-important-prompt ()
> (interactive)
> (while (and (comint-previous-prompt)
> (let ((prompt-end-pos (point)))
> (forward-line 0) ; move to true beginning-of-line
> (string-match foo-avoid-prompt-regexp
> (buffer-substring (point) prompt-end-pos))))))
>seems to work for your current example.
Good idea; it works like a charm. Well, almost: I had to give an
argument of 1 to comint-previous-prompt (actually, I'm surprised
your code worked at all, unless the code you posted was not a
faithful cut-and-paste of the code you tested).
Many thanks.
-bill
next parent reply other threads:[~2004-06-08 11:34 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <ca2ctl$6ta$1@reader2.panix.com>
[not found] ` <877jujt2bx.fsf@tc-1-100.kawasaki.gol.ne.jp>
2004-06-08 11:34 ` bill [this message]
2004-06-08 22:23 ` newbie tries to hack comint.el (help!) Miles Bader
2004-06-08 16:43 ` Kevin Rodgers
2004-06-08 22:24 ` Miles Bader
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='ca488b$pbd$1@reader2.panix.com' \
--to=please_post@nomail.edu \
/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).