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
287 views

Is a Lisp program in both prog-mode and lisp-mode?

Upon reading (emacs) Program Modes: Entering a programming language mode runs the custom Lisp functions specified in the hook variable prog-mode-hook, followed by those specified in the mode's ...
3
votes
1answer
39 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?
1
vote
1answer
50 views

Retrieve all the major modes equipped with emacs

I learned that GNU Emacs Manual Most major modes fall into three major groups. The first group contains modes for normal text, either plain or with mark-up. It includes Text mode, HTML mode, ...
18
votes
4answers
5k views

How to edit jsx (react) files in emacs?

I've use js2-mode but it don't indent html in javascript properly. I've found this repo https://github.com/jsx/jsx-mode.el but it's not for react, it's for some other jsx. What do you use for editing ...
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 ...
3
votes
1answer
80 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-...
1
vote
1answer
58 views

Setting 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 prompt me for the major mode this buffer is going to use upon opening. Moreover, I want Emacs to infer the ...
3
votes
2answers
127 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?
1
vote
0answers
18 views

Running logo program (ucblogo) in Emacs

I am trying to run logo programs (ucblogo version 5.5) on my emacs in Debian Linux (26.1). There is a currently a mode for it ( https://www.emacswiki.org/emacs/LogoMode ). I followed the instructions ...
0
votes
0answers
50 views

Spacemacs - python mode

I have some problems with my spacemacs configuration. For instance, it's supposed to be globally set up with emacs editing mode and the line numbers as well dotspacemacs-editing-style 'emacs ...
3
votes
1answer
147 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 ...
9
votes
3answers
1k views

How to start emacs in “nothing” mode (`fundamental-mode`)

If I type emacs test.sh Emacs insists on putting me in Shell-script mode. Another time I want to edit the file help.txt and then Emacs puts me in Text mode. But sometimes I don't want any of this, ...
10
votes
4answers
338 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 ...
6
votes
2answers
127 views

what are the options to write a language grammar for a new major mode?

I am writing a major mode for a programming language that has a well-defined grammar: it has a BNF, formalised in some happy files. I don't particularly want to re-implement the BNF as a series of ...
0
votes
1answer
50 views

does one has to explicity enable python-mode etc. to work with python files?

Sometimes I see people talking about enabling python-mode and so on. Is that only necessary for older emacs versions? I thought, the respective mode is enabled automatically when opening a ...
30
votes
6answers
12k 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?
2
votes
2answers
120 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 ...
1
vote
1answer
59 views

Emacs custom major mode with multiple comment types

I'm trying to write my first (very simple) major mode for Emacs. My goal is to have multiple comment types, but I can't find a way to implement this. Basically, I want my major mode to make ...
0
votes
0answers
167 views

Spacemacs user-config error

I'm using Spacemacs to develop a laravel + Vue application and I followed the steps in this configuration example to highlight syntax in Vue, but now every time Spacemacs starts it gives me this error:...
2
votes
2answers
148 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 ...
4
votes
2answers
351 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 -...
0
votes
0answers
29 views

Get the syntax coloring of another mode for newly defined mode

I am defining a new mode in emacs, but I want to have the same syntax highlighting as Org mode. How can I do this?
9
votes
1answer
4k views

How do I associate a file extension with a specific mode? [duplicate]

I would like emacs to switch to gnuplot-mode when I open a file ending in .g or .gnuplot. I tried ;; gnuplot mode-name (add-to-list 'gnuplot-mode '("\\.g\\'" . gnuplot-mode)) or ;; gnuplot mode-...
2
votes
0answers
68 views

Strange comment indentation results

I am working with a simple major mode. The format has one single line comment delimiter, i.e., %. However, I get strange results when running fill-paragraph on a comment. Specifically, the result I ...
2
votes
1answer
74 views

Create a command or key binding for closing code blocks

In AUXtex there is the key binding macro C-c ] which closes the lowest current TeX environment. For example \begin{equation} ... would be closed (by putting an \end{equation} on a new line after ...
6
votes
2answers
2k 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
0answers
36 views

Change major-mode keymap char-table

I'm trying to write my own major mode, which I want to use under MS Windows. Unfortunately, Windows doesn't have my favourite keyboard layout, so I'm planning to implement this keyboard layout in my ...
2
votes
2answers
103 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 ...
31
votes
3answers
11k views

How do I get the current major mode?

If I am editing a .tex file in emacs, by default (for me) the bottom right corner of the frame will say "LaTeX/P". However, I won't get to that mode by typing "M-x LaTeX/P-mode"; I can only get to it ...
1
vote
1answer
154 views

What does the `/l` mean in the mode `C++/l` mean?

Just a simple question with more than likely a simple answer: What does the /l mean in the mode C++/l mean?
6
votes
1answer
263 views

# -*- mode: … -*- string fallback

So I know that I can put at the first or second line of a file a line such as: # -*- mode: conf -*- to tell Emacs what major mode I want the file to be opened with. But if that mode isn't installed ...
15
votes
4answers
4k 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 ...
2
votes
2answers
99 views

Syntax table to match arbitrary forms with regexp

I'm trying to write a small major-mode for editing pico-8 files in emacs and I had a quick question regarding best practices and matching a somewhat arbitrary form in the pico-8 cartridge files for ...
3
votes
2answers
58 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 ...
0
votes
1answer
77 views

pressing return in paragraph-indent-text-mode deletes whitespace indenting beginning of paragraph

I'm currently using emacs 25.3 on Mac OSX installed using Homebrew, and without any modifications in my .emacs file or anywhere else. I think I may be fundamentally misunderstanding what paragraph-...
1
vote
1answer
74 views

Determining major mode for proper comment character insertion

I currently have a function like so in my .emacs file: (defun insert-todo () (interactive) (insert "// TODO(map) : ") ) It is bound to my key combination of "C-t". This will work for me if I'...
3
votes
2answers
76 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 ...
4
votes
1answer
76 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 ...
-1
votes
1answer
51 views

use a major mode from the internet

After installing emacs on windows 10 and gone through the tutorial and downloaded a major mode mt4.el , Now where to save it and how to use it in emacs? googling did not help me.
2
votes
1answer
353 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 ...
1
vote
2answers
72 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 ...
2
votes
2answers
186 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?
1
vote
1answer
49 views

Enable diff-mode for files with diff-ish content

How do I make Emacs automatically turn on diff-mode for any file with diff-looking content, eg. --- a.txt +++ b.txt @@ -1234,56 +1234,56 @@
1
vote
0answers
158 views

How to add additional comment syntax to a mode?

In general, given a major mode with a defined comment syntax, what do I have to define or change to add a new comment syntax? By "adding", I mean setting some new characters so that they work with ...
4
votes
1answer
145 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 ...
1
vote
1answer
49 views

derive major mode but do not derive mode hooks

I am trying to reuse lots of things that are built in c-mode for technically another c-like language, including syntactical highlighting and stuff like that. However, c-mode in my settings are ...
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'...
1
vote
1answer
69 views

Elisp: Inserting Comments

I'm trying to write an elisp program that will insert a section header and footer as a comment. For example, if I need a section called "intro" for my LaTeX document, the following would be inserted: ...
1
vote
1answer
34 views

Is it possible to “protect” strings from formatting?

I'm working on a latex document \documentclass{exam} \printanswers % to use the tag % \usepackage{catchfilebetweentags} % \ExecuteMetaData[file.tex]{tag} %<*afterclass> \begin{document} \...
3
votes
1answer
175 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-...