emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nick Dokos <nicholas.dokos@hp.com>
To: Matthew Sauer <improv.philosophy@gmail.com>
Cc: nicholas.dokos@hp.com, Org Mode Mailing List <emacs-orgmode@gnu.org>
Subject: Re: [Use Question] Capture and long lines
Date: Mon, 27 Jun 2011 02:39:53 -0400	[thread overview]
Message-ID: <6153.1309156793@alphaville.dokosmarshall.org> (raw)
In-Reply-To: Message from Matthew Sauer <improv.philosophy@gmail.com> of "Sun\, 26 Jun 2011 22\:17\:35 CDT." <BANLkTiktxh6sarv9cRV3MEWDF8+fb55FBw@mail.gmail.com>

Matthew Sauer <improv.philosophy@gmail.com> wrote:

> I can refile into the longlines format buffer and it looks fine until
> I close and reopen the buffer, then it is all drawn out into one long
> line, the headline instead of broken up.   One other behavior I have
> noticed is that when I change state it generates the logbook and
> changes the state but then changes it from
> :LOGBOOK:
> - state changed from etc
> :END:
> to all being in one long line like
> :LOGBOOK - state changed from etc :END: . . .
> 
> I have attatched a sample buffer with some sample TODO's refiled in
> from capture and the capture templates out of my .emacs in it as well.
> 

I don't know much about longlines, so the following is pretty much a
flying guess: I have not tested it, I have not even tried to implement
it. Forewarned is forearmed.

longlines implements "hard" newlines by giving them a 'hard
text-property.  So after the template is inserted into the capture
buffer, you need to turn the newlines into hard newlines by doing
something like what longlines-decode-region does: go through the buffer
and add the text-property to each newline. longlines-decode-region does
that with the following code:

--8<---------------cut here---------------start------------->8---
  (save-excursion
    (let ((reg-max (max beg end)))
      (goto-char (min beg end))
      (while (search-forward "\n" reg-max t)
	(set-hard-newline-properties
	 (match-beginning 0) (match-end 0)))))
--8<---------------cut here---------------end--------------->8---

So you write a function that does that and hook it into the capture process
at the appropriate point: after the template is inserted into the
capture buffer but before you have entered any data. I think
org-capture-mode-hook will do that, but again I don't know for sure[fn:1]. And
of course you need to do that conditionally, otherwise every capture
will go through this process, which you probably don't want.

Again, I emphasize the tentative nature of these suggestions. I hope they
are useful, but they may be completely off the mark.

Nick


> 
> 
> 
> On Wed, Jun 22, 2011 at 1:09 PM, Nick Dokos <nicholas.dokos@hp.com> wrote:
> > Matthew Sauer <improv.philosophy@gmail.com> wrote:
> >
> >> I have one structured org file I use for school that I leave in long
> >> lines.  The capture template I have setup has \n at the end of what I
> >> would want to be a line but is still stringing them together in one
> >> long line until i reach my wrap point.  My headline has my deadline in
> >> it and org recognizes the deadline but that isn't working to get a new
> >> line inserted (an actual hard return).  Org is recongnizing it as a
> >> new line but it just runs in one long line.  Am I missing something
> >> obvious or ????    If it isn't something obvious I will make up a
> >> sample target file, example of a capture and send them out to the
> >> group
> >>
> >> * WORKING Read Chapter 9  :ENGL102: \n
> >> DEADLINE:<2011-06-28 Tue 18:30>\n  ADDEND:<2011-06-28 Tue
> >>  00:00>\n :
> >>
> >> Also the logbook just keeps adding in as one long line
> >> :LOGBOOK: -State "STARTED  from "TODO" [2011-06-22 Wed 09:56] :END:
> >>
> >>
> >
> > Looks as if you are escaping the newlines - are you using \\n in your
> > templates? If so, try losing one of the backslashes - or put explicit
> > newlines in the string which should amount to the same thing:
> >
> > (setq org-capture-templates
> > '(                   ("t" "" entry (file+headline "~/lib/org/todo.org" "Tasks") "* TODO %?
> >  %U %a" :prepend t)
> >                     ...
> > ))
> >
> > Nick
> >

Footnotes:

[fn:1] Some experiments suggest that the hook is actually run twice:
that may (or may not) complicate things - I don't know.

      reply	other threads:[~2011-06-27  6:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-22 17:16 [Use Question] Capture and long lines Matthew Sauer
2011-06-22 18:09 ` Nick Dokos
2011-06-27  3:17   ` Matthew Sauer
2011-06-27  6:39     ` Nick Dokos [this message]

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.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6153.1309156793@alphaville.dokosmarshall.org \
    --to=nicholas.dokos@hp.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=improv.philosophy@gmail.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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

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).