From mboxrd@z Thu Jan 1 00:00:00 1970 From: Suvayu Ali Subject: Re: Problem with choosing mode while editing blocks with C-c ' Date: Wed, 14 Mar 2012 10:03:48 +0100 Message-ID: <20120314100348.284936b2@kuru.dyndns-at-home.com> References: <877gyoxfu4.fsf@googlemail.com> <19361.1331685259@alphaville> <21446.1331694680@alphaville> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="MP_/QrYyOg4xLH4vZDNzATHxzVR" Return-path: Received: from eggs.gnu.org ([208.118.235.92]:56894) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S7k7m-0008Az-Ll for emacs-orgmode@gnu.org; Wed, 14 Mar 2012 05:04:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1S7k7f-0001sW-DL for emacs-orgmode@gnu.org; Wed, 14 Mar 2012 05:04:02 -0400 Received: from mail-ee0-f41.google.com ([74.125.83.41]:42609) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1S7k7f-0001oK-4V for emacs-orgmode@gnu.org; Wed, 14 Mar 2012 05:03:55 -0400 Received: by eeke53 with SMTP id e53so838820eek.0 for ; Wed, 14 Mar 2012 02:03:52 -0700 (PDT) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: nicholas.dokos@hp.com Cc: emacs-orgmode@gnu.org --MP_/QrYyOg4xLH4vZDNzATHxzVR Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline Sorry the quoting was all wrong! Gmail was behaving weirdly. I wanted to quote the other message. On Wed, Mar 14, 2012 at 03:59, Nick Dokos wrote: > The case-fold-search problem is in > org-src.el:org-edit-src-code. case-fold-search is let-bound to t, but > the let form evaluates all the VARLIST forms before evaluating the > body, so the very next varlist > (case-fold-search t) > (info (org-edit-src-find-region-and-lang)) > ... > fails because in its evaluation, case-fold-search is still nil. > The solution is to use a let* form instead: just change the let on > line 216 to a let*. On Wed, Mar 14, 2012 at 09:41, suvayu ali wrote: > Yup, your analysis was spot on. :) Changing the let to let* and > reevaluating the defun fixed the issue. > > I hadn't grasped this subtlety about let*, dependencies on preceding > bindings hidden behind function calls! I am attaching the changes as a patch. Let me know if it is okay. Thanks, -- Suvayu Open source is the future. It sets us free. --MP_/QrYyOg4xLH4vZDNzATHxzVR Content-Type: text/x-patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=0001-Change-let-bind-to-a-let-in-org-edit-src-code.patch >From 48eb85df419c38a57d35808ca3a3bc9d86e05c33 Mon Sep 17 00:00:00 2001 From: Suvayu Ali Date: Wed, 14 Mar 2012 09:49:40 +0100 Subject: [PATCH] Change let bind to a let* in org-edit-src-code * org-src.el (org-edit-src-code): Change let bind to let*, e.g. if case-fold-search is bound to nil globally, the (case-fold-search t) doesn't work until we get to the body. The fix and analysis was provided by Nick Dokos on this email message thread: TINY CHANGE --- lisp/org-src.el | 20 ++++++++++---------- 1 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lisp/org-src.el b/lisp/org-src.el index 9cd56d2..dfaa72d 100644 --- a/lisp/org-src.el +++ b/lisp/org-src.el @@ -213,16 +213,16 @@ (defun org-edit-src-code (&optional context code edit-buffer-name) (interactive) (unless (eq context 'save) (setq org-edit-src-saved-temp-window-config (current-window-configuration))) - (let ((mark (and (org-region-active-p) (mark))) - (case-fold-search t) - (info (org-edit-src-find-region-and-lang)) - (full-info (org-babel-get-src-block-info 'light)) - (org-mode-p (derived-mode-p 'org-mode)) ;; derived-mode-p is reflexive - (beg (make-marker)) - (end (make-marker)) - (allow-write-back-p (null code)) - block-nindent total-nindent ovl lang lang-f single lfmt buffer msg - begline markline markcol line col transmitted-variables) + (let* ((mark (and (org-region-active-p) (mark))) + (case-fold-search t) + (info (org-edit-src-find-region-and-lang)) + (full-info (org-babel-get-src-block-info 'light)) + (org-mode-p (derived-mode-p 'org-mode)) ;; derived-mode-p is reflexive + (beg (make-marker)) + (end (make-marker)) + (allow-write-back-p (null code)) + block-nindent total-nindent ovl lang lang-f single lfmt buffer msg + begline markline markcol line col transmitted-variables) (if (not info) nil (setq beg (move-marker beg (nth 0 info)) -- 1.7.7.6 --MP_/QrYyOg4xLH4vZDNzATHxzVR--