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
0 votes
2 answers
59 views

before-save-hook not working with use-package and custom mode

I wrote a little derived mode for the kage shader language, it's derived from go-mode (syntax is the same). I also like to use gofmt, but it's just not loading the hook. Here's the mode: (define-...
0 votes
1 answer
285 views

Highlight syntax of function names and their arguments in custom mode

I'm trying to create a major mode that handles the following syntax: function someName(value1, value2) # some contents end function I'm using the following to highlight the keywords function,...
1 vote
2 answers
219 views

How do I permanently configure a major mode?

I've been searching most of the day for an answer to this basic question, but I can't find an answer for the noise. If you search for, say, "configuring indentation in emacs," there's lots ...
0 votes
1 answer
37 views

Different outputs from minor-mode depending on major-mode

My minor-mode is inserting text in the current buffer. I want the default format of the text to be different depending on what major-mode the buffer is in, and to allow the user to override this ...
0 votes
2 answers
39 views

What to do when a major mode overides keybindings set in doom emacs?

[Edit: I should specify that there are many keybindings in the major mode that overide the desired keybinding. They all start with a whereas I would like a to do something else. I already thought ...
0 votes
0 answers
17 views

How to put 'viper-change-state-to-emacs function on some hook

I am using viper-mode, which is vi emulator and can be switched to the original emacs mode with viper-change-state-to-emacs, when I edit program files. But, sometimes I want to create some special ...
0 votes
1 answer
27 views

Whitespace in syntax table for comment delimiters in conflict with indentation and font lock

The special file format of my software uses angle brackets as a delimiter and # / # as comment markers (note the whitespace after the first # and before the last #). I try to make a major mode to ...
0 votes
1 answer
51 views

Call different functions based on buffer mode

I annotate my reading with org-remark and pdf-annot. They work with EPUBs and PDFs respectively, and are not interchangeable, with inconvenient consequences. What I would like to do is to bind a ...
0 votes
1 answer
20 views

`tab-stop-list` being ignored

Tying to write a new mode, I am stuck at: (define-derived-mode NEWS-mode text-mode "NEWS" "Major mode for NEWS file." (setq tab-stop-list '(2 6 59 65)) (setq indent-tabs-...
0 votes
1 answer
20 views

Update content of a buffer in side window when a custom mode is on [duplicate]

I have following code which is supposed to clear existing content in a buffer and write new one. (defun display-file-dir (path) (text-mode) (if buffer-read-only (read-only-mode)) (erase-...
1 vote
0 answers
62 views

What is the advantage of major-mode-remap-alist?

I've had this in my init file about forever: (defalias 'perl-mode 'cperl-mode) ;cperl is much nicer Now I learned about major-mode-remap-alist in Emacs 29.1 which I had installed shortly after ...
0 votes
1 answer
58 views

How do I stop Prolog mode from jumping to the Prolog REPL when consulting the buffer?

Suppose I am using Prolog mode with the Prolog REPL started as an inferior process using CtrlcEnter. Whenever I "consult" (i.e. evaluate) the Prolog mode buffer using CtrlcCtrlb ((prolog-...
1 vote
1 answer
274 views

Is there a major mode for dbt

I'm trying to use dbt in emacs, and I'm hoping that there is a mode for this that will combine the jinja and sql parts in an intelligent way... I quick google search didn't find anything, so the ...
0 votes
0 answers
21 views

Viewing a single mail file in a maildir

Is there any major mode that allows one to properly view a single mail file in a maildir? By "properly" here I mean similar to "big" email clients, like mu4e or gnus, so allowing (...
8 votes
1 answer
582 views

Emacs Mode For Editing Guitar/Bass Tablature?

I have been looking for a while, and have not been able to find an Emacs major mode for editing Guitar/Bass tablature.
1 vote
2 answers
380 views

Whitespace mode settings on per major mode basis

When I open the Linux Kernel code, my default indentation conflicts with the desired formatting of the Kernel. I use Emacs Prelude, so I added the settings from this link to my c-mode-common-hook. I ...
20 votes
6 answers
11k 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 ...
1 vote
1 answer
900 views

Good mode to edit CSV files including adding and removing columns?

Looking for a mode to edit CSV files. I tried csv-mode which is great for viewing CSVs via the minor mode csv-align-mode. However I cannot find an easy way to add or delete columns in this mode. Is ...
1 vote
0 answers
46 views

Mermaid major mode not showing up after installation

I've installed mermaid-mode by using package-install and MPLA but for some reason, it's not showing up when I type it after M-x. (I get Match required). I'm running Doom Emacs. Any clue why this ...
0 votes
0 answers
19 views

Haskell Interactive mode - incorrect parsing of crammed code

When using list comprehension without white spaces, all text after vertical bar turns grey. [x| is treated like header of here-document - grey color spans for the rest of the buffer, unless sequence |...
0 votes
0 answers
22 views

Is there a major mode for editing xkb files?

I have a custom keyboard layout I'm often editing. This is a file stored in /usr/share/X11/xkb/symbols/, similar to the other language files there. Since none of these files have an extension Emacs ...
0 votes
1 answer
38 views

change major mode without hiding text or revealing hidden text (for live-coding)

Question I am live-coding. I would like to be able to change the major mode to and from org-mode without un-hiding any of the text that org-mode has hidden. I would switch to a code mode whenever I ...
0 votes
2 answers
1k views

How enable tree-sitter modes (*-ts-mode) that aren't built-in?

My Emacs (29.1) comes with the some tree-sitter modes: c-ts-mode go-ts-mode js-ts-mode ... I downloaded the compiled .dll and they work out of box. However, there are some languages that tree-sitter ...
0 votes
1 answer
27 views

set the correct major mode for script files based on interpreter

I want to make a function that will set the correct major mode based on the interpreter used for a script. I don't want to include extensions in my scripts (because that can be annoying if making cli ...
1 vote
1 answer
886 views

language specific tree-sitter major mode wont show up

I'm using GNU Emacs 29.1 and have installed the tree-sitter haskell grammar: libtree-sitter-haskell.so via treesit-install-language-grammar but somehow haskell-ts-mode wont show up as a major mode ...
1 vote
0 answers
14 views

What is the correct way to make js2-next-error available when using js2-mode as major mode?

I'm using js2-mode. It provides js2-next-error, but apparently only when using js2-minor-mode and not when using js2-mode as a major mode. This is clear from the code in js2-mode.el (in version ...
0 votes
1 answer
22 views

how to use different faces for regular expressions in the same line in font-lock-defaults

I'm trying to create a major-mode for HTTP requests in emacs, I'm stuck at the syntax coloring for regexs at the same line. let this be the HTTP request I'm trying to highlight: GET /...
3 votes
2 answers
419 views

Remap mode to the new tree sitter mode not working

I"m trying to use the following code to remap js-mode to js-ts-mode. (add-to-list 'major-mode-remap-alist '(js-mode . js-ts-mode)) (Edit) I am using default emacs with a custom init file (only a ...
-2 votes
1 answer
73 views

Changing the major mode of a named buffer

How can I construct a function that changes the major mode of a named buffer ? (defun change-buffer-mode (mode buffer) )
0 votes
1 answer
47 views

Using major mode dependent functions

I have a function (tika-outlhg-regexp) that sets custom outline headings based on major mode. I activate this with major-mode hooks. Is there some other way? (defun tika-addhook-hgptn () (add-hook '...
0 votes
1 answer
156 views

Using hooks in minor modes

I have introduced the following hook function inside a minor mode. The intention is to activate the minor mode for a number of major modes. I would also need to activate outline-minor-mode once tika-...
68 votes
8 answers
35k 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?
1 vote
1 answer
193 views

How do I turn off electric-indent mode within 'Fundamental' mode?

Currently, in my .emacs.d/init.el, I have: (setq-default indent-tabs-mode nil) (setq-default tab-width 4) (setq indent-line-function 'insert-tab) (push (cons "\\*shell\\*" display-buffer--...
1 vote
2 answers
528 views

Disabling visual-line-mode only in org-agenda-mode

My emacs configuration has global visual line mode enabled via (global-visual-line-mode 1). I want to disable this mode, but only when in org-agenda-mode. When I do this manually, via M-x org-agenda, ...
0 votes
0 answers
59 views

SMIE: defining a build.ninja grammar

I'm trying to write a mode in SMIE, to figure out how it works and to create some documentation. build.ninja (a build system used by Meson and others) is a perfect candidate due to its very simple ...
55 votes
6 answers
15k 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 ...
0 votes
1 answer
173 views

Using the push function to append a list to the default-frame-alist variable

I've noticed some people use this to disable the menu bar in the GUI: (push '(menu-bar-lines . 0) default-frame-alist) and some people use this: (menu-bar-mode -1) Both achieve the same. The first ...
1 vote
0 answers
173 views

How do I use a local tree-sitter grammar in my emacs major mode?

I want to create a new major mode for a language with tree-sitter. I am working on the tree-sitter parser locally and It's working (tested in neovim and helix) Now I want to tell emacs to use the ...
2 votes
1 answer
687 views

How to set major mode localleader keybinding to both `SPC m` and `comma` in Doom

I want to be able to use both SPC m and , as major mode localleader keybinding in Doom. With my current Doom setup, I can only use , as localleader key. SPC m is undefined currently.
0 votes
1 answer
29 views

Highlight code between specified tags

how can I write extension for existing major mode, e.g. dart-mode to highlight block of codes. For example: // $done> import 'dart:async'; import 'dart:convert'; import 'dart:io'; import 'dart:ui'; ...
0 votes
1 answer
119 views

Rebind key to a different character in a specific mode?

I already tried some different ways of doing this, but never got it quite right, so I put it here. When working in buffers using some specific modes (lisp-mode, emacs-lisp-mode) I want to make it so a ...
1 vote
1 answer
465 views

How can I turn off Company mode in only some major modes? [duplicate]

I use company when coding. I currently have it set to global. I would like to turn it off for a few major modes. However, instead of turning it off globally, I only want to deactivate company for 2 or ...
1 vote
0 answers
51 views

How to apply changes from a major mode that I'm currently creating?

I'm writing a syntax highlighting mode for emacs, and wondering if there is a way to improve my workflow. Currently I do this: make edits to mymode.el restart emacs open mymode.el eval buffer open a ...
0 votes
1 answer
29 views

Making function callable only whilst in `c-mode`

How can I make this function callable only whilst in c-mode? (defun nuket-c (actm) "Code templates for the C language" (interactive (list (let ( (cseq '("struct" "...
0 votes
2 answers
110 views

Are C-[0-9] and M-[0-9] completely interchangeable?

In all my exploration, it seems that M-[0-9] and C-[0-9] apply numeric prefixes in the same way everywhere. Does this change for any common modes? I'm considering overwriting one of the sets of ...
1 vote
1 answer
55 views

How to disable `q` key (quit) for *Geiser Debug* window?

The *Geiser Debug* window disappears after pressing q. This is normally good for dismissing the error messages in the window (for scheme). However, I'd like to keep this window open so that I can see ...
1 vote
1 answer
251 views

How to make a popup buffer like *Help* accept and return some input upon pressing RET?

What I need to capture some text which is then inserted at point without using the minibuffer (see "why" for why this is not entirely stupid). My idea was to just pop up a temporary window ...
1 vote
2 answers
151 views

How can a function check which major mode is enabled?

The accepted answer to this question says: When the function is invoked, it can test the current mode and do something appropriate. For example, for some modes, or all modes except some modes, it can ...
0 votes
1 answer
22 views

When is the major-mode assigned to an input file determined by its file extension?

How does Emacs determine the major-mode assigned to a file based on file extension, e.g. .txt or .odt? If the filename has no extension, and I don't do anything to tell Emacs how to treat it, what ...
1 vote
0 answers
24 views

Major mode to colour fragments such as tables

I would like to define a major mode for some class of documents, a few faces, and fontification rules that find fragments users would want colored and apply those faces. The user will be able to ...

1
2 3 4 5 6