help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Keybinding that loops through Major Modes


From: Christopher Dimech
Subject: Re: Keybinding that loops through Major Modes
Date: Mon, 2 Nov 2020 22:10:02 +0100

I shall explain better then.  In my .texi files I customarily include commands
from other modes or want to use some hooks from other modes (e.g. org-mode).
So even after I load a file with the default mode, I would need to quickly
shift to another mode temporarily, then switch back to normal-mode.



> Sent: Monday, November 02, 2020 at 9:59 PM
> From: "Emanuel Berg via Users list for the GNU Emacs text editor" 
> <help-gnu-emacs@gnu.org>
> To: help-gnu-emacs@gnu.org
> Subject: Re: Keybinding that loops through Major Modes
>
> Christopher Dimech wrote:
>
> > Is it difficult to make an keybinding that if I continue to press
> > it, it will loop through a list of major modes in a predefined
> > order (e.g. text-mode, org-mode, normal-mode, text-mode, ...)
>
> Not difficult but perhaps not a good idea since it is probably better
> to let Emacs set the major mode automatically.
>
> If it doesn't do it to your liking there are many ways to set it up,
> depending on the situation.
>
> Based on file extension:
>
> (let ((modes (list
>      '("\\.bal\\'" . balance-mode)
>      '("\\.lu\\'"  . lua-mode)
>      '("\\.nqp\\'" . perl-mode)
>      '("\\.php\\'" . html-mode)
>      '("\\.pic\\'" . nroff-mode)
>      '("\\.pl\\'"  . prolog-mode)
>      '("\\.tex\\'" . latex-mode)
>      '("\\.xr\\'"  . conf-xdefaults-mode)
>      '("*"         . text-mode) )))
>   (setf auto-mode-alist (nconc modes auto-mode-alist)) )
>
> For scripts, use the hash-bang line, topmost. You probably want it
> anyway. For example, for zsh:
>
> #! /bin/zsh
>
> You can also force a mode like this, also topmost:
>
> ;;; -*- emacs-lisp -*-
>
> For the rare cases none of these methods will do, I think M-x
> perl-mode RET will do...
>
> --
> underground experts united
> http://user.it.uu.se/~embe8573
> https://dataswamp.org/~incal
>
>
>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]