Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

2
votes
2answers
58 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
24 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
22 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:...
0
votes
0answers
27 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?
2
votes
0answers
64 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 ...
6
votes
1answer
70 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 ...
2
votes
1answer
65 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 ...
1
vote
0answers
25 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 ...
1
vote
2answers
88 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 ...
1
vote
1answer
61 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?
4
votes
1answer
238 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 ...
3
votes
2answers
44 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
85 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 ...
1
vote
2answers
88 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 ...
3
votes
2answers
55 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
63 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
42 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.
1
vote
1answer
41 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'...
2
votes
1answer
233 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
1answer
44 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 @@
0
votes
1answer
56 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-...
0
votes
0answers
73 views

How can I change the indent size to 2 spaces in r-mode?

I have tried using (setq r-indent-level 2) but that doesn't seem to work. I would like to set the indent to 2 spaces instead of 4 in R.
2
votes
2answers
81 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 ...
1
vote
0answers
93 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 ...
1
vote
1answer
43 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 ...
1
vote
2answers
3k 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'...
0
votes
1answer
42 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: ...
4
votes
1answer
133 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-...
1
vote
0answers
54 views

How to disable code folding for coq?

When I do isearch on the buffer having coq mode it somehow executes code folding, something like (... *)... I have tried to use (setq company-coq-disabled-features '(code-folding)) for disabling code ...
1
vote
1answer
33 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} \...
1
vote
2answers
143 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?
0
votes
0answers
43 views

How do I define a simple indentation rule for a custom mode?

I'm making a custom mode for an internal DSL that we use at work. I have nailed the highlighting and just need to get around making indentation work. The language itself is just S-expressions so I ...
2
votes
0answers
52 views

Recommended use of non-file-visiting revert-buffer-function

Summary I am working on a major mode derived from special-mode, which populates its buffers with formatted lists of items retrieved from a web API. Reverting such a buffer involves refetching and ...
1
vote
0answers
147 views

Enabling Company CAPF backend with timer in Major Mode

I've be working on a new major mode for a DSL. I'm planning to use the CAPF backend for company mode and would like to provide the integration. The completion at point functions produce the correct ...
1
vote
0answers
76 views

Keyword as comment ender (and starter)

In my previous question I asked about complex comment-start sequence and I think I figured it out, but now I have another problem. Let say we have this mode: (defconst test-font-lock-keywords '(("\\...
1
vote
1answer
68 views

Complex comment-start (and end) sequence

As far as I understand there is syntax flags only for comment delimiters made up of two characters but if I have comment delimiters of length greater than two characters is it possible to change ...
0
votes
1answer
35 views

.emacs linked to emacs.link,open emacs.link in emacs-lisp mode

Say I have a symbolic link .emacs link to emacs.link,so when I open emacs.link,the associated buffer's major mode is Fundamental mode. I want emacs.link's major mode Emacs-Lisp. Another example is: ...
0
votes
1answer
42 views

Is it possible to auto select the mode depending on where the file is?

One can use auto-mode-alist to define modes based on the regex and the filename. However I want to use different modes for files depending on which folder they are in. So, for example, in a django ...
1
vote
2answers
106 views

Is it possible to lazy-load language mode packages?

Most of the packages I currently use are major modes for various languages that are only included in the off-chance I load a file of that type. Is there a way to postpone loading them at startup in ...
5
votes
0answers
164 views

How to read wikipedia in Emacs

Is there a simple mode for the reading of wikipedia through Emacs?
2
votes
0answers
97 views

SMIE default syntax : First level of indentation

When you only do that in your major mode : (require 'smie) (smie-setup nil #'ignore) That means SMIE but no grammar, and no rules. And it's great. It makes the point stay on col0 when you TAB and ...
2
votes
1answer
117 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-...
2
votes
2answers
152 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 . ...
1
vote
1answer
352 views

Setting the Default Major Mode?

I have a lot of files on my system without extensions (i.e., files like todo, list_of_stuff, etc). I would like these types of files to default to markdown-mode for their major mode. How to do this? ...
0
votes
1answer
43 views

How can a file be configured to recognized as a certain language only in that session?

I am editing a Drupal module file which doesn't use either a .php or .module extension. How can I configure emacs to recognize the file alone as a PHP file: regardless of the extension and only for ...
14
votes
1answer
4k 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 ...
0
votes
0answers
21 views

wiki and twiki major modes

Is there an emacs mode for editing and typsetting wiki wiki modes? What I am looking for is something that could help me writing a properly formatted document for wikipedia.
0
votes
1answer
80 views

Json-Mode / Puppet-Mode unset common functions when installed with use-package

I'm facing a weird issue in my init.el. Installing packages such as json-mode or puppet-mode (from MELPA Stable) with use-package unsets common functions like forward-word or backward-kill-word. The ...
0
votes
1answer
85 views

How does one change a .el file to lisp-interaction mode?

I've looked at the documentation, but I can't seem to figure out how to do it.
0
votes
1answer
365 views

major mode with irony warning message

Below major mode is a dummy mode just derived from c-mode: ;; a simple major mode, mylang-mode (define-derived-mode mylang-mode c-mode "major mode for editing mylang language code." (message "...