* save-excursion not saving when I call org-capture-goto-last-stored
@ 2012-02-05 3:01 Jon Miller
2012-02-09 6:28 ` David Maus
0 siblings, 1 reply; 3+ messages in thread
From: Jon Miller @ 2012-02-05 3:01 UTC (permalink / raw)
To: orgmode
I'm currently trying to write a function to do some post-capture
updates to an entry. My intention is to add it to
org-capture-after-finalize-hook. First step is navigating to the
captured item but I'd like to return to the current buffer I was in
before. I'm still a novice with elisp, so I could use a pointer here.
Here is a simplified example:
M-: (save-excursion (org-capture-goto-last-stored))
Is there a better way to navigate to the last capture and then return
to my current buffer?
Thanks,
Jon Miller
;; My current full version:
(defun jsm/org-project-properties ()
"Takes the current heading title, denoting the project, and
sets the :EXPORT_TITLE: and :CATEGORY: properties to the same."
(interactive)
(save-excursion
(org-capture-goto-last-stored) ; Aka C-u C-u org-capture
(let ((project-title (org-get-heading t t)))
(org-set-property "EXPORT_TITLE" project-title)
(org-set-property "CATEGORY" project-title))))
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: save-excursion not saving when I call org-capture-goto-last-stored
2012-02-05 3:01 save-excursion not saving when I call org-capture-goto-last-stored Jon Miller
@ 2012-02-09 6:28 ` David Maus
2012-02-09 17:02 ` Jon Miller
0 siblings, 1 reply; 3+ messages in thread
From: David Maus @ 2012-02-09 6:28 UTC (permalink / raw)
To: Jon Miller; +Cc: orgmode
[-- Attachment #1: Type: text/plain, Size: 1236 bytes --]
At Sat, 4 Feb 2012 22:01:32 -0500,
Jon Miller wrote:
>
> I'm currently trying to write a function to do some post-capture
> updates to an entry. My intention is to add it to
> org-capture-after-finalize-hook. First step is navigating to the
> captured item but I'd like to return to the current buffer I was in
> before. I'm still a novice with elisp, so I could use a pointer here.
>
> Here is a simplified example:
> M-: (save-excursion (org-capture-goto-last-stored))
>
> Is there a better way to navigate to the last capture and then return
> to my current buffer?
Well, save-excursion does restore the current buffer but is not
switching to it. Executing
,----
| (progn
| (save-excursion
| (org-capture-goto-last-stored))
| (princ (current-buffer)))
`----
in *scratch* tells me that the current-buffer after the excursion is
*scratch*. What you are looking for is saving and restoring the
windows configuration (visible buffers in a frame).
C-h f save-window-excursion RET
This should do the trick:
,----
| (progn
| (save-excursion
| (save-window-excursion
| (org-capture-goto-last-stored))))
`----
Best,
-- David
--
OpenPGP... 0x99ADB83B5A4478E6
Jabber.... dmjena@jabber.org
Email..... dmaus@ictsoc.de
[-- Attachment #2: Type: application/pgp-signature, Size: 230 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: save-excursion not saving when I call org-capture-goto-last-stored
2012-02-09 6:28 ` David Maus
@ 2012-02-09 17:02 ` Jon Miller
0 siblings, 0 replies; 3+ messages in thread
From: Jon Miller @ 2012-02-09 17:02 UTC (permalink / raw)
To: David Maus; +Cc: orgmode
Awesome, thanks. That worked for me.
Now to add my conditional logic for which parent headings I want
this behavior to apply to and I'm done.
Thanks again,
Jon Miller
On Thu, Feb 9, 2012 at 1:28 AM, David Maus <dmaus@ictsoc.de> wrote:
> At Sat, 4 Feb 2012 22:01:32 -0500,
> Jon Miller wrote:
>>
>> I'm currently trying to write a function to do some post-capture
>> updates to an entry. My intention is to add it to
>> org-capture-after-finalize-hook. First step is navigating to the
>> captured item but I'd like to return to the current buffer I was in
>> before. I'm still a novice with elisp, so I could use a pointer here.
>>
>> Here is a simplified example:
>> M-: (save-excursion (org-capture-goto-last-stored))
>>
>> Is there a better way to navigate to the last capture and then return
>> to my current buffer?
>
> Well, save-excursion does restore the current buffer but is not
> switching to it. Executing
>
> ,----
> | (progn
> | (save-excursion
> | (org-capture-goto-last-stored))
> | (princ (current-buffer)))
> `----
>
> in *scratch* tells me that the current-buffer after the excursion is
> *scratch*. What you are looking for is saving and restoring the
> windows configuration (visible buffers in a frame).
>
> C-h f save-window-excursion RET
>
> This should do the trick:
>
> ,----
> | (progn
> | (save-excursion
> | (save-window-excursion
> | (org-capture-goto-last-stored))))
> `----
>
> Best,
> -- David
> --
> OpenPGP... 0x99ADB83B5A4478E6
> Jabber.... dmjena@jabber.org
> Email..... dmaus@ictsoc.de
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-02-09 17:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-05 3:01 save-excursion not saving when I call org-capture-goto-last-stored Jon Miller
2012-02-09 6:28 ` David Maus
2012-02-09 17:02 ` Jon Miller
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.