From mboxrd@z Thu Jan 1 00:00:00 1970 From: Olaf Dietsche Subject: Re: problem with command-line call to emacsclient Date: Sat, 02 Jul 2011 11:57:26 +0200 Message-ID: <87oc1dc8e1.fsf@rat.lan> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from eggs.gnu.org ([140.186.70.92]:33478) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QcwxF-0000Jw-UA for emacs-orgmode@gnu.org; Sat, 02 Jul 2011 05:57:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QcwxE-0005gK-BO for emacs-orgmode@gnu.org; Sat, 02 Jul 2011 05:57:37 -0400 Received: from www85.your-server.de ([213.133.104.85]:33791) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QcwxE-0005fs-3o for emacs-orgmode@gnu.org; Sat, 02 Jul 2011 05:57:36 -0400 In-Reply-To: (Herbert Sitz's message of "Sat, 2 Jul 2011 04:42:30 +0000 (UTC)") 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: Herbert Sitz Cc: emacs-orgmode@gnu.org Herbert Sitz writes: > I'm making a call to an emacsclient and trying to figure out how to get the > buffer to unload at the end of the function I'm calling. I know kill-buffer > isn't supposed to unload the buffer but I can't figure out what will. I've > tried server-edit and server-kill-buffer in place of kill-buffer below and they > also haven't worked. The buffer gets "pushed to the kill buffer", but remains > loaded. > > The problem with having buffer remain loaded is when I redo the command-line > call after editing the org file outside of emacs it prompts user for whether to > reload changed file. One option would be to simply disable that prompt, I > guess, but I'd rather be able to clear the buffer. > > Here's the function I'm calling: > ---------------------------------- > (defun vimorg-export-publish (fname exp-function) > (find-file fname) > (funcall exp-function nil) > (kill-buffer) ) > --------------------------------- I tried this in *scratch* and it works fine: (defun test-kill-buffer (fname) (find-file fname) (kill-buffer)) C-x C-e (test-kill-buffer "/tmp/abc.txt") C-x C-e Repeat the steps and leave out the "(kill-buffer)" and the file /tmp/abc.txt remains in emacs. > > And here's sample command line that calls it. Strange characters are because > it's on Windows system, but it works fine other than that the buffer is not > unloaded at end of vimorg-export-publish function: > ----------------------------- > c:\users\herbert\emacsclientw.exe --eval ^"(vimorg-export-publish > \^"~/myorgfile.org\^" 'org-export-as-html-and-open )^" > ------------------------------ So it must be something with (funcall exp-function) or exp-function, which prevents unloading `fname'. Maybe org-export-as-html-and-open changes buffers. So, I guess either a save-excursion around (funcall ...) or: (defun test-kill-buffer (fname exp-function) (let ((buf (find-file fname))) (funcall exp-function) (kill-buffer buf))) (test-kill-buffer "/tmp/abc.txt" 'some-function-to-call) will do the trick. Regards, Olaf