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

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

Adding major-mode selection to new buffer


From: carlmarcos
Subject: Adding major-mode selection to new buffer
Date: Tue, 28 Jun 2022 00:46:15 +0200 (CEST)

With the following function I can make a new buffer with a name.  Would also 
like to set the major-mode from the minibuffer.

Perhaps using `completing-read` 

(cseq '("sh-mode" "emacs-lisp-mode" "org-mode" "f90-mode" "c-mode" ))
(csel  (completing-read "Major Mode: " cseq nil t "org-mode"))

How can I introduce the above functionality in the `workbench' function?

(defun workbench (&optional name)
  "Make new buffer with unique name based on NAME."
  (interactive "s Buffer Name: ")
  (switch-to-buffer
   (generate-new-buffer
    (if (string-blank-p name) "wb" name))))


reply via email to

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