From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Christopher Dimech Newsgroups: gmane.emacs.help Subject: Re: Keybinding that loops through Major Modes Date: Mon, 2 Nov 2020 22:10:02 +0100 Message-ID: References: <87eelb1nmc.fsf@zoho.eu> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="9503"; mail-complaints-to="usenet@ciao.gmane.io" Cc: help-gnu-emacs@gnu.org To: moasenwood@zoho.eu Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Mon Nov 02 22:12:00 2020 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kZh7Q-0002Kb-2y for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 02 Nov 2020 22:12:00 +0100 Original-Received: from localhost ([::1]:41080 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kZh7O-0005P8-TW for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 02 Nov 2020 16:11:59 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52498) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZh5b-0005Oi-RS for help-gnu-emacs@gnu.org; Mon, 02 Nov 2020 16:10:07 -0500 Original-Received: from mout.gmx.net ([212.227.15.19]:36515) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZh5Z-0002gO-8t for help-gnu-emacs@gnu.org; Mon, 02 Nov 2020 16:10:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1604351402; bh=1UlmSQo16UqABhPpOb6/D86a3xnR3ejz79HzmZsJJI4=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=M/dsWMWEx/xf3zsXf2V4tQSDTRfnKVzdQX6V5vXPrGl30zlLGN2dEdbl8bDwY/ZjD wk0E4JwdKyfSQDJCcpsly0SA1CcP0zbgFoylv/OmqLZWkIP4IdXUlyzdjLXHAeVxTI Vl6eYiMdTSWDsz4KEJWIcZdyIiDh4NbGQl1MQJBQ= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from [213.165.168.94] ([213.165.168.94]) by web-mail.gmx.net (3c-app-mailcom-bs09.server.lan [172.19.170.177]) (via HTTP); Mon, 2 Nov 2020 22:10:02 +0100 Importance: normal Sensitivity: Normal In-Reply-To: <87eelb1nmc.fsf@zoho.eu> X-UI-Message-Type: mail X-Priority: 3 X-Provags-ID: V03:K1:erPMqBCA6tpcJZtijtS3vOc94KFWY0Fip2fUksa+l0v+IaSifDfv8oDM/2rvVP9dvlcCq eurQRmOCaioRh6HqtIywgcG2MdpQe88CKVC3a5y8VwiXGSVVqht7Lg1co6Uhq5UdVX/YUokyrJvX rTgnTtlBrjc3WmyRK6qNOpMrJNMysGAI4c6TiI19v7rnZycm0lmsz5SJQB/qSi6zKGo8C3Xcm99y fh+Xo7Bhv97Y1cHBZRWX5sAxP6fXBxY5fIf8ShHKN8nbruxgPdHKBOS6Gwt3kJmTRgPCtOkvAaEA FE= X-UI-Out-Filterresults: notjunk:1;V03:K0:HiRnOY1lc38=:aoJESFlZCm37nj337Kwm2Q t1f9diFXZ61aIEQFSgv3VTcFRjInw4/7OZBbXLvFH99O6XiE9goAIG0ecKsUQfSzNVylcBWPv svwaiXiDD5K6/4B4Lx/Z14I0fspzuL4TKwhUhPTtUfp+6ZNNeftjLSonkVQUnCb3reKCT5ssL r8iGuk/oE3RV3Mwd6BH++br2h2KqHFsDvd4ohXnQqduNA/LnLzAqWpPqBvoz17Bo6UTZw7XBi IwyXocj5LSQA3AHdkl/ei9sCindp1F0wvS8rjJubc4lDF4+BEuaCrkHt4IilBaUo8tyOK6bb9 cO6k2YJTmx6xW+e0o1RbQ/+qEfFGMGSLvWGIwYirTynBWLTeydrS6ELJ40VVgetc859cu1Pax UpGM1PzKBJEBqNUbncr+tCenABe8y93yk1/bTqL7s41QV8MVlg+UnjTVzE+svJcpjIY29BC5j Z4eqAlnPy3qn+nl39BTya+ghIxP+11S/3hsuU8kKJt6aNTTY7c/xXbYEFGpXAhQaRRDS9B7fU MXeBvsAnRH07JHluuf0B9G3isrRv9KWxz51t2BQQvUKir560GFfhVce0TLI2sGaCIgvUx/4NH AmGnNLSk7e5lI= Received-SPF: pass client-ip=212.227.15.19; envelope-from=dimech@gmx.com; helo=mout.gmx.net X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/02 16:01:23 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:124959 Archived-At: I shall explain better then. In my .texi files I customarily include comm= ands 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" > 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 > > >