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
1k views

How can I change which shell script mode I'm in?

Occasionally, emacs opens a file in shell-script[fish] when I want it to open in shell-script[bash]. How can I manually change the subtype of shell-script mode that I'm in?
5
votes
2answers
681 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 ...
5
votes
1answer
285 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 ...
5
votes
0answers
236 views

How to read wikipedia in Emacs

Is there a simple mode for the reading of wikipedia through Emacs?
4
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 ...
4
votes
3answers
415 views

How can I create mode-local variables?

I'm looking to create a command which stores a kind of "history" for the current major-mode. I need the variable to be independent for each major mode, but consistent across all buffers in any ...
4
votes
1answer
223 views

Why isn't emacs-lisp-mode derived from lisp-mode?

Just out of curiosity, why isn't emacs-lisp-mode derived from lisp-mode? Instead, both are derived from prog-mode. It seems to me that there is a natural hierarchical relationship that should exist. ...
4
votes
1answer
968 views

Change the default mode used when opening a new buffer

For example, we can open a new buffer with C-x b <new-buffer-name>, and by default, this new buffer opens in fundamental-mode, which is not very useful to me. I would like to change this to open ...
4
votes
1answer
160 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 ...
4
votes
2answers
364 views

sh-script alignment issues

I'm sure emacs used to do it my way, but things appear to have changed (probably years ago, I've just been living with the pain). I want this (to conform to corp. standards): MULTIFORM=$( curl -...
4
votes
1answer
460 views

nxhtml mode support

I've been using https://stackoverflow.com/a/17761144/788700 to get multiple major modes in rst-mode. It has been working in Emacs 24.3. However as emacs develops the same code gradually stops working. ...
4
votes
1answer
78 views

How should I test my new mode?

I am trying to create a new mode for Emacs lisp, let's call it xyz-mode.el. In testing the mode, I want to re-run xyz-mode.el on a potential target file, let's say abc.xyz. In other words, as I edit ...
4
votes
2answers
432 views

Which mode is best for a special configuration file, specifically logstash

I'm using logstash and its configuration file (documented here) looks like this: input { file { path => "/some/path/to/file" option => 1 } } filter { if [var] == "string" { ...
4
votes
1answer
148 views

Package for inline editing in another major mode

I work a lot with Typescript files for Angular 2. The whole HTML structure is packaged in a quote. I would like to select that quote, and edit it in another mode (HTML/Web mode), then save it back to ...
3
votes
2answers
2k views

Use-package for a mode

it's not clear for me how should I set use-package to load a package when a mode is activated. I have read different things about :mode, :init :config and I am now confused. Could someone explains it ...
3
votes
5answers
461 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 ...
3
votes
1answer
495 views

How to define “mode-specific” functions?

How can I define an Elisp function such that it is available only under a specific mode? (FWIW, at the moment, the mode I want to restrict a function to is comint.)
3
votes
2answers
6k views

How to compile and run a C++ file? [closed]

I don't know how to compile and run a C++ file in GNU Emacs. I searched on the various sites and stackexchange network, but from them what I understood was write something like make compile, and I don'...
3
votes
2answers
42 views

SMIE Basic Identation and Block Example

I've tried for a while to create a simple major mode that uses SMIE to perform navigation and indentation, but it seems like even the simple examples that I've found seems to break quite easily. The ...
3
votes
1answer
47 views

Why won't `emacs -nw -f org-mode foo` open `foo` in `org-mode`?

I want to open a file foo in org-mode on the terminal. However, Issuing emacs -nw -f org-mode foo opens foo in Fundamental mode. What's wrong with my command?
3
votes
1answer
88 views

How to check if a major mode derives from another?

Is it possible to check if a mode is derived from another mode? eg: (member major-mode '(c-mode c++-mode glsl-mode)) Could be replace with something like this: (does-mode-derive-from major-mode cc-...
3
votes
2answers
60 views

When writing a new major mode, should it add itself to auto-mode-alist?

I am defining a new major mode, foo-mode, which is closely and only associated with .foo files. Should foo-mode.el fiddle with auto-mode-alist to add this association, or is that the user's ...
3
votes
1answer
131 views

Set “Edit with Emacs” major mode to markdown-mode

I'm using Edit with Emacs to edit Stack Overflow and Stack Exchange sites. Currently I'm doing it with this message ;-) When I click on the button under the text area of Chrome browser, I get a new ...
3
votes
2answers
129 views

How do I disassociate a filetype and mode?

I think the Change Log mode in emacs (spacemacs) acts crazily and I want to turn it off when editing my CHANGELOG. How do I do that for good?
3
votes
1answer
210 views

Derived mode without merging keymap

It seems that when using define-derived-mode, the new mode's keymap is merged with that of the parent mode. Is there a way to avoid this? That is, to inherit font-lock, etc. from the parent mode, but ...
3
votes
1answer
96 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 ...
3
votes
2answers
84 views

ANSI / xterm font-locking

I have a buffer with terminal escape codes in it and I want them to be colored: I was able to do this with (ansi-color-apply-on-region (point-min) (point-max)): However, my file is really big and ...
3
votes
1answer
187 views

Folding code between a literal “begin”/“end” block using Hideshow

A formatted input file (*.alm) often contains a large section of columned data. To fold this and improve navigation, I've tried to implement a hs-special-mode-alist entry from hideshow.el. (setq hs-...
3
votes
1answer
102 views

Vector literal indentation

I want to write my emacs-lisp-mode modification which respects some of my preferences. In particular, I want to override indentation for vector literals. Emacs treats vector literal as quoted list ...
3
votes
2answers
906 views

How to customize major mode initialization with local variables?

Seems like most major modes clear all local variables before initializing. It also seems like many major modes read variables while initializing to customize their behavior. If I want to set a file ...
3
votes
1answer
290 views

Is it possible to achieve erlang formatting like this?

As I was going through learnyousomeerlang I came across code formatted like so: if X > Y -> a() ; true -> b() end Presently As close as I can get is: if X > Y -> a() ; -...
3
votes
2answers
613 views

Git commit uses fundamental mode after magit update

I recently updated magit to 20151025.1115, which gave me a message about git-commit-mode incompatibility. I now, instead, have a package git-commit at version 20151022.933 (from the magit project) ...
3
votes
2answers
166 views

File-local variable to force specific shell for shell-script major mode

I'm having the same problem as asked in this question: emacs is dropping into shell-script mode, but for the wrong shell variant. Using a shebang as suggested in that question's answer is ...
3
votes
1answer
163 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, ...
3
votes
0answers
100 views

Can twittering-mode be used with GNU Social, and if so, how? If not, any alternatives?

I have an account on GNUSocial, and I want to be able to control it from Emacs. However, I haven't found a way to do so yet. I can control my Twitter just fine through twittering-mode, and was ...
2
votes
2answers
190 views

Enable mode if file content contains a matching string

I would like to enable rjsx-mode whenever a file I open contains a specific string, or a regex like import.*react for example. Is there a way to do something like this in emacs?
2
votes
1answer
421 views

How do I force a mode on a specific file through special comments

I have a file called zshrc (not .zshrc). Emacs does not recognize that it must use sh-modeautomatically. I want to put some sort of hint for emacs to pick up and syntax highlight my file accordingly. ...
2
votes
2answers
106 views

How to make all variables and functions of a mode visible without activating the mode

Let's say I want to customize a keybind for a mode that hasn't been loaded yet like so: (define-key eshell-mode-map (kbd "C-M-i") 'eshell-previous-input) But the problem is if I haven't yet loaded ...
2
votes
2answers
192 views

Why is the . needed for adding suffixes to the 'auto-mode-alist?

In https://www.emacswiki.org/emacs/AutoModeAlist one needs to use this command in order to add .py for python-mode (add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode)) Why do we need the . ...
2
votes
1answer
921 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*...
2
votes
1answer
393 views

How to prevent line wrapping in code, but allow it in help/info buffers?

I'm quite new to emacs (coming from vim), and I'm struggling to figure out how to configure sane line-wrapping/truncation behavior. For the most part, I'd like to prevent wrapping, so I put this in ...
2
votes
1answer
742 views

Scratch always starts in fundamental mode

I don't know what change in my configuration caused this, but scratch buffer always starts in fundamental-mode. I would like to have emacs-lisp-mode in the scratch buffer. I tried to do (setq initial-...
2
votes
2answers
277 views

Create new major mode from cc-mode that allows comments with two dashes

It is possible and relatively easy to create a new major mode, deriving from c-mode, and just add two dashes '--' to work as comments too? I have checked many resources, but couldn't find anything ...
2
votes
1answer
102 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/...
2
votes
2answers
155 views

How to load an Idris file that depends on a package?

Working in Spacemacs (on Linux Mint, if that is relevant), using the Idris layer, one of my major mode commands is SPC m-r (Vim-style keybindings): idris-load-file. This causes Spacemacs to load up an ...
2
votes
1answer
57 views

Modify mode's font-locking without changing source code

Suppose I want to make additions to a major mode's syntax highlighting, how would I do this without modifying the major mode's source code? Some ideas: Redefine variable in .emacs Define a minor ...
2
votes
1answer
37 views

Set the major mode of a new buffer interactively

When creating a new buffer via: C-x b NonExistentBufferName RET RET I would like Emacs to ask me what major mode this buffer is going to use upon opening. Moreover, I want Emacs to infer the major ...
2
votes
2answers
139 views

Are there hooks for leaving modes?

There seems to be a bug in clojure-mode (mentioned here) because it does things in a mode hook (for paredit-mode) but doesn't undo them when the mode is turned off. I understand that add-hook can ...
2
votes
1answer
373 views

Where is mhtml mode defined? And why am I getting it by default when I open HTML files?

Under some very special conditions (namely, performing one particular edit in one particular HTML file), my Emacs session will freeze completely, and starts consuming ~100% of the CPU. The only ...
2
votes
1answer
176 views

How do I activate my keymap in my mode?

Following the Mode Tutorial, I /almost/ finished my own mode (my-mode). Now I only have the problem, that my mode-map settings seem to be ignored: (defvar my-mode-map (let ((map (make-sparse-...