unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Emanuel Berg <incal@dataswamp.org>
To: help-gnu-emacs@gnu.org
Subject: Re: completing-read to set the mode for a buffer
Date: Sat, 09 Jul 2022 03:51:57 +0200	[thread overview]
Message-ID: <87v8s7oxxe.fsf@dataswamp.org> (raw)
In-Reply-To: N6VRPiS--3-2@tutanota.com

carlmarcos--- via Users list for the GNU Emacs text editor wrote:

> (defvar modes
>   '( ("emacs-lisp-mode" . "el")
>      ("org-mode" . "org")
>      ("sh-script" . "sh")))
>
> (completing-read " Mode: " (map-keys modes) nil t)

You should automate that. It is already to a large extent but
if it isn't, or if your unhappy with some of the choices, you
can set that up yourself. But after it's setup, it does it
for you. You can change it ...

;;; -*- lexical-binding: t -*-
;;
;; this file:
;;   https://dataswamp.org/~incal/emacs-init/mode-by-filename.el

(setq auto-mode-alist `(
    ("\\.bal\\'"     . balance-mode)
    ("\\.cl\\'"      . common-lisp-mode)
    ("\\.dat\\'"     . gnuplot-mode)
    ("\\.gpi\\'"     . gnuplot-mode)
    ("\\.grm\\'"     . sml-mode)
    ("\\.lu\\'"      . lua-mode)
    ("\\.nqp\\'"     . perl-mode)
    ("\\.php\\'"     . html-mode)
    ("\\.pic\\'"     . nroff-mode)
    ("\\.pl\\'"      . prolog-mode)
    ("\\.sed\\'"     . conf-mode)
    ("\\.service\\'" . conf-mode)
    ("\\.tap\\'"     . gcode-mode)
    ("\\.tex\\'"     . latex-mode)
    ("\\.xr\\'"      . conf-xdefaults-mode)
    ("keys\\'"       . conf-mode)
    ("*"             . text-mode)
  ,@auto-mode-alist) )

Uhm, what is 'balance-mode' BTW? It's not
installed/available, either.

It sure isn't this [1] (and both links are broken) because
I don't deal with credit cards.

Maybe that was something I did I don't remember.
I don't remember.

Anyway to the OP you see how it works, right?
Pretty straightforward. Like C++. LOL

[1] https://www.emacswiki.org/emacs/BalanceMode

-- 
underground experts united
https://dataswamp.org/~incal




  reply	other threads:[~2022-07-09  1:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-09  0:52 completing-read to set the mode for a buffer carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-09  1:51 ` Emanuel Berg [this message]
2022-07-09  3:42   ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-10  4:20     ` Emanuel Berg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87v8s7oxxe.fsf@dataswamp.org \
    --to=incal@dataswamp.org \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).