* Is there any local variable to avoid asking me to save buffer on kill-buffer? @ 2024-12-16 6:59 Jean Louis 2024-12-16 7:14 ` Jean Louis 2024-12-16 15:00 ` Stefan Monnier via Users list for the GNU Emacs text editor 0 siblings, 2 replies; 10+ messages in thread From: Jean Louis @ 2024-12-16 6:59 UTC (permalink / raw) To: Help GNU Emacs 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? Maybe there is some local variable which I could set on opening of the buffer to kill the buffer on `C-x k' without getting bothered, anybody knows? Jean ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Is there any local variable to avoid asking me to save buffer on kill-buffer? 2024-12-16 6:59 Is there any local variable to avoid asking me to save buffer on kill-buffer? Jean Louis @ 2024-12-16 7:14 ` Jean Louis 2024-12-16 12:04 ` Tassilo Horn 2024-12-16 15:00 ` Stefan Monnier via Users list for the GNU Emacs text editor 1 sibling, 1 reply; 10+ messages in thread From: Jean Louis @ 2024-12-16 7:14 UTC (permalink / raw) To: Help GNU Emacs * Jean Louis <bugs@gnu.support> [2024-12-16 10:01]: > 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? > > Maybe there is some local variable which I could set on opening of the > buffer to kill the buffer on `C-x k' without getting bothered, anybody > knows? (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)) (message "Killed: " buffer-name))) I see that above attempt is again asking me, but function is called "no-ask". Is that a bug? -- Jean Louis ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Is there any local variable to avoid asking me to save buffer on kill-buffer? 2024-12-16 7:14 ` Jean Louis @ 2024-12-16 12:04 ` Tassilo Horn 2024-12-16 12:25 ` Eduardo Ochs 0 siblings, 1 reply; 10+ messages in thread From: Tassilo Horn @ 2024-12-16 12:04 UTC (permalink / raw) To: Help GNU Emacs Jean Louis <bugs@gnu.support> writes: > (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)) > (message "Killed: " buffer-name))) > > I see that above attempt is again asking me, but function is called > "no-ask". Is that a bug? Not really, but a bit strange maybe. kill-matching-buffers-no-ask calls kill-matching-buffers with no-ask arg set to t. That results in buffers being killed with kill-buffer instead of kill-buffer-ask. The latter would require confirmation for any buffer to be killed. However, kill-buffer itself will query anyhow in certain cases, especially when you have unsaved changes in the buffer which you probably have. So it depends on how one interprets "no-ask". The current interpretation seems to be "don't ask unless you might lose data" in contrast to "never" which you seem to expect. HTH, Tassilo ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Is there any local variable to avoid asking me to save buffer on kill-buffer? 2024-12-16 12:04 ` Tassilo Horn @ 2024-12-16 12:25 ` Eduardo Ochs 0 siblings, 0 replies; 10+ messages in thread From: Eduardo Ochs @ 2024-12-16 12:25 UTC (permalink / raw) To: Tassilo Horn; +Cc: Help GNU Emacs On Mon, 16 Dec 2024 at 09:04, Tassilo Horn <tsdh@gnu.org> wrote: > > Jean Louis <bugs@gnu.support> writes: > > > (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)) > > (message "Killed: " buffer-name))) > > > > I see that above attempt is again asking me, but function is called > > "no-ask". Is that a bug? > > Not really, but a bit strange maybe. kill-matching-buffers-no-ask calls > kill-matching-buffers with no-ask arg set to t. That results in buffers > being killed with kill-buffer instead of kill-buffer-ask. The latter > would require confirmation for any buffer to be killed. > > However, kill-buffer itself will query anyhow in certain cases, > especially when you have unsaved changes in the buffer which you > probably have. > > So it depends on how one interprets "no-ask". The current > interpretation seems to be "don't ask unless you might lose data" in > contrast to "never" which you seem to expect. > > HTH, > Tassilo Hi Jean, I use this in eev, bound to `M-k': (defun ee-kill-this-buffer () "Kill the current buffer with fewer warnings than `kill-this-buffer'. See: (find-eev-quick-intro \"3. Elisp hyperlinks\" \"go back\" \"`M-k'\") and: (find-eval-intro \"`M-k'\")" (interactive) (let ((kill-buffer-query-functions nil)) (kill-this-buffer))) it is simple and IIRC it only asks for confirmation when a buffer has a file associated to it and it is marked as modified... Cheers, Eduardo Ochs http://anggtwu.net/emacsconf2024.html ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Is there any local variable to avoid asking me to save buffer on kill-buffer? 2024-12-16 6:59 Is there any local variable to avoid asking me to save buffer on kill-buffer? Jean Louis 2024-12-16 7:14 ` Jean Louis @ 2024-12-16 15:00 ` Stefan Monnier via Users list for the GNU Emacs text editor 2024-12-16 16:13 ` Jean Louis 1 sibling, 1 reply; 10+ messages in thread From: Stefan Monnier via Users list for the GNU Emacs text editor @ 2024-12-16 15:00 UTC (permalink / raw) To: help-gnu-emacs > 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"? Stefan ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Is there any local variable to avoid asking me to save buffer on kill-buffer? 2024-12-16 15:00 ` Stefan Monnier via Users list for the GNU Emacs text editor @ 2024-12-16 16:13 ` Jean Louis 2024-12-16 19:39 ` Suhail Singh 0 siblings, 1 reply; 10+ messages in thread From: Jean Louis @ 2024-12-16 16:13 UTC (permalink / raw) To: Stefan Monnier; +Cc: help-gnu-emacs [-- Attachment #1: Type: text/plain, Size: 602 bytes --] * Stefan Monnier via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> [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 [-- Attachment #2: rcd-temp-buffer.el --] [-- Type: text/plain, Size: 5710 bytes --] ;;; rcd-temp-buffer.el --- RCD Temporary Buffer -*- lexical-binding: t; -*- ;; Copyright (C) 2016-2024 by Jean Louis ;; Author: Jean Louis <bugs@gnu.support> ;; 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 <http://www.gnu.org/licenses/>. ;;; 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-<f4>") #'kill-buffer) map)) (global-set-key (kbd "<f5>") #'rcd-temp-buffer) (provide 'rcd-temp-buffer) ;;; rcd-temp-buffer.el ends here ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Is there any local variable to avoid asking me to save buffer on kill-buffer? 2024-12-16 16:13 ` Jean Louis @ 2024-12-16 19:39 ` Suhail Singh 2024-12-16 21:02 ` Jean Louis 0 siblings, 1 reply; 10+ messages in thread From: Suhail Singh @ 2024-12-16 19:39 UTC (permalink / raw) To: help-gnu-emacs; +Cc: Stefan Monnier Jean Louis <bugs@gnu.support> writes: > (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) A "temporary" buffer with a buffer-file-name? What makes it "temporary"? -- Suhail ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Is there any local variable to avoid asking me to save buffer on kill-buffer? 2024-12-16 19:39 ` Suhail Singh @ 2024-12-16 21:02 ` Jean Louis 2024-12-16 21:26 ` Suhail Singh 0 siblings, 1 reply; 10+ messages in thread From: Jean Louis @ 2024-12-16 21:02 UTC (permalink / raw) To: Suhail Singh; +Cc: help-gnu-emacs, Stefan Monnier * Suhail Singh <suhailsingh247@gmail.com> [2024-12-16 22:41]: > Jean Louis <bugs@gnu.support> writes: > > > (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) > > A "temporary" buffer with a buffer-file-name? What makes it > "temporary"? rcd-temp-file-directory ➜ "/home/data1/protected/tmp/" Even files can be temporary files, not so? My temporary buffer with a buffer-file-name is considered temporary because it is intended for short-term use and is typically deleted or discarded after its purpose is served, regardless of whether it has a file name or is stored in a designated temporary directory like `rcd-temp-file-directory`. -- Jean Louis ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Is there any local variable to avoid asking me to save buffer on kill-buffer? 2024-12-16 21:02 ` Jean Louis @ 2024-12-16 21:26 ` Suhail Singh 2024-12-17 4:05 ` Jean Louis 0 siblings, 1 reply; 10+ messages in thread From: Suhail Singh @ 2024-12-16 21:26 UTC (permalink / raw) To: Suhail Singh; +Cc: help-gnu-emacs, Stefan Monnier Jean Louis <bugs@gnu.support> writes: > Even files can be temporary files, not so? Files can be temporary. However, buffers associated with them aren't generally referred to as "temporary buffers"; they are regular buffers. A temporary buffer has no file associated with it. -- Suhail ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Is there any local variable to avoid asking me to save buffer on kill-buffer? 2024-12-16 21:26 ` Suhail Singh @ 2024-12-17 4:05 ` Jean Louis 0 siblings, 0 replies; 10+ messages in thread From: Jean Louis @ 2024-12-17 4:05 UTC (permalink / raw) To: Suhail Singh; +Cc: help-gnu-emacs, Stefan Monnier * Suhail Singh <suhailsingh247@gmail.com> [2024-12-17 00:28]: > Jean Louis <bugs@gnu.support> writes: > > > Even files can be temporary files, not so? > > Files can be temporary. However, buffers associated with them aren't > generally referred to as "temporary buffers"; they are regular buffers. > A temporary buffer has no file associated with it. That's actually how it started, until they got temporary buffer in addition. :-) -- Jean Louis ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2024-12-17 4:05 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2024-12-16 6:59 Is there any local variable to avoid asking me to save buffer on kill-buffer? Jean Louis 2024-12-16 7:14 ` Jean Louis 2024-12-16 12:04 ` Tassilo Horn 2024-12-16 12:25 ` Eduardo Ochs 2024-12-16 15:00 ` Stefan Monnier via Users list for the GNU Emacs text editor 2024-12-16 16:13 ` Jean Louis 2024-12-16 19:39 ` Suhail Singh 2024-12-16 21:02 ` Jean Louis 2024-12-16 21:26 ` Suhail Singh 2024-12-17 4:05 ` Jean Louis
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.