From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Maus Subject: Re: save-excursion not saving when I call org-capture-goto-last-stored Date: Thu, 09 Feb 2012 07:28:37 +0100 Message-ID: <87liocmsfe.wl%dmaus@ictsoc.de> References: Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: multipart/signed; boundary="pgp-sign-Multipart_Thu_Feb__9_07:28:34_2012-1"; micalg=pgp-sha256; protocol="application/pgp-signature" Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([140.186.70.92]:45111) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RvNUp-0006jb-7A for emacs-orgmode@gnu.org; Thu, 09 Feb 2012 01:28:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RvNUn-0002cZ-Sh for emacs-orgmode@gnu.org; Thu, 09 Feb 2012 01:28:43 -0500 Received: from app1a.xlhost.de ([213.202.242.161]:58292) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RvNUn-0002cQ-Mw for emacs-orgmode@gnu.org; Thu, 09 Feb 2012 01:28:41 -0500 In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Jon Miller Cc: orgmode --pgp-sign-Multipart_Thu_Feb__9_07:28:34_2012-1 Content-Type: text/plain; charset=US-ASCII 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 --pgp-sign-Multipart_Thu_Feb__9_07:28:34_2012-1 Content-Type: application/pgp-signature Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) iF4EABEIAAYFAk8zZ5UACgkQDMLgk1Evc4UwwQEApFt2CdDt0nYJiNxUddQ714PN xoY0sFlaY4iONihrgzEA/iYhLmmqoNTf93CLd/jy0VNFi//m882iiGkUPVPIXS16 =aPUR -----END PGP SIGNATURE----- --pgp-sign-Multipart_Thu_Feb__9_07:28:34_2012-1--