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.

0
votes
0answers
24 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
61 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 ...
5
votes
1answer
59 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
62 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
24 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
84 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
45 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
231 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
43 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
76 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
1answer
72 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
54 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
60 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
40 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
38 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
196 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
41 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
45 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
70 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
79 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
75 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 ...
0
votes
2answers
2k 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
35 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
125 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
52 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
135 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
39 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 ...
1
vote
0answers
36 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
122 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
75 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
65 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
40 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
98 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
156 views

How to read wikipedia in Emacs

Is there a simple mode for the reading of wikipedia through Emacs?
2
votes
0answers
92 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
105 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
147 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
324 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
3k 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
20 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
78 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
81 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
339 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 "...
1
vote
1answer
46 views

File mode name with -mode suffix or not?

I am not sure when I should name file x-mode.el and when x.el. Note that because of established practice mode writer should put (provide 'x) or (provide x-mode) to the end of file and end-users load ...
9
votes
1answer
2k views

How to disable the org-mode in a buffer

For a test purpose, I enabled the org-mode by M-x org-mode in a buffer (e.g., in scratch buffer). How to disable it? Doing again an M-x org-mode does not turn it off.
1
vote
0answers
20 views

Cperl font lock regions in here docs

I am having a problem in cperl-mode described in this question. Basically inserting a newline at the start of a line in here doc in cperl-mode is breaking the syntax highlighting. One of the answers ...