From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Eric Schulte" Subject: [PATCH] handle the case when a language's name isn't it's major mode's name Date: Sun, 16 Aug 2009 17:58:11 -0600 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1McpcE-0004uG-7G for emacs-orgmode@gnu.org; Sun, 16 Aug 2009 19:58:22 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Mcpc8-0004tf-PH for emacs-orgmode@gnu.org; Sun, 16 Aug 2009 19:58:20 -0400 Received: from [199.232.76.173] (port=34236 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mcpc8-0004tc-IL for emacs-orgmode@gnu.org; Sun, 16 Aug 2009 19:58:16 -0400 Received: from rv-out-0708.google.com ([209.85.198.241]:11829) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Mcpc8-0001wa-3o for emacs-orgmode@gnu.org; Sun, 16 Aug 2009 19:58:16 -0400 Received: by rv-out-0708.google.com with SMTP id f25so993714rvb.6 for ; Sun, 16 Aug 2009 16:58:15 -0700 (PDT) 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: Org Mode --=-=-= Attached is a small patch for a small issue. Sometimes a language uses a major mode which can't be guessed from it's name. This patch introduces the `org-src-lang-modes' variable which can be used to map language names to major modes when this is the case. This is used when editing a source-code block, or when exporting fontified source-code with htmlize. So far the only instance of this that I know of is ocaml and tuareg-mode, so that's the only thing that `org-src-lang-modes' is pre-populated with. Maybe there are other instances as well? Thanks -- Eric --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-adding-org-src-lang-modes-to-map-languages-to-their-.patch >From cd4ce4bd47398ae43d477d7a02af0e2139ddcc15 Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Sun, 16 Aug 2009 17:53:06 -0600 Subject: [PATCH] adding org-src-lang-modes to map languages to their major modes --- lisp/org-exp.el | 6 +++++- lisp/org-src.el | 12 +++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/lisp/org-exp.el b/lisp/org-exp.el index 7e77fc5..bc413db 100644 --- a/lisp/org-exp.el +++ b/lisp/org-exp.el @@ -2278,7 +2278,11 @@ INDENT was the original indentation of the block." "htmlize.el 1.34 or later is needed for source code formatting"))) (if lang - (let* ((mode (and lang (intern (concat lang "-mode")))) + (let* ((lang-m (when lang + (or (plist-get org-src-lang-modes + (intern (concat ":" lang))) + lang))) + (mode (and lang-m (intern (concat lang-m "-mode")))) (org-inhibit-startup t) (org-startup-folded nil)) (setq rtn diff --git a/lisp/org-src.el b/lisp/org-src.el index 2a6c087..028c545 100644 --- a/lisp/org-src.el +++ b/lisp/org-src.el @@ -109,6 +109,14 @@ You may want to use this hook for example to turn off `outline-minor-mode' or similar things which you want to have when editing a source code file, but which mess up the display of a snippet in Org exported files.") +(defcustom org-src-lang-modes + '(:ocaml "tuareg") + "Property list mapping languages to their major mode. +The key is the language name, the value is the string that should +be inserted as the name of the major mode." + :group 'org-edit-structure + :type 'plist) + ;;; Editing source examples (defvar org-src-mode-map (make-sparse-keymap)) @@ -151,7 +159,9 @@ the edited version." (setq beg (move-marker beg (nth 0 info)) end (move-marker end (nth 1 info)) code (buffer-substring-no-properties beg end) - lang (nth 2 info) + lang (or (plist-get org-src-lang-modes + (intern (concat ":" (nth 2 info)))) + (nth 2 info)) single (nth 3 info) lfmt (nth 4 info) nindent (nth 5 info) -- 1.6.4.73.gc144 --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ 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 --=-=-=--