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
3
votes
2answers
90 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
82 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
59 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
419 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
74 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
220 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
55 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
201 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
152 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
56 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 ...
4
votes
2answers
8k 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
97 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
39 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
212 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
72 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
0answers
80 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 '(("\\...
38
votes
4answers
8k 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 ...
2
votes
0answers
69 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
314 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
1answer
73 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
40 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
76 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
157 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
265 views

How to read wikipedia in Emacs

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

How do I change the cursor face per buffer?

I have a custom emacs major-mode which I specified the background and foreground colors for. However, the default cursor color clashes with the background and you can't see it. 'set-cursor-color' ...
7
votes
2answers
1k views

How to set major mode for a file in .dir-locals.el?

I would like to set the major mode for a file as you would using file-local variables Local Variables: mode: text End: but in .dir-locals.el in order not to “pollute” the file in question. Is this ...
0
votes
1answer
87 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 ...
2
votes
2answers
202 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 . ...
2
votes
1answer
212 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
0answers
133 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 ...
1
vote
1answer
527 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
53 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 ...
2
votes
1answer
376 views

Executing programs the efficient way with Spacemacs

I'm a Vim user trying to learn Spacemacs. In Vim, I execute a Scheme program by typing :mit-scheme < xxx.scm. After the program exits, I can continue editing simply by press Enter. However, doing ...
0
votes
0answers
25 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.
5
votes
3answers
627 views

Turn a non prog-mode derived major-mode into a prog-mode derived major-mode

erlang-mode is not a derived prog-mode. Is there any way to make it part of the prog-mode-hook ?
3
votes
1answer
305 views

Is it possible to achieve erlang formatting like this?

As I was going through learnyousomeerlang I came across code formatted like so: if X > Y -> a() ; true -> b() end Presently As close as I can get is: if X > Y -> a() ; -...
9
votes
2answers
168 views

How to write a major mode that does not open the file but provides a view on it

I would like to write a major mode for inspecting netCDF files. These are binary files which can be multiple GB in size. So I don't want to open them in emacs. The interaction that I have in mind is ...
5
votes
2answers
161 views

How do I handle multiple string delimeters in a major mode?

I'm trying to write a major mode for a language that supports normal strings and triple-quoted strings ("foo" and """foo"""). (defconst my-string-mode-syntax-table (let ((table (make-syntax-table)))...
8
votes
1answer
274 views

How do I create a simple syntax table for a major mode?

I'm trying to understand how syntax tables work, but my minimal major mode doesn't highlight anything. I've written the following elisp, which is just supposed to highlight comments: (defconst my-...
0
votes
1answer
93 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
484 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
54 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
3k 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
22 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 ...
3
votes
1answer
106 views

Vector literal indentation

I want to write my emacs-lisp-mode modification which respects some of my preferences. In particular, I want to override indentation for vector literals. Emacs treats vector literal as quoted list ...
1
vote
1answer
76 views

Cperl-mode syntax highlighting breaks when inserting a newline into a here doc

in cperl-mode, here docs are colored with a font-lock-string-face. However if you used any function that inserts a newline on a blank line (e.g. M-: (insert "\n")) it will cause all code after the ...
2
votes
1answer
29 views

Adding XUL file syntax highlighting support?

I am new on Emacs and I am working on modifying firefox interface. XUL is implemented as an XML dialect. I just need basic syntax highlighting for XUL. I found that VIM and gedit are working out of ...
3
votes
1answer
250 views

Derived mode without merging keymap

It seems that when using define-derived-mode, the new mode's keymap is merged with that of the parent mode. Is there a way to avoid this? That is, to inherit font-lock, etc. from the parent mode, but ...
0
votes
1answer
280 views

How to disable warning in js2-mode: function does not always return a value?

Is it possible to disable warning for functions that not always return value in js2-mode?
1
vote
0answers
90 views

How to save a yasnippet placeholder's final value in an Elisp variable?

In its more recent versions, shell-script mode tailors its behavior in response to the sh-shell variable's value, which indicates the shell variant (zsh, bash, etc.) that the script is for. I've ...