emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Leo Alekseyev <dnquark@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: Org-edit-special and C-x C-s strange behavior
Date: Wed, 11 Jan 2012 22:56:42 -0600	[thread overview]
Message-ID: <CADzxs1=u1aLEZ3p9V7TiAM8hcA-yt-FMmuQAv6ivzLmbsT3X7g@mail.gmail.com> (raw)
In-Reply-To: <CADzxs1kAF_PPD3Z_o_YFeJrZ0Eb6ipnFDK2ZXHyh_9nGF7M2_g@mail.gmail.com>

On Wed, Jan 11, 2012 at 7:40 PM, Leo Alekseyev <dnquark@gmail.com> wrote:
>> Eric S Fraga <e.fraga@ucl.ac.uk> writes:
>>>
>>> What version of org are you using?  I ask because I used to experience
>>> 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.  Org mode is the current git HEAD.  I tried to step through
> basic-save-buffer in edebug, but I couldn't catch the error (I'm not
> very experienced with edebug).  Can 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

  reply	other threads:[~2012-01-12  4:56 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-11  6:40 Org-edit-special and C-x C-s strange behavior Leo Alekseyev
2012-01-11 15:16 ` Eric S Fraga
2012-01-11 20:56   ` Andreas Leha
2012-01-12  1:40     ` Leo Alekseyev
2012-01-12  4:56       ` Leo Alekseyev [this message]
2012-01-12  9:03       ` Eric S Fraga
2012-01-12 10:14         ` Andreas Leha
2012-01-12 13:55           ` Leo Alekseyev
     [not found]             ` <30ae09b29d262e6156ec9818df085441@mail.rickster.com>
2012-01-13 20:58               ` Leo Alekseyev
2012-01-24 15:25                 ` Bastien
2012-02-08 21:50                   ` Leo Alekseyev
2012-02-14 22:37                     ` Andreas Leha
2012-02-14 23:02                       ` Andreas Leha

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CADzxs1=u1aLEZ3p9V7TiAM8hcA-yt-FMmuQAv6ivzLmbsT3X7g@mail.gmail.com' \
    --to=dnquark@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).