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 23:54:31 +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="32089"; 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 23:57:09 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 1kZilB-0008AQ-2x for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 02 Nov 2020 23:57:09 +0100 Original-Received: from localhost ([::1]:51204 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kZil9-0002PK-Vd for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 02 Nov 2020 17:57:08 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48884) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZiii-0002Nv-QF for help-gnu-emacs@gnu.org; Mon, 02 Nov 2020 17:54:38 -0500 Original-Received: from mout.gmx.net ([212.227.15.15]:60517) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZiig-0006AJ-6l for help-gnu-emacs@gnu.org; Mon, 02 Nov 2020 17:54:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1604357671; bh=rF1ATr2QPTULXTc3Un+irvyYA5b3Yde/A4n+ws8DfxU=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=fepirui2O1lT2pvfOUDRzpm+oCcslqThcmyN1s2BWSbObd9qtb30wDY5YVTRiTAaK y+FOGmNwYzomcpgmf2UOBGnTJtCSUL9DZN9kZ62SEE11KPfvDMvWMm16Hu1pJYrOeG G4gdI9pzUCeq2acZzuFXDaWF/+4SfJWPkAxUQbms= 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 23:54:31 +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:3JTwKKxHv/gA9b2pfbqFuZmkvuWovcBo19WNG2KuCd6Zb8LprR0f1KS+ceWdHLVgbKf3j 2xFey4DSTbi9o0T/XUdRRv8cZM+9pP1xgZFbut3wi/RbZ4ehFotBXLa6rD0gxb9b010LuovQTmit ZELNcCN4KkPcDywbiK/ByEJCJucrUTldj8qlJslpQVW060+i+4fcPtlyAXYViXZ0mtm8avodmyAV g29zOv1W6eXl49/+rthtQalCm4+XDiW2eQefExbQb7GumufQ9SwmYruKFDJ1GpHZUJ2EYcYjjOtC Gg= X-UI-Out-Filterresults: notjunk:1;V03:K0:v20KFnoiDQ4=:Jyh6S4+IHxRFyccRu/4FHl ZjuNNDn/ofnVmniEVgQKPNUZoPCt8t2aOlGt7doyzmYOmgeW6PLE38XDC0xf11FcEIvqtAf5H i5RHLRSydPJgpxXlLFANwYiCA5E/l4721YiF722FHPi4wftozpXTnTWnLNUu+Y1biYv75HJiu TEauw6hiAndLbQ3sA/Zoh204qLQIJf4HBMy0CbYPrhiXU8BzNiHXQfWTJyrixYsIo97J5fAyo use1VdK/Hi4dlvhhDhDP1f3LgqOcRsYbHjCWDX5kSL4cAc3gcF6PB7TTUoXp0T8toPfLJ+7i1 ERiLvwtq9kkaic3Dcyx0jWau5kD7BxpbFTBBdD59mFkDBmFLrTsRMXmAI/vAfy8Zoemw4El5w S3JY3sZmK9T4gNCHQDosHZjM+Umv79E1WNMimv66uRd6c4lYGB2R8wGyJK++zV1ExnSNemgf1 HADO8vIwzQek74a5wrN/OCVVAMNRu21bkDGj9KjbGK0WxhuwPYZq4mev+SiBiexUiVxbGDoEJ UqNQvAmzgHSdwr0XwGKd2+fbwqHp9be7mIOxwOCS/i7NiLHhUihxACJL46RmD93Zi1U7F+HDA VaJeEl2ue22kA= Received-SPF: pass client-ip=212.227.15.15; envelope-from=dimech@gmx.com; helo=mout.gmx.net X-detected-operating-system: by eggs.gnu.org: First seen = 2020/11/02 17:54:32 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:124963 Archived-At: I think something similar to (let ((modes (list would work. But by forcing a mode change in the current buffer. not based= on file extension. > 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 > > >