Does Org-mode support RTL Languages like arabic ?
The objective is to prepare and typeset a book in arabic script and export it as PDF for print.
For a correct RTL display you can add the following snippet to your init file:
(defun set-bidi-env ()
"interactive"
(setq bidi-paragraph-direction 'nil))
(add-hook 'org-mode-hook 'set-bidi-env)
From Emacs Manual:
The variable bidi-paragraph-direction, if non-nil, disables the dynamic determination of the base direction, and instead forces all paragraphs in the buffer to have the direction specified by its buffer-local value. The value can be either right-to-left or left-to-right. Any other value is interpreted as nil.
As for pdf export, orgmode handles this using latex. Latex have a rich language support and you can easily makes this work. You can read more about that here.
Related
I'm using most of the standard features of org-mode that come with the spacemacs develop branch, but I haven't been able to find a way to disable the automatic indentation for source code blocks on a case by case basis. I use tangle and I'm writing Dockerfile's in the same file that I'm writing groovy code or javascript for example. The Dockerfile's are the only ones I want not to be indented so I can get syntax highlighting. Here's what it looks like without the indentation:
And here's what it looks like with the indentation that automatically happens if I edit the text:
The automatic indentation is fine for groovy for example, so I have no issue with the automatic indentation here. (in fact, if I still got the syntax highlighting for Dockerfile's I probably wouldn't mind too much except the weird word wrapping not respecting the background face). Here's the example with groovy:
As you can see, I tried a :noindent property I found in the org-mode docs that's usually in a #+STARTUP directive. I also searched stack overflow, but I didn't find anything fruitful that didn't disable indenting for all source blocks or for the entire file.
In my practice (I'm not sure it is a good practice or not, just share it to you):
I setup org-src-tab-acts-natively to true for using the languageās major-mode indentation. In your case, it will format the src block with the formatting rules of dockerfile-mode.
I created a new major-mode plain-mode for the content which should not be indented automatically. Personally, I use this mode for something like:
shell outputs
ASCII diagrams
...
#+begin_src plain
this will not
be
auto
indented
#+end_src
Above src block will not be indented when you select them as region, and TAB on them.
In this way, the src blocks will always behavior as expected when formatting them.
Aside, the example code of plain-mode:
(define-derived-mode plain-mode
clean-mode "Plain"
"Major mode for plain text."
;; preserve the auto indentation on line
(setq-local indent-line-function 'indent-relative)
;; disable auto indentation on region
(setq-local indent-region-function (lambda (start end))))
So, in emacs auctex mode, it is easy to have flyspell ignore TeX math codes by adding a couple of lines to one's .emacs (or other initialization) file. At the moment I'm working on a long HTML document that contains a ton of embedded TeX code, which is being rendered by MathJax. Since it's an HTML file, I'm using nxml mode to write it (mostly to get nice syntax coloring and nice formatting). But since I'm not in auctex (or other LaTeX) mode, flyspell sees all the TeX math codes as misspellings. Is there a way to get flyspell to ignore them the way it does in auctex mode? Thanks.
I'm reading about Invisible Text in the Elisp manual. It defines the variable my-symbol to add or not add ... in place of the hidden text.
;; If you want to display an ellipsis:
(add-to-invisibility-spec '(my-symbol . t))
;; If you don't want ellipsis:
(add-to-invisibility-spec 'my-symbol)
However, I don't get it. How is it that you don't use (setq my-symbol "..."). What is the difference in syntax between (setq my-symbol "...") and '(my-symbol . t).
This might be a silly question but I'm not an expert or anything in Lisp and I'm playing around with Emacs configurations.
If you were to do (setq my-symbol "...") that would just set the value of variable my-symbol to that string.
What the Elisp manual is describing is the form of a specification, that is, a Lisp data structure (in this case a list) that causes certain parts of the buffer text to be invisible. It causes that behavior because such a spec is handled by Emacs automatically.
As #jenesaisquoi said in a comment, it is the C code of Emacs that does that automatic handling of the buffer invisibility spec. To use the spec, refer to the Elisp manual, node Invisible Text.
I frequently use abbrev-mode in Emacs when writing prose or just taking notes. It would be nice if there was any way to define language-specific abbreviations, e.g. if I write "proj" in an English text, it would expand to "project", whereas if I write it in a Swedish text, it would expand to "projekt". Likewise, "riskfac" would expand to "risk factor" in English but "riskfaktor" in Swedish. How to accomplish this?
It would be especially nice if this could be coupled to the ispell-dictionary that is currently used. I know there are different abbrev-tables, but these are specific to modes, not languages.
Any ideas here?
For free text, I tend to use pabbrev.el (which I wrote!) but there are several other packages which now do the same thing -- a dynamic abbreviation expansion depending on what you have already written. This tends to give a degree of language specificity in practice.
Otherwise, I think you need something to switch the abbrev tables in different buffers. Perhaps you could hook this into input methods if you are using them, then Emacs would know which language you were using.
Consider trying dynamic-completion-mode (standard library completion.el).
You can change between different dynamic-completion files, one for each language. Option save-completions-file-name holds the file name, but nothing says that you cannot change its value dynamically, e.g. using a command, in order to switch among several sets of completions. (Naturally, such a command should save to one file before switching to another.)
The "doc" for dynamic-completion-mode is in the Commentary of library completion.el. The library is old, but still quite useful, IMHO. Excerpts from the Commentary:
This watches all the words that you type and remembers them. When
typing a new word, pressing "complete" (meta-return) "completes" the
word by inserting the most recently used word that begins with the
same characters. If you press meta-return repeatedly, it cycles
through all the words it knows about.
If you like the completion then just continue typing, it is as if you
entered the text by hand. If you want the inserted extra characters
to go away, type control-w or delete. More options are described below.
The guesses are made in the order of the most recently "used". Typing
in a word and then typing a separator character (such as a space) "uses"
the word. So does moving a cursor over the word. If no words are found,
it uses an extended version of the dabbrev style completion.
(See also Icicles completion for dynamic-completion-mode.)
I had the same requirement (and am also switching between writing
English and Swedish in Emacs) and solved it by defining two modes, one
for English and one for Swedish. Both derive from a special "writer
mode" that has some useful features when I am just writing text. I have
some convenient keybindings (and even abbrevs that run code) to switch
modes/languages. Since each language has its own mode, I can keep
different abbrevs for the two languages.
Here is part of my setup:
(define-derived-mode writer-mode text-mode "W-EN"
"Writer mode."
(abbrev-mode 1))
(define-derived-mode writer-english-mode writer-mode "W-EN"
"Writer mode - English.")
(define-derived-mode writer-swedish-mode writer-mode "W-SV"
"Writer mode - Swedish.")
...
(defun writer-swedish ()
(interactive)
(writer-swedish-mode)
(set-input-method 'swedish-postfix)
(setq header-line-format " SV> ")
(setq mode-line-format nil)
(flyspell-mode -1)
(writer-setup-bindings))
(defun writer-english ()
(interactive)
(writer-english-mode)
(deactivate-input-method)
(setq header-line-format " EN> ")
(setq mode-line-format nil)
(flyspell-mode 1)
(writer-setup-bindings))
As you can see I also use an input method when writing Swedish. I have a
keyboard with Swedish letters but try to stay with English keyboard
layout since it is generally better when writing code.
I use a custom mode for a certain type of files just for syntax highlighting. But c-style indentation does not work when I load that mode. I don't want to write the rules for indentation for this mode.
Here is the link for the mode I'm using
How can I use the Emacs default c-style indentation in this custom mode?
Thanks.
c-mode installs its own parser to calculate indentation. Therefore, switching on c-indentation is not as simple as it seems to be (you cannot simply set indent-line-function and indent-region-function).
You can try the following:
(add-hook 'ned-mode-hook (lambda ()
(c-init-language-vars c-mode)
(c-basic-common-init 'c-mode "user")))
I noticed regular expressions for comments and strings in ned-font-lock-keywords. As far as I understand font-lock, this is wrong. Comments and strings are handled by the Parse-Partial-Sexp parser (see syntax-ppss) and not via regular expressions.
Furthermore, ned-mode should be derived from prog-mode and not from text-mode.