Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Syntax highlighting in org-mode. List of languages?

Tags:

emacs

org-mode

When I try to highlight SQL code in org-mode, the highlighting fails:

#+BEGIN_SRC SQL
SELECT *
FROM Production.Product
ORDER BY Name ASC;
#+END_SRC SQL

It works great for Python, shell etc, but not for SQL. I wonder if I am using the wrong keyword.

Given this:

  • How can I highlight SQL code?
  • Where can I find the list of languages supported?
like image 844
Amelio Vazquez-Reina Avatar asked Mar 18 '14 15:03

Amelio Vazquez-Reina


People also ask

How do you write Org mode?

To enable Org mode on your current document, type M-x org-mode which will enable the Org mode on the current document. Those are minuses, not underscores. MY PROJECT is the title of the document, this can be anything. This will enable Org mode for this document, no matter what the file-ending is.

What is Org mode used for?

Org Mode (also: org-mode; /ˈɔːrɡ moʊd/) is a document editing, formatting, and organizing mode, designed for notes, planning, and authoring within the free software text editor Emacs.


1 Answers

SQL should be lowercase, sql, and you don't need to repeat the language name on the END_SRC line:

#+BEGIN_SRC sql
  SELECT *
  FROM Production.Product
  ORDER BY Name ASC;
#+END_SRC

org-mode just appends -mode to the language name given and tries to find a major mode function. Emacs Lisp function names are case sensitive, so sql-mode exists while SQL-mode doesn't.

You can get a list of all such functions by typing C-h a -mode$, i.e. search for all functions that end with -mode, but the resulting list contains many modes that are not major modes for programming languages.

like image 153
legoscia Avatar answered Oct 02 '22 19:10

legoscia