From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: outline-minor-mode and code editing / export Date: Tue, 9 Jun 2009 19:29:05 +0200 Message-ID: <198870E0-3A0D-4A2A-A4E9-4546E542A0CB@gmail.com> References: <87skidxinh.fsf@stats.ox.ac.uk> <658100FA-212E-4D99-9297-5C73A53A0E70@gmail.com> <87oct0nerb.fsf@stats.ox.ac.uk> <49673B8D-315B-4CE6-8BEB-67AB13B70649@gmail.com> <878wk1mtho.fsf@stats.ox.ac.uk> Mime-Version: 1.0 (Apple Message framework v935.3) 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 1ME58N-0001ZM-Kl for emacs-orgmode@gnu.org; Tue, 09 Jun 2009 13:29:15 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1ME58J-0001Z9-0M for emacs-orgmode@gnu.org; Tue, 09 Jun 2009 13:29:14 -0400 Received: from [199.232.76.173] (port=55075 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ME58I-0001Z6-Qy for emacs-orgmode@gnu.org; Tue, 09 Jun 2009 13:29:10 -0400 Received: from mail-ew0-f225.google.com ([209.85.219.225]:51870) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1ME58I-0001lW-7E for emacs-orgmode@gnu.org; Tue, 09 Jun 2009 13:29:10 -0400 Received: by ewy25 with SMTP id 25so162678ewy.42 for ; Tue, 09 Jun 2009 10:29:09 -0700 (PDT) In-Reply-To: <878wk1mtho.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 On Jun 9, 2009, at 3:22 PM, Dan Davison wrote: > >> >>> >>> Dan >>> >>> * Btw, a trivial thing, but I wonder if it would be appropriate to >>> rename >>> org-exit-edit-mode as something like org-edit-src-mode; it now has >>> two >>> keybindings only one of which is to do with exiting. >> >> I don't understand this point. Please try again :-) > > No problem. We currently have this in org-src.el: > > (define-minor-mode org-exit-edit-mode > "Minor mode installing a single key binding, \"C-c '\" to exit > special edit.") > > However, the scope of that minor mode has now expanded, and as well as > the docstring being out of date, its name is misleading, as it is now > concerned with more than just *exit* (saving as well). > > What I propose is that we rename org-exit-edit-mode as org-src-mode, > and > that that minor mode is turned on when editing source blocks with C- > c ', > and when processing with htmlize. I have applied this patch, thanks - still looking at the other one... - Carsten > Because of the way you named the hook > you just created, the minor mode would automatically inherit it as its > minor mode hook. I think this would logically tie together your recent > changes (expansion of functionality in the edit buffer, and addition > of > org-src-mode-hook), and would leave the door open for future additions > to org-src-mode. > > I've quickly made these changes, and tested that the minor mode hook > had > the desired effect (for me) on export and source code editing. > Here's my > patch that does what I propose. > > Dan > > diff --git a/lisp/org-exp.el b/lisp/org-exp.el > index 4e98bb9..b8fb201 100644 > --- a/lisp/org-exp.el > +++ b/lisp/org-exp.el > @@ -2219,7 +2219,7 @@ INDENT was the original indentation of the > block." > (funcall mode) > (fundamental-mode)) > (font-lock-fontify-buffer) > - (run-hooks 'org-src-mode-hook) > + (org-src-mode) > (set-buffer-modified-p nil) > (org-export-htmlize-region-for-paste > (point-min) (point-max)))) > diff --git a/lisp/org-src.el b/lisp/org-src.el > index 401c628..524f6d6 100644 > --- a/lisp/org-src.el > +++ b/lisp/org-src.el > @@ -116,9 +116,9 @@ This is needed for font-lock setup.") > > ;;; Editing source examples > > -(defvar org-exit-edit-mode-map (make-sparse-keymap)) > -(define-key org-exit-edit-mode-map "\C-c'" 'org-edit-src-exit) > -(define-key org-exit-edit-mode-map "\C-x\C-s" 'org-edit-src-save) > +(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) > @@ -127,8 +127,14 @@ This is needed for font-lock setup.") > (defvar org-edit-src-overlay nil) > (defvar org-edit-src-nindent nil) > > -(define-minor-mode org-exit-edit-mode > - "Minor mode installing a single key binding, \"C-c '\" to exit > special edit.") > +(define-minor-mode org-src-mode > + "Minor mode for language major mode buffers generated by org. > +This minor mode is turned on in two situations: > +- when editing a source code snippet with \"C-c '\". > +- When formatting a source code snippet for export with htmlize. > +There is a mode hook, and keybindings for org-edit-src-exit and > +org-edit-src-save > +") > > (defun org-edit-src-code () > "Edit the source code example at point. > @@ -187,7 +193,7 @@ the edited version." > (org-do-remove-indentation) > (let ((org-inhibit-startup t)) > (funcall lang-f) > - (run-hooks 'org-src-mode-hook)) > + (org-src-mode)) > (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 > @@ -197,7 +203,6 @@ the edited version." > (while (re-search-forward "^," nil t) > (replace-match ""))) > (goto-line (1+ (- line begline))) > - (org-exit-edit-mode) > (org-set-local 'org-edit-src-beg-marker beg) > (org-set-local 'org-edit-src-end-marker end) > (org-set-local 'org-edit-src-overlay ovl) > > > > >> >> - Carsten >> >> >>> >>> >>>> >>>> - Carsten >>>> >>>> On Jun 6, 2009, at 9:32 PM, Dan Davison wrote: >>>> >>>>> In turn on outline-minor-mode in the language major modes that I >>>>> use, so >>>>> that code starts up folded, via a call to org-content that is made >>>>> in my >>>>> major-mode hook. I'm finding that this has two undesirable >>>>> consequences >>>>> for org-mode, as follows. I have also described a possible >>>>> solution, >>>>> as >>>>> implemented by the patch at the end. >>>>> >>>>> 1. The code appears folded on HTML export >>>>> >>>>> solution: add this line to org-export-format-source-code-or- >>>>> example >>>>> (if (fboundp 'show-all) (show-all)) >>>>> >>>>> 2. org-edit-src-save does not remember the visibility state, so >>>>> C-x >>>>> C-s >>>>> causes a jump to a different visibility state >>>>> >>>>> solution: save the value of org-cycle-global-status and, when the >>>>> edit buffer is re-entered, call one of {org-overview, >>>>> org-content,show-all} accordingly >>>>> >>>>> Dan >>>>> >>>>> p.s. Carsten: the first hunk in the second diff (org.el) refers >>>>> to a >>>>> patch that I submitted a few days ago and which you said had been >>>>> applied. http://article.gmane.org/gmane.emacs.orgmode/14154 >>>>> However, I >>>>> believe it is not in the current git. Apologies if I have got >>>>> (git) >>>>> confused, but if not I do believe there is still a need for it >>>>> or an >>>>> equivalent solution: without this change I go to end of edit >>>>> buffer, >>>>> hit >>>>> return a few times, and then C-x C-s fails (leaves me in org >>>>> buffer). >>>>> >>>>> >>>>> >>>>> >>>>> diff --git a/lisp/org-exp.el b/lisp/org-exp.el >>>>> index 0dcd956..5f0ad88 100644 >>>>> --- a/lisp/org-exp.el >>>>> +++ b/lisp/org-exp.el >>>>> @@ -2215,7 +2215,6 @@ INDENT was the original indentation of the >>>>> block." >>>>> (if (functionp mode) >>>>> (funcall mode) >>>>> (fundamental-mode)) >>>>> - (if (fboundp 'show-all) (show-all)) >>>>> (font-lock-fontify-buffer) >>>>> (set-buffer-modified-p nil) >>>>> (org-export-htmlize-region-for-paste >>>>> diff --git a/lisp/org.el b/lisp/org.el >>>>> index d124b1a..1eb5e74 100644 >>>>> --- a/lisp/org.el >>>>> +++ b/lisp/org.el >>>>> @@ -6875,9 +6875,7 @@ the language, a switch telling of the >>>>> content >>>>> should be in a single line." >>>>> code) >>>>> (goto-char (point-min)) >>>>> (if (looking-at "[ \t\n]*\n") (replace-match "")) >>>>> - (when (re-search-forward "\n[ \t\n]*\\'" nil t) >>>>> - (replace-match "") >>>>> - (setq line (min line (org-current-line)))) >>>>> + (if (re-search-forward "\n[ \t\n]*\\'" nil t) (replace-match >>>>> "")) >>>>> (when (org-bound-and-true-p org-edit-src-force-single-line) >>>>> (goto-char (point-min)) >>>>> (while (re-search-forward "\n" nil t) >>>>> @@ -6916,18 +6914,11 @@ the language, a switch telling of the >>>>> content should be in a single line." >>>>> (defun org-edit-src-save () >>>>> "Save parent buffer with current state source-code buffer." >>>>> (interactive) >>>>> - (let ((p (point)) (m (mark)) >>>>> - (visibility org-cycle-global-status) msg) >>>>> + (let ((p (point)) (m (mark)) msg) >>>>> (org-edit-src-exit) >>>>> (save-buffer) >>>>> (setq msg (current-message)) >>>>> (org-edit-src-code) >>>>> - (when visibility >>>>> - (setq org-cycle-global-status visibility) >>>>> - (cond >>>>> - ((equal org-cycle-global-status 'overview) (org-overview)) >>>>> - ((equal org-cycle-global-status 'contents) (org-content)) >>>>> - ((equal org-cycle-global-status 'all) (show-all)))) >>>>> (push-mark m 'nomessage) >>>>> (goto-char (min p (point-max))) >>>>> (message (or msg "")))) >>>>> >>>>> >>>>> _______________________________________________ >>>>> Emacs-orgmode mailing list >>>>> Remember: use `Reply All' to send replies to the list. >>>>> Emacs-orgmode@gnu.org >>>>> http://lists.gnu.org/mailman/listinfo/emacs-orgmode >>>> >>>> >>>> >>>> _______________________________________________ >>>> Emacs-orgmode mailing list >>>> Remember: use `Reply All' to send replies to the list. >>>> Emacs-orgmode@gnu.org >>>> http://lists.gnu.org/mailman/listinfo/emacs-orgmode >> >> >> >> _______________________________________________ >> Emacs-orgmode mailing list >> Remember: use `Reply All' to send replies to the list. >> Emacs-orgmode@gnu.org >> http://lists.gnu.org/mailman/listinfo/emacs-orgmode