From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jean Louis Newsgroups: gmane.emacs.help Subject: Re: Is there any local variable to avoid asking me to save buffer on kill-buffer? Date: Mon, 16 Dec 2024 19:13:16 +0300 Message-ID: References: <7f8a548d35d21c6436045ce11af22088.support1@rcdrun.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=_stw1.rcdrun.com-544627-1734370231-0001-2" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="18332"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mutt/2.2.12 (2023-09-09) Cc: help-gnu-emacs@gnu.org To: Stefan Monnier Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Mon Dec 16 18:31:29 2024 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 1tNEwK-0004d9-TY for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 16 Dec 2024 18:31:29 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tNEvw-0002Ec-Ok; Mon, 16 Dec 2024 12:31:04 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tNEvT-0001Rk-PO for help-gnu-emacs@gnu.org; Mon, 16 Dec 2024 12:30:45 -0500 Original-Received: from stw1.rcdrun.com ([217.170.207.13]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tNEvR-0002aX-NU for help-gnu-emacs@gnu.org; Mon, 16 Dec 2024 12:30:35 -0500 Original-Received: from localhost ([::ffff:197.239.10.219]) (AUTH: PLAIN admin, TLS: TLS1.3,256bits,ECDHE_RSA_AES_256_GCM_SHA384) by stw1.rcdrun.com with ESMTPSA id 000000000001BF33.00000000676063B6.00084F73; Mon, 16 Dec 2024 10:30:29 -0700 Mail-Followup-To: Stefan Monnier , help-gnu-emacs@gnu.org Content-Disposition: inline In-Reply-To: Received-SPF: pass client-ip=217.170.207.13; envelope-from=bugs@gnu.support; helo=stw1.rcdrun.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 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-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:148834 Archived-At: This is a MIME-formatted message. If you see this text it means that your E-mail software does not support MIME-formatted messages. --=_stw1.rcdrun.com-544627-1734370231-0001-2 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline * Stefan Monnier via Users list for the GNU Emacs text editor [2024-12-16 18:02]: > > I have bunch of temporary buffers which I regularly use, like 160 > > times in 8 days, and as they are truly temporary I do not want to > > answer the question on `C-x k' yes/no/save? > > AFAIK Emacs doesn't ask confirmation to kill "temporary buffers", so > I think the question is: what do you mean by "temporary buffers"? They are programmed, I press F5 and get new temporary buffer, it is related to the file name, but file is really not important. New buffer simply. -- Jean Louis --=_stw1.rcdrun.com-544627-1734370231-0001-2 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="rcd-temp-buffer.el" ;;; rcd-temp-buffer.el --- RCD Temporary Buffer -*- lexical-binding: t; -*- ;; Copyright (C) 2016-2024 by Jean Louis ;; Author: Jean Louis ;; Version: 0.1 ;; Package-Requires: (rcd-utilities) ;; Keywords: convenience tools ;; URL: https:// NOT YET rcd-temp-buffer-el.html ;; This file is not part of GNU Emacs. ;; This program is free software: you can redistribute it and/or ;; modify it under the terms of the GNU General Public License as ;; published by the Free Software Foundation, either version 3 of the ;; License, or (at your option) any later version. ;; ;; This program is distributed in the hope that it will be useful, but ;; WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License ;; along with this program. If not, see . ;;; Commentary: ;;; Change Log: ;;; Code: ;;; RCD TEMPORARY BUFFERS (defvar rcd-temp-buffer-name "RCD TEMPORARY BUFFER") (defvar rcd-temp-buffer-session-count 0) (defvar rcd-temp-buffer-list nil) (defvar rcd-temp-buffer-modes '(("adoc-mode" . "adoc") ("emacs-lisp-mode" . "el") ("lisp-mode" . ".lisp") ("markdown-mode" . ".md") ("org-mode" . "org") ("sql-mode" . "sql") ("fundamental-mode" . "txt") ("html-mode" . "html"))) (defun rcd-temp-buffer-next () "Switch to next available temporary buffer." (interactive) (let ((rcd-temp-buffer-list (reverse (rcd-list-matching-buffers rcd-temp-buffer-name)))) (cond ((and rcd-temp-buffer-list (member (current-buffer) rcd-temp-buffer-list)) (switch-to-buffer (next-circular-list-item rcd-temp-buffer-list (current-buffer)))) ((and rcd-temp-buffer-list (switch-to-buffer (car rcd-temp-buffer-list)))) (t (rcd-warning-message "No temporary buffers"))))) (defun rcd-temp-buffer-destroy-em () "Destroy all temporary buffers." (interactive) (kill-matching-buffers rcd-temp-buffer-name)) (defun rcd-temp-buffer (&optional name mode) "Generate new temporary buffer. In Emacs, you can effortlessly generate a new temporary buffer to use for various purposes. A temporary buffer is essentially a buffer that exists temporarily in your current Emacs session and gets discarded once you close it. This feature is particularly handy when you want to quickly jot down notes, brainstorm ideas, or experiment with some code without cluttering your existing buffers. Standard temporary buffer named \"*scratch*\" is specifically designed for temporary use. Once you have created the temporary buffer, you can freely modify it, insert text, execute Emacs commands, or write code within it. It behaves just like any other Emacs buffer. Moreover, you can switch between this temporary buffer and other buffers in your Emacs session using the usual buffer-switching commands like \"C-x b\" or \"C-x o\". This flexibility allows you to seamlessly navigate between different buffers while working on your project. Furthermore, Emacs offers a multitude of features and functionalities that you can leverage within temporary buffers. You can customize your temporary buffer's major mode to suit your specific needs, enabling syntax highlighting, indentation, and other language-specific functionalities. This ensures that your temporary buffer provides an environment tailored to your current task, whether it's writing prose, coding, or organizing information. Temporary buffers in Emacs are incredibly versatile and create a dynamic workspace where you can experiment, brainstorm, and iterate without being confined to a particular document or file. They seamlessly complement Emacs's overall philosophy of flexibility and extensibility, making it a powerful text editor for handling various projects and workflows." (interactive) (let* ((file-name (concat rcd-temp-file-directory (format-time-string "%Y-%m-%d-%H:%M:%S-") rcd-temp-buffer-name ".txt")) (buffer (or name (concat "*" rcd-temp-buffer-name "*")))) (switch-to-buffer (generate-new-buffer buffer)) (setq buffer-file-name file-name) (save-buffer) (setq rcd-temp-buffer-session-count (1+ rcd-temp-buffer-session-count)) (rcd-general-log (concat "Opened " buffer-file-name) nil 1 nil nil nil 13) (if current-prefix-arg (let ((mode (rcd-choose (map-keys rcd-temp-buffer-modes) "Major mode: "))) (funcall (intern mode))) (funcall (intern (or mode "fundamental-mode")))) (rcd-temp-buffer-minor-mode) buffer-file-name)) (defun rcd-temp-buffer-ask-name () "Generate new temporary buffer by asking for buffer name." (interactive) (rcd-temp-buffer (rcd-ask-get "Buffer name: "))) (defun rcd-show-prominently (text) "This function was meant to make better presentation of the TEXT." (let ((buffer (rcd-temp-buffer nil "*RCD Showing Prominently*"))) (switch-to-buffer buffer) (insert text))) (defun rcd-temp-buffer-kill-current () "Kill current buffer without asking." (interactive) (let ((buffer-name (buffer-name (current-buffer)))) (kill-matching-buffers-no-ask (regexp-quote buffer-name)) (rcd-message "Killed: %s" buffer-name))) (define-minor-mode rcd-temp-buffer-minor-mode "A minor mode for RCD temporary buffers." :init-value nil :lighter "RCD Temp Buffer Mode" :keymap (let ((map (make-sparse-keymap))) (define-key map (kbd "C-x k") #'rcd-temp-buffer-kill-current) (define-key map (kbd "C-") #'kill-buffer) map)) (global-set-key (kbd "") #'rcd-temp-buffer) (provide 'rcd-temp-buffer) ;;; rcd-temp-buffer.el ends here --=_stw1.rcdrun.com-544627-1734370231-0001-2--