emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Clément Pit-Claudel" <cpitclaudel@gmail.com>
To: emacs-orgmode@gnu.org
Cc: Nicolas Goaziou <mail@nicolasgoaziou.fr>
Subject: Re: buffer-file-name in [* Org src *] buffers
Date: Wed, 14 Mar 2018 10:18:55 -0400	[thread overview]
Message-ID: <a064d3f0-139a-d434-7fb3-e23dfbcf4a6e@gmail.com> (raw)
In-Reply-To: <87ina1cqaf.fsf@nicolasgoaziou.fr>

Hi Nicolas,

> The explanation is here:
> 
> <http://lists.gnu.org/archive/html/emacs-orgmode/2009-08/msg00335.html>
> 
> AFAIU, this was needed so that Emacs would warn when closing a remote
> editing buffer with C-x k. This feature doesn't appear to be functional
> at the moment, tho.

Sorry for the delayed answer; I didn't receive your message.

Thanks for the link to the discussion.  It'd be great to find a different way to do it, though, as the current implementation sends a confusing signal to other packages.

The original implementation listed three problems:

> * Proposed bug I
>       C-x k kills the edit buffer without questions; the overlay
>       remains, but now links to a deleted buffer.
> * Proposed bug II
>       C-x C-c kills a modified edit buffer silently, without offering to
>       save your work. I have lost work like that a number of times
>       recently.
> * Proposed bug III
>       C-x s does not offer to save a modified edit buffer

It also mentioned this:

> This patch gives the desired behaviour, at the cost of being forced
> to assign a buffer-file-name to the edit buffer. The consequence is
> that the edit buffer is considered to always be modified

I think there's an alternative fix for these issues that doesn't require setting buffer-file-name:

1. Set buffer-offer-save to 'always; this guarantees that C-x s will ask about the edit buffer.
2. Add an entry to kill-buffer-query-functions.  For example, with-editor (used by magit) does this:
   (add-hook 'kill-buffer-query-functions
             'with-editor-kill-buffer-noop nil t)

With these, we could leave buffer-file-name to nil.

WDYT?
Clément.

PS: point (1) shares an issue with the original implementation (it always prompts during save-some-buffers).  One fix to this could be to add a buffer-modification-hook that marks the source buffer as modified when the edit buffer is modified, and to make change the source buffer's write-contents-functions to offer to save edit buffers too.

  reply	other threads:[~2018-03-14 14:19 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-11 22:56 buffer-file-name in [* Org src *] buffers Clément Pit-Claudel
2018-03-12  3:47 ` numbchild
2018-03-12 14:38 ` Nicolas Goaziou
2018-03-14 14:18   ` Clément Pit-Claudel [this message]
2018-03-14 19:57     ` Nicolas Goaziou
2018-04-26 23:34     ` Bastien
2018-04-27  5:06       ` Clément Pit-Claudel

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=a064d3f0-139a-d434-7fb3-e23dfbcf4a6e@gmail.com \
    --to=cpitclaudel@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=mail@nicolasgoaziou.fr \
    /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).