From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: Re: PATCH: proposed improvements to org-src-mode Date: Mon, 24 Aug 2009 14:17:47 +0200 Message-ID: <3845FC6A-EF07-4CB0-BB36-6F2652CD4F26@gmail.com> References: <873aain0f7.fsf@stats.ox.ac.uk> <8216B89D-C718-4604-AAC4-82BFCA967161@gmail.com> <873a7y9u63.fsf_-_@stats.ox.ac.uk> <9C5369DB-A034-4A0D-84FE-8872BB032BA6@gmail.com> <87iqgt5ba2.fsf@stats.ox.ac.uk> <87ljlgysjl.fsf@stats.ox.ac.uk> Mime-Version: 1.0 (Apple Message framework v936) Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MfYUp-0006Ym-1P for emacs-orgmode@gnu.org; Mon, 24 Aug 2009 08:17:59 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MfYUk-0006VQ-PG for emacs-orgmode@gnu.org; Mon, 24 Aug 2009 08:17:58 -0400 Received: from [199.232.76.173] (port=53027 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MfYUk-0006Ux-9h for emacs-orgmode@gnu.org; Mon, 24 Aug 2009 08:17:54 -0400 Received: from mail-ew0-f211.google.com ([209.85.219.211]:33626) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MfYUj-0002iG-HY for emacs-orgmode@gnu.org; Mon, 24 Aug 2009 08:17:53 -0400 Received: by ewy7 with SMTP id 7so2342749ewy.31 for ; Mon, 24 Aug 2009 05:17:51 -0700 (PDT) In-Reply-To: <87ljlgysjl.fsf@stats.ox.ac.uk> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Dan Davison Cc: emacs org-mode mailing list Hi Dan, I am now finally looking at your patch. A few questions: On Aug 19, 2009, at 1:03 PM, Dan Davison wrote: > Dan Davison writes: > >> Carsten Dominik writes: >> >>> Hi Dan, >>> >>> thank you for studying and describing these issues, and for >>> proposing >>> a patch. > > I have noticed a bug in the patch I proposed: the configuration of the > edit buffer for saving must be done only after C-c ', and not for > example when entering org-src-mode during HTML export. Here's the > revised patch (again, assuming org-edit-src-from-org-mode is a valid > test that C-c ' has just been done). > > Dan > > --8<---------------cut here---------------start------------->8--- > diff --git a/lisp/org-src.el b/lisp/org-src.el > index 2a6c087..6ba58f5 100644 > --- a/lisp/org-src.el > +++ b/lisp/org-src.el > @@ -113,7 +113,6 @@ but which mess up the display of a snippet in > Org exported files.") > > (defvar org-src-mode-map (make-sparse-keymap)) > (define-key org-src-mode-map "\C-c'" 'org-edit-src-exit) > -(define-key org-src-mode-map "\C-x\C-s" 'org-edit-src-save) > (defvar org-edit-src-force-single-line nil) > (defvar org-edit-src-from-org-mode nil) > (defvar org-edit-src-picture nil) > @@ -168,7 +167,8 @@ the edited version." > (if (boundp 'org-edit-src-overlay) > (org-delete-overlay org-edit-src-overlay))) > (kill-buffer buffer)) > - (setq buffer (generate-new-buffer "*Org Edit Src Example*")) > + (setq buffer (generate-new-buffer > + (concat "*Org Src " (file-name-nondirectory buffer-file- > name) "[" lang "]*"))) > (setq ovl (org-make-overlay beg end)) > (org-overlay-put ovl 'face 'secondary-selection) > (org-overlay-put ovl 'edit-buffer buffer) > @@ -186,8 +186,7 @@ the edited version." > '(display nil invisible nil intangible nil)) > (org-do-remove-indentation) > (let ((org-inhibit-startup t)) > - (funcall lang-f) > - (org-src-mode)) You are moving the call to org-src-mode only so that you have org-edit- src-from-org defined in the hook, right? > + (funcall lang-f)) > (set (make-local-variable 'org-edit-src-force-single-line) single) > (set (make-local-variable 'org-edit-src-from-org-mode) org-mode-p) > (when lfmt > @@ -201,6 +200,7 @@ the edited version." > (org-set-local 'org-edit-src-end-marker end) > (org-set-local 'org-edit-src-overlay ovl) > (org-set-local 'org-edit-src-nindent nindent) > + (org-src-mode) > (and org-edit-src-persistent-message > (org-set-local 'header-line-format msg))) > (message "%s" msg) > @@ -400,12 +400,13 @@ the language, a switch telling of the content > should be in a single line." > (defun org-edit-src-exit () > "Exit special edit and protect problematic lines." > (interactive) > - (unless (string-match "\\`*Org Edit " (buffer-name (current- > buffer))) > - (error "This is not an sub-editing buffer, something is > wrong...")) > + (unless org-edit-src-from-org-mode > + (error "This is not a sub-editing buffer, something is > wrong...")) > (let ((beg org-edit-src-beg-marker) > (end org-edit-src-end-marker) > (ovl org-edit-src-overlay) > (buffer (current-buffer)) > + (buffer-file-name nil) What is the above line for? > (nindent org-edit-src-nindent) > code line) > (untabify (point-min) (point-max)) > @@ -444,7 +445,6 @@ the language, a switch telling of the content > should be in a single line." > (switch-to-buffer (marker-buffer beg)) > (kill-buffer buffer) > (goto-char beg) > - (org-delete-overlay ovl) Why are you removing this line? > (delete-region beg end) > (insert code) > (goto-char beg) > @@ -464,6 +464,19 @@ the language, a switch telling of the content > should be in a single line." > (goto-char (min p (point-max))) > (message (or msg "")))) > > +(defun org-src-mode-configure-edit-buffer () > + (when org-edit-src-from-org-mode > + (setq buffer-offer-save t) > + (setq buffer-file-name > + (concat (buffer-file-name (marker-buffer org-edit-src-beg-marker)) > + "[" (buffer-name) "]")) > + (set (if (featurep 'xemacs) 'write-contents-hooks 'write- > contents-functions) > + '(org-edit-src-save)) > + (org-add-hook 'kill-buffer-hook > + '(lambda () (org-delete-overlay org-edit-src-overlay)) nil > 'local))) > + > +(org-add-hook 'org-src-mode-hook 'org-src-mode-configure-edit-buffer) > + > (provide 'org-src) > > ;; arch-tag: 6a1fc84f-dec7-47be-a416-64be56bea5d8 > --8<---------------cut here---------------end--------------->8--- I believe an important addition to your patch would be to (set-buffer-modified-p nil) when entering org-src-mode. Otherwise, if I exit Emacs and reply "y" to all safe-this-buffer questions, then I still get a complaint about a buffer with changes.... Thanks! - Carsten