Questions tagged [major-mode]

The mode that determines the editing behavior of Emacs while that buffer is current. The mode line normally shows the name of the current major mode, in parentheses.

Filter by
Sorted by
Tagged with
5
votes
1answer
139 views

Using a different major mode in comments

A programming language that I use lets me format comments and docstrings using markdown, and then export my code and documentation to PDF. When I edit the file, though, Emacs doesn't see comments as ...
5
votes
1answer
249 views

How can I make emacs ignore part of the file name when deciding major mode?

If you have a GPG-encrypted file, say notes.org.gpg, emacs figures out that the major mode has to be set to org-mode. This applies in general to any major mode out there; you do not need to modify the ...
5
votes
2answers
914 views

How to set major mode according to buffer name for non-file buffers

Some buffers are created by emacs and is set in fundamental mode, like the Org-Babel results. I think it is more convenient to set them in special mode, which can be closed with key q. How do set the ...
16
votes
4answers
6k views

Automatically formatting SQL code

There are some general well-known coding standards and styles for SQL (e.g. capitalizing reserved words, placing main keywords in different lines, etc.). Does Emacs come with any modes for this, or ...
3
votes
1answer
192 views

Why doesn't electric-indent-mode indent in comments?

I've defined my own major mode using define-generic-mode, and in the setup function I have (set (make-local-variable 'indent-line-function) 'my-indent-function). This works fine in general code, ...
1
vote
2answers
98 views

add-hook unable to reassign a mode-specific keybinding

I'm attempting to override a mode-specific keybinding, but my attempt so far hasn't been able to reassign it. I use the M-j,k,i,l to navigate instead of the regular C-n, C-p etc. I find it to be a ...
1
vote
2answers
480 views

How to detect mode, then execute?

I'm currently using autoheader. I have this configuration, which causes the <?php tag to be inserted in other modes: (defsubst my/header-title () "Insert buffer's first row." (insert "<?...
17
votes
2answers
10k views

Run command when opening a file of a specific filetype

I'm trying to get a lisp script to run some commands for me when I open a file of a specific filetype. I know that I'm working in the correct init file because if I remove the theme from it, emacs has ...
7
votes
1answer
205 views

How do I find the code for the current major mode?

How do I find the elisp code for the major mode in use in the current buffer?
10
votes
2answers
856 views

Remember modes for files without extensions

I've started editing a lot of files that have no extensions, but are still in a major mode format. I'm the only Emacs user on the team, and I don't want to make it a painfully obvious that my editor ...
8
votes
2answers
3k views

How to change comment character from # (hash) to % (percent sign) for Octave major mode

By default, comment-region inserts # for comments in Octave major mode: # foo I want to modify the behavior so that it inserts the percent sign % foo I used the following (setq octave-mode-hook ...
1
vote
2answers
212 views

js-comint mode (node) returning too many undefined responses?

I am using js2-mode and comint-mode to run the Node REPL in emacs. For some reason the prompt is returning a lot of undefined and ...undefined responses, which it wouldn't do normally. for instance, ...
4
votes
1answer
185 views

How to specify the buffer mode on the command line?

I want to open a file in makefile-gmake mode. Is there a way to do this from the command line? I'm looking for something like: $ emacs -m makefile-gmake filename I do not want to change any config ...
0
votes
1answer
185 views

Tie a minor-mode to a particular major mode

I'm writing an extension to a major mode (coq-mode) that adds extra features, plus a few keybindings. To makes it easy to disable or redefine these keybindings, I packaged them in a keymap. That ...
2
votes
1answer
114 views

How can I tell if a buffer is a comint buffer, eshell buffer or neither?

I have Emacs Lisp program that I want to work inside either a comint process buffer or an eshell buffer. The code I currently am using is: https://github.com/rocky/emacs-dbgr/blob/master/realgud/...
1
vote
1answer
131 views

Why is cperl-mode-hook running twice?

I am using cperl-mode to edit Perl scripts. According to the Emacs wiki ( link ) one could use defalias to use cperl-mode instead of perl-mode. Here is an example: $ emacs -Q -l init.el test.pl & ...
7
votes
3answers
448 views

permanently change buffer mode of a file?

Beginner question: In OSX 10.6.8, Aquamacs has many buffer modes. My .tex files open in TeX mode, but I would like to open them in LaTeX mode. I can change the Mode with "Change Buffer Mode", but ...
5
votes
1answer
2k views

js2-mode on, still emacs hunts for javascript-mode

I enabled js2-mode in emacs by adding this snippet in .emacs, (add-to-list 'auto-mode-alist '("\\.js$'" . js2-mode)) But still for .js files, emacs tries to load javascript-mode alias js-mode as ...
1
vote
1answer
187 views

Major mode map in emacs

How to print, all file extensions & the mapped major modes (and possibly minor modes...) in emacs? like this, *.js js-mode *.json js-mode *.c c-mode Which global map variable contains ...
11
votes
1answer
3k views

Why does *compilation* buffer show control characters?

I'm using the *compilation* buffer to build a C++ application on Centos 5 and Centos 6. The buffer shows the build and includes references to files that are part of the build. However, I'm getting ...
0
votes
1answer
261 views

Visual Basic mode doesn't work after update

I'm on Windows. I updated my emacs to 24.4. Now, when trying to open a file that has its extension mapped to the Visual Basic mode at http://www.emacswiki.org/emacs/visual-basic-mode.el, I get these ...
1
vote
2answers
342 views

How to define key bindings for major mode extensions?

I am writing some extension features for various major modes. The features are (as usual in Emacs) some functions that should be bound to some keys to simplify the workflow of the user. I started ...
6
votes
1answer
820 views

Is possible to execute a key binding in a function?

Say, the C-M-j is bound to c-indent-new-comment-line for c-mode (and c++-mode) and indent-new-comment-line for other modes, but I want to define a function that will execute C-M-j to c-indent-new-...
6
votes
3answers
704 views

Turn a non prog-mode derived major-mode into a prog-mode derived major-mode

erlang-mode is not a derived prog-mode. Is there any way to make it part of the prog-mode-hook ?
1
vote
2answers
78 views

Enable mode association with backup files as well

I want to enable mode association with backup files as well. E.g., if I backup my my-markdown.md file as my-markdown.md.orig or my-markdown.md.lastweek etc, I want them still be associated with the ...
1
vote
1answer
59 views

emacs major mode for INF files

Is there a major mode for .inf files (https://en.wikipedia.org/wiki/INF_file)? If there is one, it's proving to be most unGoogleable.
6
votes
2answers
935 views

CSS code completion as in Firebug

One of the convenient features of in-browser inspectors like Firebug is that it is so easy to tweak CSS stylesheets. As you type in the attribute position, all possible attributes are shown in a ...
8
votes
2answers
702 views

Make buffer read-only on a per-file basis

I know I can set something like -*- mode: read-only-mode -*- inside a commentary and Emacs will open the corresponding file as read-only. My problem is that I still want to read files that include ...
11
votes
2answers
330 views

Use two major-mode-maps in the same buffer

I've run into a few situations where it would be highly convenient to have to have the keymap of one major-mode act as a fallback keymap for another major-mode. For instance: I write a lot of LaTeX ...
4
votes
2answers
192 views

How do I handle multiple string delimeters in a major mode?

I'm trying to write a major mode for a language that supports normal strings and triple-quoted strings ("foo" and """foo"""). (defconst my-string-mode-syntax-table (let ((table (make-syntax-table)))...
10
votes
2answers
385 views

Why don't major modes just inspect the faces?

When writing a major mode, it's often useful to know 'is point in a string?' 'is point in a comment?'. Most major modes seem to attempt to parse the programming language. For example: python-syntax-...
20
votes
2answers
5k views

Using a different font for each major mode

Is it possible to set different fonts following the major mode? Say Inconsolata-12 in org-mode buffers and Symbola-12 in all remaining modes. Or at least, is it possible to do a (set-frame-font "...
0
votes
1answer
99 views

Is there a mode for phpBB?

I'm using the "It's all Text" addon for Firefox so I can edit textarea's in Emacs. As I spend some time on a phpBB forum, I was wondering if there is an Emacs mode for phpBB with it's syntax of using [...
6
votes
1answer
371 views

hierarchy of modes

I am aware that org-mode derives from outline-mode, in the same way as outline-mode derives from text-mode, which derives from nil. I have always wonder if there exists something similar to a ...
7
votes
1answer
839 views

Specify major-mode for files with multiple extensions

In my .emacs file, I have: (setq-default major-mode (lambda () (let ((buffer-file-name (replace-regexp-in-string "\\.tmp$" "" ...
5
votes
3answers
139 views

elisp: retaining data structure after inserting string representation to buffer?

I'm currently writing a major mode (for interacting with a remote Grid Engine) which involves fetching data, parsing it into an alist, formating the alist into a string and then inserting the ...
14
votes
6answers
946 views

how to get buffers (not just files) to honor auto-mode-alist?

Q: how can I get new buffers to honor the mapping in auto-mode-alist? When finding a file, Emacs compares the file extension to the auto-mode-alist to determine which major mode to use for the file's ...
63
votes
8answers
2k views

How can I use Emacs to edit questions, answers, and comments here?

Emacs as a StackExchange client? How can I use Emacs to edit questions, answers, and comments here on the Emacs Stack Exchange site? Broadly, what possible methods exist? Kill and yank This works, ...
2
votes
1answer
1k views

Filter Helm buffers by mode in ibuffer

When I try to filter buffers by mode in ibuffer, I am not able to filter by major mode helm-mode. For example, MR Name Size Mode -- ---- ---- ---- * *helm apropos*...
7
votes
3answers
838 views

What's the difference between words and symbols?

When defining a syntax table for a major mode, I can define both word constituents and symbol constituents. When should I use each? For example, given a programming language that writes variables in ...
13
votes
4answers
562 views

Differences between setting major mode keys with a hook versus adding them to the mode map

Assume that I have downloaded a major mode called magical-mode, and it has its own magical keymap called magical-mode-map. This mode also provides a hook magical-mode-hook which is run each time ...
10
votes
4answers
389 views

How do I inherit from prog-mode, whilst still supporting older emacsen?

I'm writing a major mode for a programming language, but I want to support older Emacs versions. prog-mode is relatively new. I want to inherit from prog-mode if it's defined, but still do something ...
3
votes
5answers
680 views

How to get a major mode to open full screen

I'd like magit to default to a large buffer instead of one that is half the size of the available space. Even better would be a way to wrap the call to a major mode to make this happen when opening ...
58
votes
7answers
27k views

How do I list all key-bindings available in a given buffer?

I am trying out a new major mode, how can I take advantage of Emacs' documentation system to get a listing of key bindings available in that specific buffer?
24
votes
1answer
3k views

How do I automatically load a mode for a specific set of file extensions?

I'd like to load the yaml-mode for any files named *.yml or *.yaml.
50
votes
5answers
12k views

How to override major mode bindings

Sometimes my global keybindings are overridden by a major mode. An easy example is the following setting in my init file (global-set-key (kbd "C-j") 'newline-and-indent) But annoyingly this ...
8
votes
1answer
443 views

How do I create a simple syntax table for a major mode?

I'm trying to understand how syntax tables work, but my minimal major mode doesn't highlight anything. I've written the following elisp, which is just supposed to highlight comments: (defconst my-...
23
votes
1answer
975 views

How can I quickly toggle between a file and a *scratch* buffer having the same major mode?

At times while working on a code, it's useful to quickly open a *scratch* buffer to paste a snippet from that code file. If I am working on a Perl script, I would like to quickly open a *scratch* ...

1 2 3 4
5