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
1
vote
1answer
27 views

sage-shell-mode repeat the input in the output

I wanted to use sagemath straight in emacs instead of having a terminal open. I tried to use a shell (or eshell for that matters) in emacs and launch sage there, but every time I input a command, the ...
0
votes
0answers
35 views

Setting custom font size for org-mode?

What's a recommended way to set the font size for org-mode (or any other major mode) to a certain value that is different from the global font size? By looking at documentation C-h k C-x C-+, this is ...
20
votes
4answers
6k 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
1answer
48 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 ...
1
vote
1answer
63 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 ...
0
votes
0answers
14 views

Editing mode for OpenBSD .conf files

Can GNU Emacs edit OpenBSD configuration files (/etc/*.conf, curly-brace syntax) with auto-indentation and syntax highlighting? conf-mode does not seem to handle that syntax in Emacs 26. c-mode ...
1
vote
2answers
49 views

How to describe-mode (but not the current major mode)?

I know that describe-mode will describe the current major mode. Is it possible to describe a mode, and I will input the mode name?
1
vote
1answer
16 views

How to find inheritance of modes?

As an example, let's use latex-mode, that inherits from tex-mode, that inherits from text-mode. Is there a command, that would take as input latex-mode and give me parent and grand-parent? Or, other ...
0
votes
1answer
29 views

symbol's value as variable is void: command, when using ibuffer-sidebar

I installed ibuffer-sidebar (https://github.com/jojojames/ibuffer-sidebar) and added the following to my ~/.emacs.d/init.el: (use-package "ibuffer-sidebar.el") (require 'ibuffer-sidebar) (setq ...
2
votes
1answer
53 views

Is there a standard mode for .ini files?

After looking for a mode for .ini files, I found ini-mode via MELPA, but upon installing it in Emacs 26, there was a message about it being an obsolete mode. What are the alternatives? In my limited ...
45
votes
5answers
10k 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
1answer
39 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,...
61
votes
8answers
2k views

How can I use Emacs to edit questions, answers, and comments here?

Emacs as a StackExchange client? How can I use Emacs to edit questions, answers, and comments here on the Emacs Stack Exchange site? Broadly, what possible methods exist? Kill and yank This works, ...
1
vote
1answer
52 views

How to activate diff-mode from command line?

Git's editor config is set to launch emacs in no-window mode and to execute lisp function diff-mode: git config --global core.editor "emacs -nw -f diff-mode" However, when I execute git commit -v to ...
1
vote
2answers
69 views

Change major mode for buffer without a corresponding file

I want to change the major mode from fundamental-mode to compilation-mode for a buffer which contains some generated output named for eg. *results*. I've tried to add an entry to auto-mode-alist but ...
0
votes
2answers
38 views

How to overwrite a package major mode?

I'm a newcomer to Emacs from Vim, I use rsjx-mode for react files. Its major mode calls itself RJSX, but I would like to call it React, so how can I overwrite the rjsx package major mode name?
0
votes
2answers
27 views

Call mode-specific backspace from “smart-backspace” function

I'm writing an IntelliJ-style "smart backspace" function which does the following: If the whole of the line up to the point is whitespace Join the line to the previous line, killing that whitespace ...
1
vote
1answer
49 views

Create custom “mode-hook” for other programming languages

For C/C++, I have the following to be run when I do M-x compile on a .c/.cpp file (add-hook 'c++-mode-hook (lambda () (set (make-local-variable 'compile-command) ...
0
votes
1answer
39 views

How to set the default of `truncate-lines` for dired buffers to `truncate`?

How can I set the default of truncate-lines for dired buffers to truncate? I.e. when I open a new dired buffer it should show the directory truncated and not wrapped into the next line.
4
votes
2answers
303 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
25 views

Can a mode setup function fail?

If I define a new mode using define-derived-mode or define-minor-mode, can the mode setup somehow signal failure so that the mode is not activated? All of the following modes are activated despite ...
0
votes
1answer
47 views

How to disable a minor/major mode so that mwheel-scroll don’t take effect?

I am trying to have a simple solution to center the cursor at all times. I found that centered-cursor-mode was too slow and found this simpler solution. The only problem is mouse scrolling no longer ...
1
vote
1answer
257 views

Find out, which mode is in use

Suppose I want to code something like this case mode in lisp-mode) do-something ;; shell-mode) do-other ;; latex-mode) do-different ;; esac What ...
0
votes
0answers
52 views

use-package deferred loading for extensions not in :mode

When moving to use-package, I'd to replace (require 'markdown-mode) (add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode)) with (use-package markdown-mode :mode "\\.md\\'" :config ... ) ...
3
votes
1answer
102 views

How are major modes and local keymaps associated?

The Emacs manual says: Major modes customize Emacs by providing their own key bindings in local keymaps.... Minor modes can also have local keymaps... Roughly, it seems to say: Major modes ...
0
votes
1answer
69 views

how to bind custom commands to keys in existing mode map?

I wrote some extra commands for Python mode: python-insert-quote and python-insert-double-quote. I want to have these commands be available in the minibuffer when python-mode is active. How can I add ...
2
votes
1answer
49 views

What's the idiomatic way of overriding a key binding for a given major-mode (but no other)?

I'd like to bind C-x C-e to python-shell-send-region when I am in python major-mode. In my config file, I have an add-hook for python mode, but I'd like this keybinding override to be removed/...
1
vote
1answer
126 views

How do you automatically enable writeoom-mode when org-mode starts?

I want to enable writeroom-mode whenever I startup org-mode because I don't really ever want writeroom-mode to be disabled if I'm using org-mode.
0
votes
1answer
103 views

Check whether buffer is in org-mode

I want to programmatically check whether the current buffer is in org mode. I know that major modes should usually define the variable <modename>-mode, i.e., org-mode should be a defined ...
1
vote
1answer
87 views

How to make font-lock use my face?

I'm interested in making a major mode to display PGN files nicely. I'm trying to create my own faces since the defaults don't seem super-appropriate. My mode definition looks like this: (defface ...
45
votes
6answers
18k 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?
0
votes
0answers
19 views

Disable Flycheck for different file extensions with the same mode

I use verilog-mode for both Verilog (extension .v) and System Verilog (extension .sv). I want to disable flycheck for .v files only. (Because they are typically multi-gigabyte netlists that take lots ...
0
votes
0answers
91 views

Howto define TAB and S-TAB in keymap of custom mode

I'm trying to bind the TAB and shift TAB keys to a custom readonly buffer mode. The skeleton of the mode looks like this: ;; 8< --- exmode.el ------- (defun exmode-i () (interactive) (message ...
1
vote
1answer
36 views

How to bind a key in a `generic` mode?

Is there a way to bind a key in a mode defined using define-generic-mode such as xmodmap-generic-mode? Generic does not appear to create keymaps. ELISP> (require 'generic-x) generic-x ELISP> (...
1
vote
0answers
21 views

Keybindigs conflict between minor modes

The configuration that I have for python mode implies loading both elpy.el and python.el. The things is that I found the python.el keybindings more natural than the elpy.el ones. And most of the ...
1
vote
3answers
97 views

SMIE Indenting Arguments and Blocks

This is closely related to a previous question I asked here: SMIE Basic Identation and Block Example However, it is sufficiently different (and already big enough) that I might as well ask it as a ...
3
votes
2answers
114 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 ...
7
votes
1answer
413 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
71 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?
2
votes
1answer
89 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, ...
2
votes
1answer
104 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
222 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
69 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
158 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
37 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 ...
9
votes
3answers
2k 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
371 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 ...
7
votes
2answers
236 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
358 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 ...
3
votes
2answers
359 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
2 3 4 5