* completing-read to set the mode for a buffer
@ 2022-07-09 0:52 carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-09 1:51 ` Emanuel Berg
0 siblings, 1 reply; 4+ messages in thread
From: carlmarcos--- via Users list for the GNU Emacs text editor @ 2022-07-09 0:52 UTC (permalink / raw)
To: Help Gnu Emacs
Am using completing-read to set the mode for a buffer. What would be the advantage of defining modes in the following way, rather than with a normal list with "emacs-lisp-mode", "org-mode", and "sh-script" ?
I use (funcall (intern mode)) to set the mode for the buffer.
(defvar modes
'( ("emacs-lisp-mode" . "el")
("org-mode" . "org")
("sh-script" . "sh")))
(completing-read " Mode: " (map-keys modes) nil t)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: completing-read to set the mode for a buffer
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
2022-07-09 3:42 ` carlmarcos--- via Users list for the GNU Emacs text editor
0 siblings, 1 reply; 4+ messages in thread
From: Emanuel Berg @ 2022-07-09 1:51 UTC (permalink / raw)
To: help-gnu-emacs
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: completing-read to set the mode for a buffer
2022-07-09 1:51 ` Emanuel Berg
@ 2022-07-09 3:42 ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-10 4:20 ` Emanuel Berg
0 siblings, 1 reply; 4+ messages in thread
From: carlmarcos--- via Users list for the GNU Emacs text editor @ 2022-07-09 3:42 UTC (permalink / raw)
To: Emanuel Berg; +Cc: help-gnu-emacs
Jul 9, 2022, 01:51 by incal@dataswamp.org:
> 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 ...
>
I already have such file-related mode association. For my case, the buffer on which
the mode is applied does not have a programming or markup file associated with it yet.
> ;;; -*- 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
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: completing-read to set the mode for a buffer
2022-07-09 3:42 ` carlmarcos--- via Users list for the GNU Emacs text editor
@ 2022-07-10 4:20 ` Emanuel Berg
0 siblings, 0 replies; 4+ messages in thread
From: Emanuel Berg @ 2022-07-10 4:20 UTC (permalink / raw)
To: help-gnu-emacs
carlmarcos--- via Users list for the GNU Emacs text editor wrote:
> the buffer on which the mode is applied does not have
> a programming or markup file associated with it yet.
Yeah but that's where you start then rather than preparing
Emacs to handle "nothing" specifically.
>> (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) )
Wow, sweat heaven! Especially the left one how it waves and
gets deeper and everything and suddenly stops. Maybe in
combination with the music ...
--
underground experts united
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-07-10 4:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2022-07-09 3:42 ` carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-10 4:20 ` Emanuel Berg
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.