emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] [Use Question] Capture and long lines


From: Nick Dokos
Subject: Re: [O] [Use Question] Capture and long lines
Date: Mon, 27 Jun 2011 02:39:53 -0400

Matthew Sauer <address@hidden> 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 <address@hidden> wrote:
> > Matthew Sauer <address@hidden> 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 via email to

[Prev in Thread] Current Thread [Next in Thread]