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
1answer
261 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
281 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
94 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 ...
10
votes
1answer
774 views

Disabling electric-indent-mode for one mode (latex mode) only

I don't like the way electric indent mode works in latex-mode. Everywhere else (at least everywhere I use), it's great. How can I permanently disable electric indent mode for latex mode only, but ...
0
votes
2answers
386 views

How replace auto-complete-mode with company-mode in all major mode using it?

How I can replace auto-complete-mode with company-mode in all major mode using it? i.e. make all modes which activating auto-complete-mode (e.g. c-mode or sh-mode etc), activate company-mode instead ...
60
votes
7answers
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
86 views

init.el config overwritten in certain modes? [duplicate]

I find when I am using emacs in certain modes that configurations made in my init.el files do not apply anymore. E.g. I have my keybinds set up so that tab is used for indentation, § for snippet ...
0
votes
1answer
108 views

Switching buffer to special mode or any mode?

I have written some code to create a new buffer, it starts up in fundamental mode, the buffer is to display output from commands. I am using this to create the buffer (get-buffer-create "*My Buffer*"...
4
votes
1answer
1k views

Change the default mode used when opening a new buffer

For example, we can open a new buffer with C-x b <new-buffer-name>, and by default, this new buffer opens in fundamental-mode, which is not very useful to me. I would like to change this to open ...
2
votes
1answer
811 views

Scratch always starts in fundamental mode

I don't know what change in my configuration caused this, but scratch buffer always starts in fundamental-mode. I would like to have emacs-lisp-mode in the scratch buffer. I tried to do (setq initial-...
0
votes
1answer
198 views

Create a sub-mode of an existing mode which overrides certain functions?

I want to make a few customizations to cmake-model.el. The big-picture view of this lisp file is as follows: ... ;; This function I want to modify (defun cmake-indent () ... ) ... ;; Mode ...
2
votes
1answer
58 views

Modify mode's font-locking without changing source code

Suppose I want to make additions to a major mode's syntax highlighting, how would I do this without modifying the major mode's source code? Some ideas: Redefine variable in .emacs Define a minor ...
1
vote
2answers
228 views

How to define key bindings for major mode extensions?

I am writing some extension features for various major modes. The features are (as usual in Emacs) some functions that should be bound to some keys to simplify the workflow of the user. I started ...
0
votes
1answer
80 views

How to disable skeleton-pair-insert-maybe?

I recently got a new Chromebook and installed Ubuntu via crouton. I then installed Emacs 23 and transferred my .emacs file to the new machine. However, a few of my key rebindings have been ...
0
votes
1answer
62 views

different mode setting

I often use .c file and .txt file on the split emacs frame. I wrote a code such as the following to init.el. ;; change text-mode indent (add-hook 'text-mode-hook (lambda () (setq ...
3
votes
2answers
1k views

How to customize major mode initialization with local variables?

Seems like most major modes clear all local variables before initializing. It also seems like many major modes read variables while initializing to customize their behavior. If I want to set a file ...
9
votes
2answers
2k views

How do I write a simple `completion-at-point-functions` function?

I'm considering writing a major mode for editing Magic: the Gathering decks. Most of it seems pretty straightforward but I have one question. There are about 15 000 unique Magic cards available (...
1
vote
0answers
28 views

Specify fallback possibilities for file-local variables?

It is clear from the manual how to set file variables: -*- mode: modename; var: value; … -*- For example, at the top of my ~/.gitconfig file, I have # -*- mode: conf; -*- I recently discovered ...
4
votes
3answers
485 views

How can I create mode-local variables?

I'm looking to create a command which stores a kind of "history" for the current major-mode. I need the variable to be independent for each major mode, but consistent across all buffers in any ...
1
vote
1answer
462 views

Syntax highlighting: highlight text followed by a pattern, but not the pattern itself

I'm writing a major mode to handle syntax highlighting for a language that allows namespaces just like in C++ e.g. somewhere::out_there. I'd like to highlight the text somewhere, but leave the ...
0
votes
1answer
214 views

How do I enable a mode, when another mode runs?

All I want to do is enable tern-mode, when I enter js-mode. I know that a hook called js-mode is run when I open a javascript file but for some reason tern-mode is not enabled. In my init.el file I ...
0
votes
1answer
112 views

Stop automatic indentation and cursor movement while typing in major mode

I've put together a simple major mode for syntax highlighting and indentation of AQL. This is my first, and I'm open to any suggestions there, but my question is more specific: When I type two ...
24
votes
1answer
840 views

How can I quickly toggle between a file and a *scratch* buffer having the same major mode?

At times while working on a code, it's useful to quickly open a *scratch* buffer to paste a snippet from that code file. If I am working on a Perl script, I would like to quickly open a *scratch* ...
2
votes
1answer
509 views

How do I force a mode on a specific file through special comments

I have a file called zshrc (not .zshrc). Emacs does not recognize that it must use sh-modeautomatically. I want to put some sort of hint for emacs to pick up and syntax highlight my file accordingly. ...
1
vote
2answers
189 views

js-comint mode (node) returning too many undefined responses?

I am using js2-mode and comint-mode to run the Node REPL in emacs. For some reason the prompt is returning a lot of undefined and ...undefined responses, which it wouldn't do normally. for instance, ...
0
votes
0answers
181 views

font-lock problem of c++ mode

I recently notice that there's some strange behaviours of the font-lock of the c++-mode. Let's start emacs by emacs -Q in the terminal, edit a new file test.cpp and save the following contents Then ...
2
votes
1answer
421 views

How to prevent line wrapping in code, but allow it in help/info buffers?

I'm quite new to emacs (coming from vim), and I'm struggling to figure out how to configure sane line-wrapping/truncation behavior. For the most part, I'd like to prevent wrapping, so I put this in ...
2
votes
1answer
256 views

How to set whitespace-line-colum per mode?

I'm trying to have whitespace-line-column set to 80 in prog-mode and 100 in web-mode, etc. However when using hooks seems to get ignored, as is always set to 80. (require 'whitespace) (setq ...
11
votes
2answers
271 views

Use two major-mode-maps in the same buffer

I've run into a few situations where it would be highly convenient to have to have the keymap of one major-mode act as a fallback keymap for another major-mode. For instance: I write a lot of LaTeX ...
4
votes
1answer
250 views

Why isn't emacs-lisp-mode derived from lisp-mode?

Just out of curiosity, why isn't emacs-lisp-mode derived from lisp-mode? Instead, both are derived from prog-mode. It seems to me that there is a natural hierarchical relationship that should exist. ...
1
vote
1answer
104 views

How to modify existing major-mode?

I've made a minor change to the existing code in bibtex.el; to be more precise, I've modified the function bibtex-generate-url-list so that it can generate URLs for several more fields (in addition to ...
2
votes
2answers
309 views

Create new major mode from cc-mode that allows comments with two dashes

It is possible and relatively easy to create a new major mode, deriving from c-mode, and just add two dashes '--' to work as comments too? I have checked many resources, but couldn't find anything ...
6
votes
2answers
483 views

How to associate more than one file extension with a given mode in `use-package`

When using use-package, is there a way to associate more than one file extension with a particular mode in one place instead of multiple locations? Case in point is that I would like to associate ...
0
votes
1answer
341 views

Is there major mode for editting CQL?

I'm editting CQL(Cassandra Query Language) on emacs and came to wonder if there's any dedicated major mode for editting CQLs. Is there such one?
1
vote
2answers
71 views

Files for which to activate generic mode

I've created a generic mode for emacs, but I have trouble matching the file names I want the generic mode to be on, right now I'm using proguard-* but I would like to match only file names with ...
5
votes
1answer
1k views

Writing a Major Mode

What are some resources for learning to write a major mode for a programming language such as Haskell? I know such things exist but I would like to learn how to do it, it seems like a fun and ...
2
votes
0answers
115 views

Find all modes derived from a mode

Is there any way to easily find all the modes that derive from a mode? The closest I can get is to use M-x apropros and search for -mode$ and manually comb through all defuns with the property ...
5
votes
3answers
293 views

How to never have a major mode enabled automatically

looks like Emacs tries to be smart, switching to an annoying change-log-mode often when i am editing a changelog file. I would like to disable it, but i just find info about how to interactively ...
1
vote
1answer
1k views

How to have emacs recognize Makefile as a prefix for makefile-mode?

I figured the following would tell emacs to recognize files starting with "Makefile" and start makefile-mode: (add-to-list 'auto-mode-alist '("\\`Makefile" . makefile-mode)) The \\` indicates the ...
3
votes
1answer
564 views

How to define “mode-specific” functions?

How can I define an Elisp function such that it is available only under a specific mode? (FWIW, at the moment, the mode I want to restrict a function to is comint.)
1
vote
1answer
176 views

syntax-highlighting strings incorrectly for strings in opascal-mode

I write my projects in FreePascal and use opascal-mode to write it. I'm having a problem that this mode thinks that '\' is not a complete string, and hence all code after it is highlighted as a string....
1
vote
1answer
688 views

Highlighting YAML comments correctly

See https://lists.gnu.org/archive/html/emacs-devel/2015-12/msg01046.html for more background. YAML defines a comment as a # either preceded by the beginning of the line or whitespace (more ...
4
votes
2answers
462 views

Which mode is best for a special configuration file, specifically logstash

I'm using logstash and its configuration file (documented here) looks like this: input { file { path => "/some/path/to/file" option => 1 } } filter { if [var] == "string" { ...
2
votes
1answer
189 views

How to match more than one instance of a single subexpression?

I'm trying to use a regular expression of the form "foo\\(?:\\(bar\\)\\(baz\\)\\)*\\(quux\\)", but I want the inner two subexpressions to retain all of their matches, not just the first one. I ...
1
vote
2answers
120 views

How to make $ not part of a symbol in tcl-mode?

Recently I found out about isearch-forward-symbol-at-point but in tcl it's rather useless, because when dereferencing a variable the $ is part of the symbol and so the symbol-at-point $var does not ...
0
votes
1answer
126 views

Make major mode be used by default for new files in directory

I forget to enter sh-mode when I create new shell scripts in ~/.local/bin, so I want emacs to do this automatically. Because I have an advice set up to make them executable, this will have the effect ...
5
votes
1answer
1k views

How can I change which shell script mode I'm in?

Occasionally, emacs opens a file in shell-script[fish] when I want it to open in shell-script[bash]. How can I manually change the subtype of shell-script mode that I'm in?
3
votes
2answers
682 views

Git commit uses fundamental mode after magit update

I recently updated magit to 20151025.1115, which gave me a message about git-commit-mode incompatibility. I now, instead, have a package git-commit at version 20151022.933 (from the magit project) ...
1
vote
1answer
719 views

Set a default scratch buffer

My emacs daemon for ocaml (I use more than one emacs daemon) starts in a tuareg scratch buffer. I am aware of initial-major-mode but this hasn't worked: the scratch is started before (setqinitial-...
3
votes
2answers
2k views

Use-package for a mode

it's not clear for me how should I set use-package to load a package when a mode is activated. I have read different things about :mode, :init :config and I am now confused. Could someone explains it ...