emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Capture feature suggestion: place the mark from a template
@ 2012-04-24 10:46 Colin Fraizer
  2012-04-24 14:53 ` Nick Dokos
  2012-04-24 15:02 ` Carsten Dominik
  0 siblings, 2 replies; 4+ messages in thread
From: Colin Fraizer @ 2012-04-24 10:46 UTC (permalink / raw)
  To: emacs-orgmode

I use a capture template like this:

("t" "Todo" entry (file+headline "todo.org" "Tasks") 
  "* TODO %?\n  :HIDDEN:\n  %U\n  :END:\n%!" :prepend t)

to create todo items.  I want the cursor to be at the end of the
headline so I can type that in, but then I want to be able to quickly
jump to the end so I can type any details that I want.

I use "the mark" for that purpose, so I can type "C-x C-x" to jump
right where I want.  So I modified the function
org-capture-place-entry to add the following lines:

    (goto-char beg)
    (if (re-search-forward "%!" end t)
        (progn
          (push-mark nil t nil)
          (replace-match "")))

just before the final (goto-char beg) that will put the cursor
position at "%?".

(I guess I could have put that following ``(goto-char beg)'' inside
that ``(progn ...)''.)

Would anyone else find this a useful addition to the capture template
mechanism?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Capture feature suggestion: place the mark from a template
  2012-04-24 10:46 Capture feature suggestion: place the mark from a template Colin Fraizer
@ 2012-04-24 14:53 ` Nick Dokos
  2012-04-24 15:02 ` Carsten Dominik
  1 sibling, 0 replies; 4+ messages in thread
From: Nick Dokos @ 2012-04-24 14:53 UTC (permalink / raw)
  To: Colin Fraizer; +Cc: emacs-orgmode

Colin Fraizer <orgmode@cfraizer.com> wrote:

> I use a capture template like this:
> 
> ("t" "Todo" entry (file+headline "todo.org" "Tasks") 
>   "* TODO %?\n  :HIDDEN:\n  %U\n  :END:\n%!" :prepend t)
> 
> to create todo items.  I want the cursor to be at the end of the
> headline so I can type that in, but then I want to be able to quickly
> jump to the end so I can type any details that I want.
> 
> I use "the mark" for that purpose, so I can type "C-x C-x" to jump
> right where I want.  So I modified the function
> org-capture-place-entry to add the following lines:
> 
>     (goto-char beg)
>     (if (re-search-forward "%!" end t)
>         (progn
>           (push-mark nil t nil)
>           (replace-match "")))
> 
> just before the final (goto-char beg) that will put the cursor
> position at "%?".
> 
> (I guess I could have put that following ``(goto-char beg)'' inside
> that ``(progn ...)''.)
> 
> Would anyone else find this a useful addition to the capture template
> mechanism?
> 

Maybe - but in this particular case, you could just go to the end of the 
buffer with  M-> (end-of-buffer), right?

And there might be a problem with your proposal: if I push a bunch of
marks during the capture, what happens after the capture is done? Are
they still on the stack? If so, should they be?

Nick

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Capture feature suggestion: place the mark from a template
  2012-04-24 10:46 Capture feature suggestion: place the mark from a template Colin Fraizer
  2012-04-24 14:53 ` Nick Dokos
@ 2012-04-24 15:02 ` Carsten Dominik
  2012-04-25  9:22   ` Colin Fraizer
  1 sibling, 1 reply; 4+ messages in thread
From: Carsten Dominik @ 2012-04-24 15:02 UTC (permalink / raw)
  To: Colin Fraizer; +Cc: emacs-orgmode


On Apr 24, 2012, at 12:46 PM, Colin Fraizer wrote:

> I use a capture template like this:
> 
> ("t" "Todo" entry (file+headline "todo.org" "Tasks") 
>  "* TODO %?\n  :HIDDEN:\n  %U\n  :END:\n%!" :prepend t)
> 
> to create todo items.  I want the cursor to be at the end of the
> headline so I can type that in, but then I want to be able to quickly
> jump to the end so I can type any details that I want.
> 
> I use "the mark" for that purpose, so I can type "C-x C-x" to jump
> right where I want.  So I modified the function
> org-capture-place-entry to add the following lines:
> 
>    (goto-char beg)
>    (if (re-search-forward "%!" end t)
>        (progn
>          (push-mark nil t nil)
>          (replace-match "")))
> 
> just before the final (goto-char beg) that will put the cursor
> position at "%?".
> 
> (I guess I could have put that following ``(goto-char beg)'' inside
> that ``(progn ...)''.)
> 
> Would anyone else find this a useful addition to the capture template
> mechanism?


You could also use a prompt for the headline.  Or we could allow several %?
in the buffer, with a simple key to jump to the next one and delete it.....

- Carsten

> 
> 
> 

- Carsten

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Capture feature suggestion: place the mark from a template
  2012-04-24 15:02 ` Carsten Dominik
@ 2012-04-25  9:22   ` Colin Fraizer
  0 siblings, 0 replies; 4+ messages in thread
From: Colin Fraizer @ 2012-04-25  9:22 UTC (permalink / raw)
  To: 'Carsten Dominik'; +Cc: emacs-orgmode

Nick Dokos wrote:
>Maybe - but in this particular case, you could just go to the end of the 
>buffer with  M-> (end-of-buffer), right?

Yeah.  I could just do that.   (Blushing with embarrassment. :-)

>And there might be a problem with your proposal: if I push a bunch of
>marks during the capture, what happens after the capture is done? Are
>they still on the stack? If so, should they be?

I guess I was mostly thinking of capture using indirect buffers, which
have their own marks and mark rings, right?  Does ":unnarrowed" use the
actual buffer instead of an indirect one?

If so, I can see a couple options (and we've already established that there
are lots of options I don't see):
- If you don't like capture to set the mark, don't set it. :-)
- Arrange for clean-up in the case of org-capture-kill and (maybe?)
org-capture-finalize.

Carsten Dominik wrote:
>You could also use a prompt for the headline.  Or we could allow several %?
>in the buffer, with a simple key to jump to the next one and delete it.....

Yeah, I could do that too.  I don't know why I didn't consider that.  I
guess
because I'm so used to the "pop-up" nature of the capture window.

I'm not sure I would like/use the "multiple %?" approach.

Another reason I can imagine for wanting to place the mark with capture
is to define the region.  (Being old, I'm somewhat ambivalent about this
new-fangled "light-up" "active" region. :-)  I can imagine wanting to
place the mark and point (with %?), typing some stuff, and then wanting to
M-w (kill-ring-save) that text.

--Colin 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-04-25  9:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-24 10:46 Capture feature suggestion: place the mark from a template Colin Fraizer
2012-04-24 14:53 ` Nick Dokos
2012-04-24 15:02 ` Carsten Dominik
2012-04-25  9:22   ` Colin Fraizer

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