|
|
Up |
|
|
  |
Author: travis jefferytravis jeffery Date: Jul 19, 2008 10:50
I'm trying to write and extension for using tumbr. In tumblr there are two
requirements for a post; title and body.
So I set up a tumblr post document as:
title:
body:
So get the title I use (string-match "\\title: \(.*\)\$"), which is fine
because it's on a single line. But with I'm having trouble getting the body
because it's multiple lines. So is there someway I can get any text
following the body:_space_? I was thinking also of saving the entire buffer
and then subtracting the title: TITLE and body:_space_ but I still don't
know about that.
Thanks for your help.
|
| |
|
| | 8 Comments |
|
  |
Author: XahXah Date: Jul 20, 2008 00:48
On Jul 19, 10:50 am, travis jeffery gmail.com> wrote:
> I'm trying to write and extension for using tumbr. In tumblr there are two
> requirements for a post; title and body.
>
> So I set up a tumblr post document as:
> title:
> body:
>
> So get the title I use (string-match "\\title: \(.*\)\$"), which is fine
> because it's on a single line. But with I'm having trouble getting the body
> because it's multiple lines. So is there someway I can get any text
> following the body:_space_? I was thinking also of saving the entire buffer
> and then subtracting the title: TITLE and body:_space_ but I still don't
> know about that.
>
> Thanks for your help.
to get text out of the “body:”, you can do something like this:
|
| Show full article (0.99Kb) |
|
| | no comments |
|
  |
Author: John Paul WallingtonJohn Paul Wallington Date: Jul 21, 2008 09:23
Xah gmail.com> writes:
> (setq mytext (buffer-substring-no-properties (point) (1+ (buffer-
> size))))
Just a nitpick: in general you want to use `point-max' rather than
(1+ (buffer-size)) to take into account any narrowing.
|
| |
| no comments |
|
  |
Author: Thr4wnThr4wn Date: Jul 21, 2008 14:47
On Jul 19, 1:50 pm, travis jeffery gmail.com> wrote:
> I'm trying to write and extension for using tumbr. In tumblr there are two
> requirements for a post; title and body.
>
> So I set up a tumblr post document as:
> title:
> body:
>
> So get the title I use (string-match "\\title: \(.*\)\$"), which is fine
> because it's on a single line. But with I'm having trouble getting the body
> because it's multiple lines. So is there someway I can get any text
> following the body:_space_? I was thinking also of saving the entire buffer
> and then subtracting the title: TITLE and body:_space_ but I still don't
> know about that.
>
> Thanks for your help.
> --
> View this message in context:http://www.nabble.com/Regex-Problem-tp18547090p18547090.html
> Sent from the Emacs - Help mailing...
|
| Show full article (1.63Kb) |
| no comments |
|
  |
Author: Nikolaj SchumacherNikolaj Schumacher Date: Jul 22, 2008 05:29
Thr4wn gmail.com> wrote:
> In an emacs regexp, you can directly enter a newline character as a
> possible match by hitting C-j (will appear as ^J in the regexp) and/or
> C-q C-m
You can, but you should most definitely not. It just makes the text
hard to read or edit in anything other than Emacs. Just use \n.
> Since Windows requires all lines to end with \r\n, I would allow for
> either ^J or ^M in the search).
I believe Emacs buffers will only contain \n even for Windows files.
> On Jul 19, 1:50 pm, travis jeffery gmail.com> wrote:
>> So I set up a tumblr post document as:
>> title:
>> body:
>>
>> So get the title I use (string-match "\\title: \(.*\)\$"), which is fine
What do you mean by document? A file or a buffer? If so, why do you
use string-match? You can just search around in the buffer, which
should be more efficient.
|
| Show full article (0.91Kb) |
| no comments |
|
  |
Author: Thr4wnThr4wn Date: Jul 23, 2008 12:30
On Jul 22, 8:29 am, Nikolaj Schumacher wrote:
> You can, but you should most definitely not. It just makes the text
> hard to read or edit in anything other than Emacs. Just use \n.
That's a good point, I didn't think about that.
However, whenever I try to use \n in my regex searches, emacs does not
seem to recognize that as a newline. the regexp syntax documentation
also does not seem to mention any way to refer to a newline.
Am I just missing something?
-Thr4wn
|
| |
| no comments |
|
  |
Author: Drew AdamsDrew Adams Date: Jul 23, 2008 12:57
>> You can, but you should most definitely not. It just makes the text
>> hard to read or edit in anything other than Emacs. Just use \n.
>
> That's a good point, I didn't think about that.
>
> However, whenever I try to use \n in my regex searches, emacs does not
> seem to recognize that as a newline. the regexp syntax documentation
> also does not seem to mention any way to refer to a newline.
> Am I just missing something?
Interactively (e.g. C-M-s), you must use an actual newline character (via C-q
j), not \n.
|
| |
| no comments |
|
  |
Author: Bernardo BacicBernardo Bacic Date: Jul 23, 2008 15:36
it was a dark and stormy night when Drew Adams said,
> Interactively (e.g. C-M-s), you must use an actual newline character (via C-q
> j), not \n.
C-q C-j
|
| |
| no comments |
|
  |
|
|
  |
Author: Nikolaj SchumacherNikolaj Schumacher Date: Jul 24, 2008 04:18
Thr4wn gmail.com> wrote:
> However, whenever I try to use \n in my regex searches, emacs does not
> seem to recognize that as a newline. the regexp syntax documentation
> also does not seem to mention any way to refer to a newline.
> Am I just missing something?
You're not. \n is in fact not part of the regexp syntax. It's part
of the lisp string syntax. It's the same reason you need to use only
one \ interactively, but two in lisp.
By the way, if you are designing regular expressions, it's usually
easier to use `re-builder' than interactive search.
regards,
Nikolaj Schumacher
|
| |
| no comments |
|
|