emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [bug] org-edit-src-code auto-save glitch
@ 2013-03-26 19:18 Charles Berry
  2013-04-07 20:42 ` Bastien
  0 siblings, 1 reply; 6+ messages in thread
From: Charles Berry @ 2013-03-26 19:18 UTC (permalink / raw)
  To: emacs-orgmode


I use Org-mode version 8.0-pre (release_8.0-pre-180-gf09471)

I am getting my src-buffers auto-saved even though

C-h v org-edit-src-auto-save-idle-delay RET gives me

,----
| org-edit-src-auto-save-idle-delay is a variable defined in `org-src.el'.
| Its value is 0
| 
| Documentation:
| Delay of idle time before auto-saving src code buffers.
| When a positive integer N, save after N seconds of idle time.
| When 0 (the default), don't auto-save.
`----

When I open a src buffer and do C-h v buffer-auto-save-file-name RET I get 

,----
| buffer-auto-save-file-name is a variable defined in `C source code'.
| Its value is "org-src-2801BU-2013-26-03.txt"
| Local in buffer *Org Src notes.org[ R ]*; global value is nil
| [deleted]
| 
| Documentation:
| Name of file for auto-saving current buffer.
| If it is nil, that means don't auto-save this buffer.
`----

Also, M-x auto-save-mode echoes "Auto-Save mode disabled" which tells me it was
enabled when I opened that buffer.

IIUC the problem is that this part of the function

,----
| (setq buffer-file-name nil
|       buffer-auto-save-file-name
|       (concat (make-temp-name "org-src-")
| 	      (format-time-string "-%Y-%d-%m") ".txt"))
`----


should consult org-edit-src-auto-save-idle-delay and when it is zero,
set buffer-auto-save-file-name to nil or take some other action to ensure that
auto-save-mode does get enabled.

?

Chuck

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [bug] org-edit-src-code auto-save glitch
  2013-03-26 19:18 [bug] org-edit-src-code auto-save glitch Charles Berry
@ 2013-04-07 20:42 ` Bastien
  2013-04-09 20:51   ` Charles C. Berry
  0 siblings, 1 reply; 6+ messages in thread
From: Bastien @ 2013-04-07 20:42 UTC (permalink / raw)
  To: Charles Berry; +Cc: emacs-orgmode

Hi Charles,

Charles Berry <ccberry@ucsd.edu> writes:

> IIUC the problem is that this part of the function
>
> ,----
> | (setq buffer-file-name nil
> |       buffer-auto-save-file-name
> |       (concat (make-temp-name "org-src-")
> | 	      (format-time-string "-%Y-%d-%m") ".txt"))
> `----
>
>
> should consult org-edit-src-auto-save-idle-delay and when it is zero,
> set buffer-auto-save-file-name to nil or take some other action to ensure that
> auto-save-mode does get enabled.

Fixed, thanks.

-- 
 Bastien

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [bug] org-edit-src-code auto-save glitch
  2013-04-07 20:42 ` Bastien
@ 2013-04-09 20:51   ` Charles C. Berry
  2013-04-09 21:04     ` Bastien
  0 siblings, 1 reply; 6+ messages in thread
From: Charles C. Berry @ 2013-04-09 20:51 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode

On Sun, 7 Apr 2013, Bastien wrote:

> Hi Charles,
>
> Charles Berry <ccberry@ucsd.edu> writes:
>
>> IIUC the problem is that this part of the function
>>
>> ,----
>> | (setq buffer-file-name nil
>> |       buffer-auto-save-file-name
>> |       (concat (make-temp-name "org-src-")
>> | 	      (format-time-string "-%Y-%d-%m") ".txt"))
>> `----
>>
>>
>> should consult org-edit-src-auto-save-idle-delay and when it is zero,
>> set buffer-auto-save-file-name to nil or take some other action to ensure that
>> auto-save-mode does get enabled.
>
> Fixed, thanks.

IMHO, this is not fixed.

I did make update2 this morning and have:

,----
| (when auto-save-default
|   (setq buffer-auto-save-file-name
| 	(concat (make-temp-name "org-src-")
| 		(format-time-string "-%Y-%d-%m") ".txt")))
`----

starting in line 354 in org-src.el.

auto-save-default affects lots of things outside of org-mode. So I really 
do not want to set it nil and thereby disable saving of all the buffers I 
really care about.

And unlike normal auto-saving, the auto-saved-files (of src block edits) 
are not deleted when the parent buffer is saved.

So, I am still getting the nuisance files.

I still don't see why org-src.el doesn't use this:

,----
| (when (< 0 org-edit-src-auto-save-idle-delay)
|   (setq buffer-auto-save-file-name
| 	(concat (make-temp-name "org-src-")
| 		(format-time-string "-%Y-%d-%m") ".txt")))
`----



HTH,

Chuck

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [bug] org-edit-src-code auto-save glitch
  2013-04-09 20:51   ` Charles C. Berry
@ 2013-04-09 21:04     ` Bastien
  2013-04-10  2:08       ` Charles C. Berry
  0 siblings, 1 reply; 6+ messages in thread
From: Bastien @ 2013-04-09 21:04 UTC (permalink / raw)
  To: Charles C. Berry; +Cc: emacs-orgmode

hi Charles,

can you provide a patch for this?

http://orgmode.org/worg/org-contribute.html#sec-5

Thanks,

-- 
 Bastien

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [bug] org-edit-src-code auto-save glitch
  2013-04-09 21:04     ` Bastien
@ 2013-04-10  2:08       ` Charles C. Berry
  2013-04-16  8:42         ` Bastien
  0 siblings, 1 reply; 6+ messages in thread
From: Charles C. Berry @ 2013-04-10  2:08 UTC (permalink / raw)
  To: Bastien; +Cc: emacs-orgmode

[-- Attachment #1: Type: TEXT/PLAIN, Size: 198 bytes --]

On Tue, 9 Apr 2013, Bastien wrote:

> hi Charles,
>
> can you provide a patch for this?
>
> http://orgmode.org/worg/org-contribute.html#sec-5
>
> Thanks,
>
> -- 
> Bastien
>

Attached.

HTH,

Chuck

[-- Attachment #2: patch file --]
[-- Type: TEXT/PLAIN, Size: 2097 bytes --]

From 48de75ed0a78573a5beb32138608ae3784d0f47b Mon Sep 17 00:00:00 2001
From: cberry <ccberry@ucsd.edu>
Date: Tue, 9 Apr 2013 19:05:17 -0700
Subject: [PATCH] Auto Saving: Uncouple src block from global auto-saving

* lisp/org-src.el (org-edit-src-code): Transmit (possibly file local)
org-edit-src-auto-save-idle-delay to edit buffer and use it to enable
auto saving of the edit buffer.

Fixes auto-saving of all src edit buffers.

TINYCHANGE
---
 lisp/org-src.el |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/lisp/org-src.el b/lisp/org-src.el
index d294796..5ca08c9 100644
--- a/lisp/org-src.el
+++ b/lisp/org-src.el
@@ -278,7 +278,9 @@ the display of windows containing the Org buffer and the code buffer."
 	       ,(or (nth 4 info) org-coderef-label-format))
 	      (org-edit-src-beg-marker ,beg)
 	      (org-edit-src-end-marker ,end)
-	      (org-edit-src-block-indentation ,block-nindent)))
+	      (org-edit-src-block-indentation ,block-nindent)
+	      (org-edit-src-auto-save-idle-delay 
+	       ,org-edit-src-auto-save-idle-delay)))
       (if (and mark (>= mark beg) (<= mark (1+ end)))
 	  (save-excursion (goto-char (min mark end))
 			  (setq markline (org-current-line)
@@ -351,7 +353,7 @@ the display of windows containing the Org buffer and the code buffer."
 	(org-src-mode)
 	(set-buffer-modified-p nil)
 	(setq buffer-file-name nil)
-	(when auto-save-default
+	(when  (< 0 org-edit-src-auto-save-idle-delay)
 	  (setq buffer-auto-save-file-name
 		(concat (make-temp-name "org-src-")
 			(format-time-string "-%Y-%d-%m") ".txt")))
@@ -376,8 +378,8 @@ the display of windows containing the Org buffer and the code buffer."
 				       (string-match "\*Org Src" (buffer-name b)))
 				     (buffer-list))))
 			 (cancel-timer org-edit-src-code-timer)
-			 (setq org-edit-src-code-timer)))))))))
-	t)))
+		 	 (setq org-edit-src-code-timer)))))))))
+      t)))
 
 (defun org-edit-src-continue (e)
   "Continue editing source blocks." ;; Fixme: be more accurate
-- 
1.7.10.2 (Apple Git-33)


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [bug] org-edit-src-code auto-save glitch
  2013-04-10  2:08       ` Charles C. Berry
@ 2013-04-16  8:42         ` Bastien
  0 siblings, 0 replies; 6+ messages in thread
From: Bastien @ 2013-04-16  8:42 UTC (permalink / raw)
  To: Charles C. Berry; +Cc: emacs-orgmode

Hi Charles,

"Charles C. Berry" <ccberry@ucsd.edu> writes:

> Attached.

Thanks for the patch -- there is a confusion here.

`org-edit-src-auto-save-idle-delay' controls whether the base buffer
will be saved after some idle delay.  If so, it does what C-x C-s
would do: save the base buffer, not the editing window.

Using auto-save-default was a bit too much, so there is now
`org-edit-src-turn-on-auto-save' which will take care of setting 
`buffer-auto-save-file-name', which turns on auto-save-mode.

Thanks for bringing this up,

-- 
 Bastien

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-04-16  8:42 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-26 19:18 [bug] org-edit-src-code auto-save glitch Charles Berry
2013-04-07 20:42 ` Bastien
2013-04-09 20:51   ` Charles C. Berry
2013-04-09 21:04     ` Bastien
2013-04-10  2:08       ` Charles C. Berry
2013-04-16  8:42         ` Bastien

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).