Emacs indent-for-tab not indenting javascript in my html file - emacs

There are two issues with tabs in Emacs Live right now.
The first is that I have HTML in a script tag and the auto-indentation level is the same.
void setup() {
size(930, 630);
smooth();
...
When I hit tab it doesn't move anything anywhere unless its at the tab stop ( i believe that's the word ). It makes it to be in line with the html tag.
<tag>
<script>
if(k){
console.log('cant indent past this');
}
</script>
</tag>
The second is that when I backspace, it moves one to the left at a time which makes me assume that spaces are being used and not tabs.

Perhaps you want to use mmm-mode.
First, install mmm-mode from your package-manager. Run M-x list-packages then find mmm-mode and install it.
Then, open your .emacs or init.el file and add the following elisp snippet.
(load-library "mmm-auto")
(add-to-list 'mmm-mode-ext-classes-alist '(html-mode nil html-js))
Customize variable mmm-global-mode to maybe by M-x customize-variable <RET> mmm-global-mode and set it to maybe.
Restart your Emacs and open an HTML file that contains JavaScript source.

Related

Why doesn't modifying the .emacs file change the behavior of GNU Emacs?

I'm running GNU Emacs 24.3.1 on Windows 7. As mentioned in this manual page, I can type
C-x d ~/ RET
to determine the location of my home directory. In my case, Emacs returns:
e:/EmacsDocs
which, according to Windows Explorer, indeed contains a file .emacs. When I open .emacs with Emacs, the file appears to be empty.
Now, I want to set Emacs so that it is in overwrite mode by default. According to this page, that can be done by adding the following to .emacs:
(setq-default overwrite-mode t)
But when I make this change to .emacs and close and reopen Emacs, Emacs does not overwrite when I select text and start typing. (Rather, it still operates in insertion mode, with new characters inserted before the cursor.)
I also tried, for example, adding this command to .emacs, which according to this page will disable cursor blinking:
(blink-cursor-mode 0)
but again, there is no change when I restart Emacs.
How can I tell if Emacs is actually reading the .emacs in the home directory (upon restarting Emacs)?
You are confusing what Emacs calls overwrite-mode with the requested behavior "overwrite when I select text and start typing".
In Emacs, the latter behavior is called delete-selection-mode, and overwrite-mode means that when you type text (without selecting anything), any existing text that follows the cursor is overwritten by what you type.
Most Emacs users do not turn on overwrite-mode by default, and they just hit the insert key (typically to the left of the home key) to toggle `overwrite-mode on/off when they need/want to.
One way to turn on delete-selection-mode by default is to put one of the following in your init file (.emacs):
(setq delete-selection-mode t)
or
(delete-selection-mode)
Another way is to customize the option delete-selection-mode using M-x customize-option RET delete-selection-mode RET and save the customized value.
Instead of editing the file outside of Emacs, just type
C-x C-f ~/.emacs
and add your configurations there. Save with
C-x C-s
and restart. This should work, since ~ in Emacs defaults to the home directory.

How do I turn off autopair when I paste into Emacs from another program?

If I C-c on some other program (lets say a terminal, or a web browser) and then C-v into Emacs, autopair sometimes creates extra parentheses or brackets that I don't want. How do I restrict this from happening when I am copy pasting external text to Emacs? My relavent lines in my init.el file are:
(require 'autopair)
(autopair-global-mode 1)
(setq autopair-autowrap t)
If I understand correctly, you're pasting into an Emacs running inside a terminal emulator. In that case, the paste really sends the pasted chars as if they were key-presses, so weird things can happen (e.g. when pasting into a Dired buffer).
For what it's worth, Emacs-25 supports "bracketed paste", which is a special functionality of "recent" xterms in which those terminals send pasted text surrounded with special escape sequences, so Emacs can know that it's a paste.
In other words, this problem should be fixed in Emacs-25.

emacs orgmode -- how to export html file to other directory instead of the same directory with .org file

emacs 24.2.1 and org mode version 8.0.3,Although I have referred to the resolution in Emacs Org-mode - Export to another directory?, add below statement to the .org file directly. after pressing C-c C-e h o,the .html file still come to the current directory.
#+bind: org-export-publishing-directory "~/org/exported_html/"
and i have also tried to add below statement to .emacs file. but still not work out what i want.
(setq org-export-publishing-directory "~/org/exported_html")
anyone who can give me an advice? thanks.
The var you're using is for publishing. What you do with C-c C-e is exporting (unless you then press P or such for publishing "projects"). I think your Org file must be part of a project, and then your variable would make sense. Not 100% sure, to be further tested.

Can I include lisp code in a text file to be executed when Emacs loads the file?

Is there a way to add lisp code, preferably in a comment, to be executed by Emacs when it loads that file?
Specifically, I want to turn auto-fill mode off for specific LaTeX files. I know something like this can be done with a mode hook, but I don't want to do it for all LaTeX files.
The way AUCTeX for Emacs stores file-specific settings in a comment at the end of edited files leads me to suspect that something like that can be done with a general snippet of lisp, such as (auto-fill-mode 0) in a comment at the start or end of a LaTeX file.
M-x add-file-local-variable RET eval RET (auto-fill-mode -1) RET
This will add a comment at the end of the file, using the appropriate comment syntax. eval can contain any lisp form, but will ask to confirm for some.

make Org ignore underscores when exporting to HTML

I use Emacs Org-mode to write some documents, and I describe some files like “/path/to/file_blah.conf”.
After I hit c-c c-e h to export one of those files to HTML, all the filenames in that file containing _ become small subscript words.
How can I make Org-mode ignore the underscores, so that I can see the filenames on the HTML page?
Duplicated as Disabling underscore-to-subscript in Emacs Org-Mode export
(setq org-export-with-sub-superscripts nil)
in .emacs or
#+OPTIONS: ^:nil
in org file.
on top of your file put the following line and save. reopen the file or hit C-c C-c on that line
#+OPTIONS: ^:nil
BTW: what is there in your org-emphasis-alist. C-h v org-emphasis-alist. You might need to edit that to achieve output to your liking
Another solution should be to correctly markup the paths, so:
Open the file =/path/to/fileA= or ~c:/path/to/fileB~.