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: Adding major-mode selection to new buffer Date: Wed, 29 Jun 2022 00:05:47 +0200 Message-ID: References: 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="12601"; mail-complaints-to="usenet@ciao.gmane.io" Cc: carlmarcos@tutanota.com, Help Gnu Emacs To: Jean Louis Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jun 29 00:07:10 2022 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 1o6JMT-00037T-Ux for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 29 Jun 2022 00:07:09 +0200 Original-Received: from localhost ([::1]:34288 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o6JMS-0005Lr-WF for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 28 Jun 2022 18:07:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49398) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o6JLi-0005Kd-FY for help-gnu-emacs@gnu.org; Tue, 28 Jun 2022 18:06:22 -0400 Original-Received: from mout.gmx.net ([212.227.15.18]:45705) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o6JLg-0007hz-9M for help-gnu-emacs@gnu.org; Tue, 28 Jun 2022 18:06:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1656453947; bh=X529Bq1FdivB96cWz4W6GuRXtQEAi/lKhHgoxbg2Cmw=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=A+xP/zY/TDIDET3MV4jEqpPnBiPXPcXL0k2w/Tw1J+D0n+4PYcFIn2eFPe9HJrIFj C/4NVlSaxdYPb5uU0x91A8hWbkkRjoFZHsgQRXn5oKT8njSDXw9xacdrBOjQX/w9ZY qsaUzLAt7MLbUQ8YHbOIZ91hlx80D9KMDN9+Hmzw= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from [92.251.127.164] ([92.251.127.164]) by web-mail.gmx.net (3c-app-mailcom-bs02.server.lan [172.19.170.129]) (via HTTP); Wed, 29 Jun 2022 00:05:47 +0200 Importance: normal Sensitivity: Normal In-Reply-To: X-UI-Message-Type: mail X-Priority: 3 X-Provags-ID: V03:K1:NnYdAU5Y9ScN3D06V0IdkuDxMGTzEPZ+JaJ+rV/rQ4/ET+2oVpf1efNwohqJYxmkM0+WK tJc6mb7c0dccnEUhOqwNHZASg6GqJY/ALnoRnde8vbenp3wBsM16NcHcOJjarHF0B8vpvqnhMPUn CXnRbdcf+jCwKqWx6zrwPb4PGHrv573Mi+mDGkerS5u6C0JKwEmN/ruCINwCfycECkeL1fNsDr4c p8AdhkfvYtcyeIjB/IxZTQbL36dKnnZ+jcbbPWQCT9k5w5QmJQeHObLFuwDxhdz4XfKBrpDLptwx vU= X-UI-Out-Filterresults: notjunk:1;V03:K0:8VaAguN2Alw=:g2f0Jo80Q0A2Gd7lUpIbMM HX9rh92IvIcdr+FBFrHisomBgY3EVzy0P2OFvG6qrfo9/7n7Q5FVYBQZYzbqx8wrxj45eG6vo k4duwXGg7s6LFFLqu0wW4IFhy3E1Y2UbFIDh0AIv9W5/wZz36/Lo4RAmevlTTbgsS/8KJq16F IJz7lLj1a0vFMhZb1DCjwLcXmqW4SnWiLYG9oRITG+wDyq3TtYsIrLYpZYjB6Kmr6yO8pSK5g M0ljCdHWLTayGjTfgFu94tgWlhHZu3yHCRjJxWX9NGH3KpAO3G26L4p+DApuzerRcWylSze0e svjDl45K4qq6ZDCUZsWiAJwHBI09ZqY1J2LMJaXQporuCwvB6e2V06YZ18OrX+e4YROzgaMsy MDMDe24ckhLGg1DOcE/0OzswaYWSilYQoE/AauyK3WCXUa6i/gNifgNeQlxOKcJsWeXOopddy LgF3GJXdJJcl5GVUsad108IaLKUBsoxeeDqZnzR/dK4jqcZHw0yReODkX8Xk+lBFItKTS2n1F 3GAM0hJJyz6fZYaURnIXHy9lpP4blziK06P8VTEUQVxiphQgKTQSh925bX1PSQRdeOLtCix23 axjlx3YKD46Leifb7SZyitAK+w+FVEQVvyohKtViiGohLUZlZru2CsJ8QUaALgtjqOW9itD75 Pud68RYd5IoWOz2sOOYoF8vXvzig/l91SKNZKEFhwdYdy8LCR/87KoZdlp0BdCZNsmY8KZPhR IetQ+2tQFC4hyf0v/HLUFpE2d04IHfh1fynufqFXBZ7yxcLdpHjvvbmtRD+zxIleGYOufdN9 Received-SPF: pass client-ip=212.227.15.18; envelope-from=dimech@gmx.com; helo=mout.gmx.net 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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 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:138177 Archived-At: > Sent: Tuesday, June 28, 2022 at 10:21 PM > From: "Jean Louis" > To: carlmarcos@tutanota=2Ecom > Cc: "Help Gnu Emacs" > Subject: Re: Adding major-mode selection to new buffer > > * carlmarcos--- via Users list for the GNU Emacs text editor [2022-06-28 01:51]: > > With the following function I can make a new buffer with a name=2E=C2= =A0 Would also=20 > > like to set the major-mode from the minibuffer=2E > >=20 > > Perhaps using `completing-read`=20 > >=20 > > (cseq '("sh-mode" "emacs-lisp-mode" "org-mode" "f90-mode" "c-mode" )) > > (csel=C2=A0 (completing-read "Major Mode: " cseq nil t "org-mode")) > >=20 > > How can I introduce the above functionality in the `workbench' functio= n? > >=20 > > (defun workbench (&optional name) > > =C2=A0 "Make new buffer with unique name based on NAME=2E" > > =C2=A0 (interactive "s Buffer Name: ") > > =C2=A0 (switch-to-buffer > > =C2=A0=C2=A0 (generate-new-buffer > > =C2=A0=C2=A0=C2=A0 (if (string-blank-p name) "wb" name)))) >=20 > I am using this below to open up new temporary buffers with name > assigned or with automatic name, and with the possibility to choose > the major mode=2E How can the code be modified to have filename saved with the following for= mat? %Y-%m-%d-T%H:%M:%S---=2Etxt =20 > {C-u M-x rcd-temp-buffer RET} will ask for mode to be used >=20 > {M-x rcd-temp-buffer RET}} will open new temporary buffer >=20 > {M-x rcd-temp-buffer RET}} will open new temporary buffer >=20 > {M-x rcd-temp-buffer-ask-name RET} will ask for buffer name >=20 > {C-u M-x rcd-temp-buffer-ask-name RET} will ask for buffer name and > for the mode >=20 > Code: >=20 > (defvar rcd-temp-buffer-name "RCD TEMPORARY BUFFER") >=20 > (defvar rcd-temp-file-directory "~/tmp/") >=20 > (defvar rcd-temp-buffer-mode-history nil) >=20 > (defvar rcd-temp-buffer-modes '(("adoc-mode" =2E "adoc") > ("emacs-lisp-mode" =2E "el") > ("lisp-mode" =2E "=2Elisp") > ("markdown-mode" =2E "=2Emd") > ("org-mode" =2E "org") > ("sql-mode" =2E "sql") > ("fundamental-mode" =2E "txt") > ("html-mode" =2E "html"))) >=20 > (defun rcd-temp-buffer (&optional name mode) > "Generate new temporary buffer=2E" > (interactive "p") > (let* ((format (concat "*" rcd-temp-buffer-name "%s%s*")) > (buffer (if name (format format ": " name) (format format "" ""))) > (file-name (concat rcd-temp-file-directory (format-time-string "%Y-%m-= %d-%H:%M:%S=2Etxt")))) > (switch-to-buffer (generate-new-buffer buffer)) > (setq buffer-file-name file-name) > (if current-prefix-arg > (let* ((mode (completing-read > "Mode: " > (map-keys rcd-temp-buffer-modes) nil t nil > 'rcd-temp-buffer-mode-history))) > (funcall (intern mode))) > (funcall (intern (or mode "fundamental-mode")))) > buffer-file-name)) >=20 > (defun rcd-temp-buffer-ask-name () > "Generate new temporary buffer by asking for buffer name=2E" > (interactive) > (rcd-temp-buffer > (read-from-minibuffer "Buffer name: "))) >=20 > (global-set-key (kbd "") #'rcd-temp-buffer) >=20 > --=20 > Jean >=20 > Take action in Free Software Foundation campaigns: > https://www=2Efsf=2Eorg/campaigns >=20 > In support of Richard M=2E Stallman > https://stallmansupport=2Eorg/ >=20 >