I have a file open in Emacs which highlights the syntax and I want to share the file (with syntax highlighting) with another person who does not use Emacs.
Is it possible to export the file open in Emacs with syntax highlightning?
Any target format is ok: e.g. HTML, PDF, Image
You can use the command M-x htmlfontify-buffer to create an html file with syntax highlighting from any buffer.
It's included in standard Emacs, definitely in version 24, I'm not sure about 23.
You can use htmlize-buffer that comes with 'htmlize.el' (find it at http://fly.srk.fer.hr/~hniksic/emacs/htmlize.el.cgi (dead link?) or install from MELPA or download from the htmlize Github project. This will create a HTML file with all the syntax highlighting of your current buffer.
Related
Markdown preview command doesn't work.
I installed markdown-mode.el on emacs by using package-install.
Then I created test.md file as a trial. Syntax hi-lighting apparently works fine in the text.
When I used "C-c C-c p" command in order to show markdown preview, I got following error message in backtrace buffer. Even if I saved test.md file in current directory, it still said "No such file or directory". The file is located in "~/workspace/daily_log/test.md."
I tried "M-x markdown-preview" instead of shortcut key. But it doesn't work,too.
Do I make a mistake about usage of markdown-mode? Any help would be appreciated. Thanks in advance.
Error message in backtrace buffer
Debugger entered--Lisp error: (file-error "Searching for program" "No such file or directory" "bash.exe")
call-process-region(1 36 "bash.exe" "/tmp/emacsAxnXZ9" #<buffer *markdown-output*> nil "-c" "markdown")
shell-command-on-region(1 36 "markdown" "*markdown-output*")
markdown("*markdown-output*")
markdown-preview()
call-interactively(markdown-preview nil nil)
command-execute(markdown-preview)
my environment
OS: Ubuntu 14.10
emacs: 24.4.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.12.2)
markdown-mode: markdown-mode-20140914.1012/
If you inspect the backtrace you'll see that this has nothing to do with your Markdown file.
markdown-preview needs an external markdown command that can generate HTML. It looks like whatever Markdown processor you are using is trying to call bash.exe (not bash) when converting your file.
You might have installed some Windows-centric Markdown converter.
You might have customized markdown-command, directly or indirectly causing it to call bash.exe.
Since you are on Ubuntu, a simple apt-get install markdown should give you a decent Markdown that works with markdown-mode's markdown-preview function. After installing markdown at the system level, make sure that Emacs has markdown-command set to markdown (the default value).
I use GNU Emacs in a Mac. After installing the last version of Pandoc I can't create pdf files. Pandoc works well when I use the Terminal. I think that the problem has to do with the fact that Emacs doesn't find the template default.latex. This template is in my ~/.pandoc/templates.
This is the error message I receive when trying to create a pdf:
pandoc: /usr/local/share/pandoc-1.10.1/data/templates/default.latex: openBinaryFile: does not exist (No such file or directory)
I don't understand why Emacs is trying to find default.latex here.
(setq pandoc-binary "/usr/local/bin/pandoc")
This answer assumes you do not have a folder named pandoc inside of /usr/local/bin/ and that the actual executable has an absolute path of /usr/local/bin/pandoc. If the executable is buried deeper in another folder or more, then adjust the path in this example accordingly. The code at the top of this answer goes in your .emacs file.
You may also wish to modify this variable depending upon your preferred setup:
(setq pandoc-data-dir "~/.emacs.d/pandoc-mode/")
You could achieve a more general solution using exec-path-from-shell:
A GNU Emacs library to ensure environment variables inside Emacs look the same as in the user's shell.
Just install it, require it (only if your aren't using MELPA) in your .emacs file and add this line to it:
(exec-path-from-shell-initialize)
For more information see the usage section in the README.
When I use org mode in emacs to export to latex and pdf file I have a problem. When I export to latex file, it's OK. but when I process latex file to export PDF file, I have this error:
Process completed with errors: [undefined control sequence] [LaTeX error]
Please tell me, how I can fix it.
You have to look at the .log file, if any, in the same directory (where the LaTeX compilation occurred).
Best (IMHO) is to compile the TeX file directly (using AUCTeX, if within Emacs), and to have a finer control on what's going wrong in the LaTeX route.
In Emacs 24 (maybe even in earlier versions) there is variable called org-latex-remove-logfiles, by default it is set to on, toggle it to off and latex will keep the log files.
To get to it, in Emacs do
M-x RET customize-variable RET org-latex-remove-logfiles
I'm having some problems with flymake-mode when editing latex files in emacs 23.4.1. First, when I start the mode I see Flymake:! in the mode line. The manual tells me this is because "Flymake was unable to find the master file for the current buffer.", but it doesn't suggest a solution. apropos tells me there is a function TeX-master-file-ask so I call it to set the master file and try flymake-mode again, but now it gives an error about .#file.tex not being found, but the file does exist.
How can I get flymake mode to work when editing latex files?
Try adding this to your .emacs:
(setq flymake-allowed-file-name-masks
(delete '("[0-9]+\\.tex\\'"
flymake-master-tex-init
flymake-master-cleanup)
flymake-allowed-file-name-masks)) ; don't use multipart tex files
By default (Flymake .3), Flymake tries to be smart about multipart .tex files it assumes that if your .tex file ends in a number then you must be working on a multi-part file.
I personally find this behavior annoying since I like to work on files named assingment1.tex and similar. However, by default, Flymake then assumes that there is an assignment.tex master file, and I get stuck with the Flymake:! behavior you describe.
Adding the above block to your .emacs will disable this behavior.
I found this website and downloaded the color-theme files.
It says:
Put the file color-theme.el and the
folder “themes” (with the files
color-theme-example.el and
color-theme-library.el) in a directory
on your LoadPath.
and then I checked the load path website, which says:
To add a single directory to the load-path:
(add-to-list 'load-path "~/.emacs.d/site-lisp/")
My question is, where do I type this line?
If I do M-x and then type, it complains add-to-list[No match].
By the way, I am using Emacs 23.2(9.0) on Mac, a GUI version.
For the text version on terminal, I use black background seems fine, except the blue is too dark on black
An answer for newbs like me!
In Emacs 24.5.1, on mac or linux the following will work.
The following command will create a folder called themes inside your .emacs.d folder (assuming one does not already exist)
mkdir ~/.emacs.d/themes/
Now tell emacs that you have installed a themes folder. In emacs open your .emacs file, by typing the following:
C-x C-f ;;;this opens a new .emacs file or creates one if it doesn't exist
Add the following line to your .emacs file:
(add-to-list 'custom-theme-load-path "~/.emacs.d/themes/")
Now copy your theme's '.el' file to your .emacs.d/themes/ directory. A good place to find custom themes is here: emacsthemes.com
Now load your custom theme by typing the following:
M-x customize-themes ;;;now press return
Your newly installed themes should appear on the list like so:
Move your cursor to within the '[ ]' and press return to select that theme.
Enjoy emacs!
You can download Emacs 24 for Mac from here and Emacs 24 already has a built-in theming system. You can call it by M-x customize-themes and choose whatever themes you like. And you can find much more themes online. There is actually a quite nice theme called "solarized", you can use it both in GUI and command line.
I load color theme by this code:
(load-file "~/.emacs.d/color-theme/themes/zenburn.el")
(zenburn)
You should put that line in your init file. This is usually the file ~/.emacs. The .emacs.d directory is a conventional directory for storing your personal customization files. Many of the instructions for installing packages (like color theme) or explaining other parts of Emacs (like the load-path page) assume you understand the init file.
.emacs and .emacs.d are really at the core of Emacs customization. If you read up on those, Emacs will make a lot more sense. I hope that helps!
In emacs 23, I thought color theme is installed by default. If not, and you need to add that line, write it in either file ~/.emacs.d/init.el, ~/.emacs.el or ~/.emacs