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

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

Re: completing-read to set the mode for a buffer


From: Emanuel Berg
Subject: Re: completing-read to set the mode for a buffer
Date: Sat, 09 Jul 2022 03:51:57 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

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 via email to

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