C-h b will list all the bindings available in a buffer. This is a mnemonic for help (C-h) bindings (b).
You can also get a list of keybindings via C-h m, which is help for the major and minor modes for the buffer. The formatting of this is a little clearer, but includes additional information about the modes beyond just listing the keybindings.
There is a "shortcut" approach too for the same solution if you don't want to define your own minor mode (that I talk about in my first answer).
You can install the use-package package available from Melpa and make use of bind-key* or bind-keys* macro that's part of the bind-key package that ships with use-package.
From the documentation of bind-key.el:
See the Stack Exchange for Emacs project. From their page:
SX will be a full featured Stack Exchange mode for GNU Emacs 24+.
Using the official API, we aim to create a more versatile experience
for the Stack Exchange network within Emacs itself.
You can define your own minor mode and its key map and have that override all other modes (minor + major). That's exactly why I chose to write my own minor mode.
Steps to have your key bindings override all bindings:
Defining your own minor mode and key map as shown below.
Activate your minor mode globally
(define-key my-mode-map (kbd "C-j") #'newline-and-...
I use the command helm-descbinds, which is available via melpa. I mapped it to C-h b because it is basically a drop-in replacement for describe-bindings. The benefit is that it is easier to navigate and search than the output of describe-bindings because you can easily search for keywords and the helm buffer will narrow to show all of the matches, and ...
It will be convenient to bind the below function to a key binding of your choice.
If you are currently working on a FILE buffer, calling the below function will toggle between FILE's major-mode specific *scratch* buffer called *scratch-MAJOR-MODE* and the FILE buffer.
Given the example in question, if I am working on a Perl script called myperl.pl, calling ...
buffer-face-set and buffer-face-mode in Emacs 23 or later is designed for exactly this. From the Emacs wiki:
;; Use variable width font faces in current buffer
(defun my-buffer-face-mode-variable ()
"Set font to a variable width (proportional) fonts in current buffer"
(setq buffer-face-mode-face '(:family "Symbola" :height 100 :...
Add these lines to your .emacs file:
(add-to-list 'auto-mode-alist '("\\.ya?ml\\'" . yaml-mode))
The auto-mode-alist is a variable which emacs consults whenever a new file is opened. You can add mappings between filename patterns and major-modes.
You can find out more about how Emacs determines which modes to load for a given buffer ...
The API completion at point function can be found in the documentation of completion-at-point-functions
Each function on this hook is called in turns without any argument and
should return either nil to mean that it is not applicable at point,
or a function of no argument to perform completion (discouraged), or a
list of the form (...
In Emacs terminology, these are two different steps:
Associate files with the .ts extension with the major mode typescript-mode.
Run the function tss-setup-current-buffer when Typescript mode starts.
To choose which major mode to use for certain file names, add an entry to the variable auto-mode-alist. Put the following line in your init file:
The full syntax for specifying file extensions for gnuplot-mode is:
(add-to-list 'auto-mode-alist '("\\.g\\'" . gnuplot-mode))
The other point to verify is that you are using Bruce Ravel's recent (year 2012) implementation of gnuplot-mode. This is a separate MELPA package that requires gnuplot version 4.4 and higher.
Lastly avoid gnuplot-mode files that ...
Doing again an M-x org-mode does not turn it off.
This convention is for minor-modes - Doing a M-x "minor-mode-name" again disables that minor mode. org-mode is a major mode. When you do this, emacs has no clue which major mode to go into. There must be a major mode always active.
So, rather than disable org-mode, you have to think in terms of which major ...
The second approach is preferable as it modifies the mode's keymap just once.
If you do it using the mode's hook then that will be called every time that mode is enabled in some buffer. Doing so again usually won't actually have an effect because the keys are just again bound to what they are already bound to. Major mode keymaps are "local" to the major ...
These are indeed escape sequences which the terminal should interpret as orders to change the text color. Normally they shouldn't be used when the compiler is invoked from Emacs (the terminal type should be set to dumb, which should cause the compiler to refrain from using any escape sequence). There may be something wrong in your configuration that causes ...
When you use M-x find-file-literally Emacs will not invoke a mode that is based on the file name. Instead, it uses fundamental-mode as the major mode.
From the command line you can use something like this:
emacs --eval '(find-file-literally "yourfile.ext")'
There are a number of ways to identify the major mode for a file that don't rely on an extension, see Choosing File Modes in the manual.
Depending on the kinds of files you are dealing with, perhaps you could use the magic-mode-alist. Also note that auto-mode-alist is not limited to matching extensions: you can match any part of the file name or path.
C-h m gives you help on the current mode, and it typically tells you the name of the command that turns the mode on.
For example, in Emacs-Lisp mode C-h m tells you that you are in Emacs-Lisp mode. The command that turns the mode on is just emacs-lisp-mode.
C-h m also provides a link to the library that defines the mode, and if you click on that link it ...
The problem is that it is not more robust.
Firstly, the major modes are precisely the ones responsible for deciding what's a comment or a string. If they were able to successfully define them for the purpose of font-locking, they should be able to do the same for other purposes.
Secondly, reading the syntax to determine the context that point is inside is ...
This turned out to be simpler then expected. As suggested in the comments here and on the question:
(make-composed-keymap (cl-copy-list erc-mode-map)
This will create a keymap which is a copy of erc-mode-...
edit-server might be of some help. It lets you edit any text field inside Chrome with Emacs and then send the text back to the browser with minimum effort. Not exactly what you wanted, but its an improvement.
At the cost of an extra top-level symbol binding, there's a very neat solution which avoids repeating the define-derived-mode form:
(if (fboundp 'prog-mode) 'prog-mode 'fundamental-mode))
(define-derived-mode my-fancy-mode my-fancy-parent-mode
Works fine in any Emacs >= 23. I came up with this for haml-mode a ...
The variable major-mode will be set to a symbol describing the mode.
If the mode was written anytime in recent history, that symbol will be a function that activates the mode.
So you can simply "find" the major mode's code.
Or interactively, run M-x describe-mode and click the link to the source file.
Emacs modes are established for each file you open, so opening Emacs in "nothing mode" doesn't necessarily accomplish what you're after. Each file you open after starting Emacs will get its own mode applied.
You can use the command @clemera provides to open a file in fundamental mode from the command line. You can do the same from an already-running Emacs ...
Although not the canonical emacs way of doing things, I quite like using discover-my-major for that purpose because it just feels more effective.
It is available on melpa and is powered by the makey library, which is responsible for those nice menus magit is known for.
I'd suggest you check out the github link for a screenshot demonstrating the ...
The auto-mode-alist variable does what you need. Never bind anything to the major-mode variable.
The documentation explains how you can set major-modes per file extension and, most importantly, it explains how to treat multiple extensions.
Alist of filename patterns vs corresponding major mode functions. Each element looks like (REGEXP . FUNCTION) or (...