From mboxrd@z Thu Jan 1 00:00:00 1970 From: Leo Alekseyev Subject: Re: Org-edit-special and C-x C-s strange behavior Date: Wed, 11 Jan 2012 22:56:42 -0600 Message-ID: References: <87pqeqb76j.fsf@ucl.ac.uk> <878vlem00k.fsf@med.uni-goettingen.de> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([140.186.70.92]:50044) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RlCiS-00079W-QE for emacs-orgmode@gnu.org; Wed, 11 Jan 2012 23:56:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RlCiR-0004Ud-IT for emacs-orgmode@gnu.org; Wed, 11 Jan 2012 23:56:44 -0500 Received: from mail-pz0-f41.google.com ([209.85.210.41]:54903) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RlCiR-0004UX-84 for emacs-orgmode@gnu.org; Wed, 11 Jan 2012 23:56:43 -0500 Received: by dakl33 with SMTP id l33so1020450dak.0 for ; Wed, 11 Jan 2012 20:56:42 -0800 (PST) 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: emacs-orgmode@gnu.org On Wed, Jan 11, 2012 at 7:40 PM, Leo Alekseyev wrote: >> Eric S Fraga writes: >>> >>> What version of org are you using? =A0I ask because I used to experienc= e >>> the annoyance you describe a while back; more recently (since at least = a >>> few months ago), hitting C-x C-s no longer has any negative impact: it >>> saves the file, or at least appears to. >>> >>> You still have to C-c ' to get back to the full buffer, mind you, but >>> that's better, IMO, than changing the behaviour of such a fundamental >>> key binding as C-x C-s. > > It appears that this bug is Emacs-version dependent: it functions as > you describe with 23.2, but the buffer gets buried (with an error > message "basic-save-buffer: Wrong type argument: stringp, nil") in > 24.0.92. =A0Org mode is the current git HEAD. =A0I tried to step through > basic-save-buffer in edebug, but I couldn't catch the error (I'm not > very experienced with edebug). =A0Can someone test this on Emacs 24 and > confirm what I'm seeing? I've done some more digging into why this is broken. I see a few issues, but no clear indication of where the problem is. This, however, should be fixed: pressing C-x C-s should not break window configuration. On Emacs 24, with latest Org: 1. Somehow, (org-edit-src-save) screws up the window configuration and buries the source edit buffer. It appears that save-window-excursion is not restoring windows correctly. What's going on exactly is unclear: in the process of getting saved, the source edit buffer is killed and subsequently restored with (org-src-switch-to-buffer buffer 'edit). Maybe this doesn't play well with save-window-excursion in Emacs 24? I stepped through the calls in Emacs 23 and 24, and it all looks identical -- except for in 24, the call to save-window-excursion does not in fact restore windows. 2. In file.el:4435 (basic-save-buffer) (nthcdr 10 (file-attributes buffer-file-name)) often leads to wrong-type-argument error. The reason for this is that buffer-file-name sometimes corresponds to the "base" .org buffer (no error in this case), sometimes it corresponds to the name of the src-edit buffer and sometimes it's nil (leads to wrong-type-argument error). By this point, the file should have been written using 'write-contents-functions that is set to (org-edit-src-save), so I don't know if this error is important (nonetheless, buffer-file-name should probably be valid). 3. Related, in the same function: (if (or (buffer-modified-p) ;; handle the case when no modification has been made but ;; the file disappeared since visited (and buffer-file-name (not (file-exists-p buffer-file-name)))) This if statement is always triggered, because buffer-file-name is not nil, and because the buffer doesn't correspond to the file. (Note that in Emacs 23 this was just (if (buffer-modified-p)...). This is not be the appropriate behavior, but it persists because buffer-file-name is not nil (which it probably should be). --l