From: "Eric Schulte" <schulte.eric@gmail.com>
To: Org Mode <emacs-orgmode@gnu.org>
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 [thread overview]
Message-ID: <m2bpmfb9bg.fsf@gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 568 bytes --]
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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-adding-org-src-lang-modes-to-map-languages-to-their-.patch --]
[-- Type: text/x-patch, Size: 2257 bytes --]
From cd4ce4bd47398ae43d477d7a02af0e2139ddcc15 Mon Sep 17 00:00:00 2001
From: Eric Schulte <schulte.eric@gmail.com>
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
[-- Attachment #3: Type: text/plain, Size: 204 bytes --]
_______________________________________________
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
reply other threads:[~2009-08-16 23:58 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m2bpmfb9bg.fsf@gmail.com \
--to=schulte.eric@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.