* Emacs ignores modified state of "untitled" buffer @ 2010-05-19 14:52 Stefan Vollmar 2010-05-19 15:04 ` Drew Adams ` (2 more replies) 0 siblings, 3 replies; 22+ messages in thread From: Stefan Vollmar @ 2010-05-19 14:52 UTC (permalink / raw) To: Emacs mailing list [-- Attachment #1: Type: text/plain, Size: 931 bytes --] Hello, we have a user who wants to always open Emacs with a new "untitled" buffer so he can start writing right away without having to think of a file name first (similar to a "New Document" feature in Mac and Windows programs). If we try this in site-start.el: (generate-new-buffer "untitled") (switch-to-buffer "untitled") we are almost there - Emacs starts with the new "untitled" buffer. However, if he then exits Emacs, Emacs does not warn about a modified buffer and potential data loss, although the buffer is marked dirty. How can we get the usual behaviour for this new buffer? Many thanks in advance, Stefan -- Dr. Stefan Vollmar, Dipl.-Phys. Head of IT group Max-Planck-Institut für neurologische Forschung Gleuelerstr. 50, 50931 Köln, Germany Tel.: +49-221-4726-213 FAX +49-221-4726-298 Tel.: +49-221-478-5713 Mobile: 0160-93874279 Email: vollmar@nf.mpg.de http://www.nf.mpg.de [-- Attachment #2: smime.p7s --] [-- Type: application/pkcs7-signature, Size: 4409 bytes --] ^ permalink raw reply [flat|nested] 22+ messages in thread
* RE: Emacs ignores modified state of "untitled" buffer 2010-05-19 14:52 Emacs ignores modified state of "untitled" buffer Stefan Vollmar @ 2010-05-19 15:04 ` Drew Adams 2010-05-19 20:34 ` Stephen Berman 2010-05-20 12:45 ` Kevin Rodgers 2 siblings, 0 replies; 22+ messages in thread From: Drew Adams @ 2010-05-19 15:04 UTC (permalink / raw) To: 'Stefan Vollmar', 'Emacs mailing list' > we have a user who wants to always open Emacs with a new > "untitled" buffer so he can start writing right away without > having to think of a file name first (similar to a "New > Document" feature in Mac and Windows programs). If we try > this in site-start.el: > > (generate-new-buffer "untitled") > (switch-to-buffer "untitled") > > we are almost there - Emacs starts with the new "untitled" > buffer. However, if he then exits Emacs, Emacs does not warn > about a modified buffer and potential data loss, although the > buffer is marked dirty. How can we get the usual behaviour > for this new buffer? The buffer is not associated with a file. Try (find-file "untitled") instead of the code you're using. If you do `C-h k', then choose `File > Visit New File', you'll see that that menu item corresponds to command `find-file'. ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Emacs ignores modified state of "untitled" buffer 2010-05-19 14:52 Emacs ignores modified state of "untitled" buffer Stefan Vollmar 2010-05-19 15:04 ` Drew Adams @ 2010-05-19 20:34 ` Stephen Berman 2010-05-20 12:45 ` Kevin Rodgers 2 siblings, 0 replies; 22+ messages in thread From: Stephen Berman @ 2010-05-19 20:34 UTC (permalink / raw) To: help-gnu-emacs On Wed, 19 May 2010 16:52:12 +0200 Stefan Vollmar <vollmar@nf.mpg.de> wrote: > we have a user who wants to always open Emacs with a new "untitled" > buffer so he can start writing right away without having to think of a > file name first (similar to a "New Document" feature in Mac and > Windows programs). If we try this in site-start.el: > > (generate-new-buffer "untitled") > (switch-to-buffer "untitled") > > we are almost there - Emacs starts with the new "untitled" > buffer. However, if he then exits Emacs, Emacs does not warn about a > modified buffer and potential data loss, although the buffer is marked > dirty. How can we get the usual behaviour for this new buffer? How about setting buffer-offer-save to t (with setq-default if you want it for all buffers)? Steve Berman ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Emacs ignores modified state of "untitled" buffer 2010-05-19 14:52 Emacs ignores modified state of "untitled" buffer Stefan Vollmar 2010-05-19 15:04 ` Drew Adams 2010-05-19 20:34 ` Stephen Berman @ 2010-05-20 12:45 ` Kevin Rodgers 2010-05-20 13:29 ` Drew Adams 2 siblings, 1 reply; 22+ messages in thread From: Kevin Rodgers @ 2010-05-20 12:45 UTC (permalink / raw) To: help-gnu-emacs Stefan Vollmar wrote: > we have a user who wants to always open Emacs with a new "untitled" > buffer so he can start writing right away without having to think of a > file name first (similar to a "New Document" feature in Mac and > Windows programs). If we try this in site-start.el: > > (generate-new-buffer "untitled") > (switch-to-buffer "untitled") > > we are almost there - Emacs starts with the new "untitled" > buffer. However, if he then exits Emacs, Emacs does not warn about a > modified buffer and potential data loss, although the buffer is marked > dirty. How can we get the usual behaviour for this new buffer? See switch-to-new-untitled-buffer in http://lists.gnu.org/archive/html/gnu-emacs-sources/2008-09/msg00016.html Here is the Commentary: ;; The switch-to-new-buffer command is like switch-to-buffer, but it ;; generates a new buffer name instead of prompting the user. It sets ;; buffer-offer-save to protect against inadvertant data loss via ;; kill-emacs. And it adds a buffer-local query function to protect ;; against inadvertant data loss via kill-buffer. ;; ;; switch-to-new-scratch-buffer and switch-to-new-untitled buffer are ;; convenience commands, for creating new *scratch* buffers (like Emacs) ;; and new "Untitled" buffers (like other text editors). ;; ;; switch-to-new-buffer is added to the menu bar Buffers menu. -- Kevin Rodgers Denver, Colorado, USA ^ permalink raw reply [flat|nested] 22+ messages in thread
* RE: Emacs ignores modified state of "untitled" buffer 2010-05-20 12:45 ` Kevin Rodgers @ 2010-05-20 13:29 ` Drew Adams 2010-05-20 14:00 ` Stefan Vollmar 2010-05-21 1:56 ` Kevin Rodgers 0 siblings, 2 replies; 22+ messages in thread From: Drew Adams @ 2010-05-20 13:29 UTC (permalink / raw) To: 'Kevin Rodgers', help-gnu-emacs > > we have a user who wants to always open Emacs with a new "untitled" > > buffer so he can start writing right away without having > > to think of a file name first (similar to a "New Document" feature > > in Mac and Windows programs). If we try this in site-start.el: > > > > (generate-new-buffer "untitled") > > (switch-to-buffer "untitled") > > > > we are almost there - Emacs starts with the new "untitled" > > buffer. However, if he then exits Emacs, Emacs does not > > warn about a modified buffer and potential data loss, although the > > buffer is marked dirty. How can we get the usual behaviour for > > this new buffer? > > See switch-to-new-untitled-buffer in > http://lists.gnu.org/archive/html/gnu-emacs-sources/2008-09/ms > g00016.html > > Here is the Commentary: > > ;; The switch-to-new-buffer command is like switch-to-buffer, but it > ;; generates a new buffer name instead of prompting the user. It sets > ;; buffer-offer-save to protect against inadvertant data loss via > ;; kill-emacs. And it adds a buffer-local query function to protect > ;; against inadvertant data loss via kill-buffer. > ;; > ;; switch-to-new-scratch-buffer and switch-to-new-untitled buffer are > ;; convenience commands, for creating new *scratch* buffers > (like Emacs) > ;; and new "Untitled" buffers (like other text editors). > ;; > ;; switch-to-new-buffer is added to the menu bar Buffers menu. What am I missing? What is wrong with just using (find-file "untitled")? If a buffer is associated with a file name (which is what `find-file' does) then Emacs asks you about saving it. What else is the OP asking for? Everyone seems to be jumping through hoops here, and my mail with this simple suggestion was ignored, so I must not be getting it. I really would like to know what I'm missing. ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Emacs ignores modified state of "untitled" buffer 2010-05-20 13:29 ` Drew Adams @ 2010-05-20 14:00 ` Stefan Vollmar 2010-05-21 2:00 ` Kevin Rodgers 2010-05-21 1:56 ` Kevin Rodgers 1 sibling, 1 reply; 22+ messages in thread From: Stefan Vollmar @ 2010-05-20 14:00 UTC (permalink / raw) To: Drew Adams; +Cc: help-gnu-emacs [-- Attachment #1: Type: text/plain, Size: 2014 bytes --] Dear Drew, On 20.05.2010, at 15:29, Drew Adams wrote: >>> we have a user who wants to always open Emacs with a new "untitled" >>> buffer so he can start writing right away without having >>> to think of a file name first (similar to a "New Document" feature >>> in Mac and Windows programs). If we try this in site-start.el: >>> >>> (generate-new-buffer "untitled") >>> (switch-to-buffer "untitled") >>> >>> we are almost there - Emacs starts with the new "untitled" >>> buffer. However, if he then exits Emacs, Emacs does not >>> warn about a modified buffer and potential data loss, although the >>> buffer is marked dirty. How can we get the usual behaviour for >>> this new buffer? [...] > What am I missing? What is wrong with just using (find-file "untitled")? > > If a buffer is associated with a file name (which is what `find-file' does) then > Emacs asks you about saving it. What else is the OP asking for? > > Everyone seems to be jumping through hoops here, and my mail with this simple > suggestion was ignored, so I must not be getting it. I really would like to know > what I'm missing. Sorry for being late with our reply (your first answer was almost within seconds of the intial question - superb!), but I was only now able to test it. (find-file "untitled") does indeed solve our specific problem quite neatly. Maybe one thing could still be improved: if the "untitled" buffer is dirty and Emacs asks where to save it, the directory now defaults to Emacs' bin directory - so (find-file "~/untitled") is an even better choice for us. switch-to-new-untitled-buffer does not seem to be part of Emacs 23.2. Thanks! Warm regards, Stefan -- Dr. Stefan Vollmar, Dipl.-Phys. Head of IT group Max-Planck-Institut für neurologische Forschung Gleuelerstr. 50, 50931 Köln, Germany Tel.: +49-221-4726-213 FAX +49-221-4726-298 Tel.: +49-221-478-5713 Mobile: 0160-93874279 Email: vollmar@nf.mpg.de http://www.nf.mpg.de [-- Attachment #2: smime.p7s --] [-- Type: application/pkcs7-signature, Size: 4409 bytes --] ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Emacs ignores modified state of "untitled" buffer 2010-05-20 14:00 ` Stefan Vollmar @ 2010-05-21 2:00 ` Kevin Rodgers 2010-05-21 2:06 ` Lennart Borgman 0 siblings, 1 reply; 22+ messages in thread From: Kevin Rodgers @ 2010-05-21 2:00 UTC (permalink / raw) To: help-gnu-emacs Stefan Vollmar wrote: > switch-to-new-untitled-buffer does not seem to be part of Emacs 23.2. That's why I posted a link to the sources-gnu-emacs archive. (The mailing list is for add-on source code, not Emacs source code.) -- Kevin Rodgers Denver, Colorado, USA ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Emacs ignores modified state of "untitled" buffer 2010-05-21 2:00 ` Kevin Rodgers @ 2010-05-21 2:06 ` Lennart Borgman 0 siblings, 0 replies; 22+ messages in thread From: Lennart Borgman @ 2010-05-21 2:06 UTC (permalink / raw) To: Kevin Rodgers; +Cc: help-gnu-emacs On Fri, May 21, 2010 at 4:00 AM, Kevin Rodgers <kevin.d.rodgers@gmail.com> wrote: >> >> switch-to-new-untitled-buffer does not seem to be part of Emacs 23.2. > > That's why I posted a link to the sources-gnu-emacs archive. (The mailing > list > is for add-on source code, not Emacs source code.) Kevin, I think it is a good idea. Have you taken up the idea on Emacs Devel mailing list? ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Emacs ignores modified state of "untitled" buffer 2010-05-20 13:29 ` Drew Adams 2010-05-20 14:00 ` Stefan Vollmar @ 2010-05-21 1:56 ` Kevin Rodgers 2010-05-21 8:03 ` Stefan Vollmar 2010-05-21 14:20 ` Drew Adams 1 sibling, 2 replies; 22+ messages in thread From: Kevin Rodgers @ 2010-05-21 1:56 UTC (permalink / raw) To: help-gnu-emacs Drew Adams wrote: > What am I missing? What is wrong with just using (find-file "untitled")? > > If a buffer is associated with a file name (which is what `find-file' does) then > Emacs asks you about saving it. What else is the OP asking for? C-x C-s won't ask. > Everyone seems to be jumping through hoops here, and my mail with this simple > suggestion was ignored, so I must not be getting it. I really would like to know > what I'm missing. I can think of a couple nuisances: * If the buffer gets saved to file "untitled", a subsequent invocation of emacs will visit that file, not an empty buffer. * Changes to the buffer will be auto-saved to the #untitled# file, and a subsequent invocation of emacs will ask to recover the file (if the 2 invocations are concurrent, or if the first invocation exited uncleanly). -- Kevin Rodgers Denver, Colorado, USA ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Emacs ignores modified state of "untitled" buffer 2010-05-21 1:56 ` Kevin Rodgers @ 2010-05-21 8:03 ` Stefan Vollmar 2010-05-21 13:17 ` Kevin Rodgers 2010-05-21 14:20 ` Drew Adams 1 sibling, 1 reply; 22+ messages in thread From: Stefan Vollmar @ 2010-05-21 8:03 UTC (permalink / raw) To: Kevin Rodgers; +Cc: Emacs mailing list [-- Attachment #1: Type: text/plain, Size: 1603 bytes --] Dear Kevin, On 21.05.2010, at 03:56, Kevin Rodgers wrote: > I can think of a couple nuisances: > > * If the buffer gets saved to file "untitled", a subsequent invocation of emacs > will visit that file, not an empty buffer. > > * Changes to the buffer will be auto-saved to the #untitled# file, and a subsequent invocation of emacs will ask to recover the file (if the 2 invocations are concurrent, or if the first invocation exited uncleanly). you are absolutely right about theses nuisances, thanks! I have now tried: http://lists.gnu.org/archive/html/gnu-emacs-sources/2008-09/msg00016.html site-start.el now ends with: (require 'switch-to-new-buffer) (switch-to-new-untitled-buffer) ;(org-mode) (setq initial-buffer-choice 'none) This works fine - except that when I uncomment the (org-mode) line, the "Untitled" buffer is set to Org-mode (as intended) but when I close Emacs it will no longer ask about saving data if the buffer was marked dirty. If the (org-mode) line is commented out, Emacs does ask about saving (if it is required). I also tried c-mode instead of Org-mode, same effect - so the problem is probably not related to Org-mode. I guess changing the mode somehow overwrites the kill protections in switch-to-new-buffer? Warm regards, Stefan -- Dr. Stefan Vollmar, Dipl.-Phys. Head of IT group Max-Planck-Institut für neurologische Forschung Gleuelerstr. 50, 50931 Köln, Germany Tel.: +49-221-4726-213 FAX +49-221-4726-298 Tel.: +49-221-478-5713 Mobile: 0160-93874279 Email: vollmar@nf.mpg.de http://www.nf.mpg.de [-- Attachment #2: smime.p7s --] [-- Type: application/pkcs7-signature, Size: 4409 bytes --] ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Emacs ignores modified state of "untitled" buffer 2010-05-21 8:03 ` Stefan Vollmar @ 2010-05-21 13:17 ` Kevin Rodgers 2010-05-21 13:59 ` Stefan Vollmar 2010-05-21 17:15 ` Lennart Borgman 0 siblings, 2 replies; 22+ messages in thread From: Kevin Rodgers @ 2010-05-21 13:17 UTC (permalink / raw) To: help-gnu-emacs Stefan Vollmar wrote: > I have now tried: > > http://lists.gnu.org/archive/html/gnu-emacs-sources/2008-09/msg00016.html > > site-start.el now ends with: > > (require 'switch-to-new-buffer) > (switch-to-new-untitled-buffer) > ;(org-mode) > (setq initial-buffer-choice 'none) > > This works fine - except that when I uncomment the (org-mode) line, > the "Untitled" buffer is set to Org-mode (as intended) but when I > close Emacs it will no longer ask about saving data if the buffer was > marked dirty. If the (org-mode) line is commented out, Emacs does ask > about saving (if it is required). I also tried c-mode instead of > Org-mode, same effect - so the problem is probably not related to > Org-mode. I was going to suggest: (let ((default-major-mode 'org-mode)) (switch-to-new-untitled-buffer)) But when I tested it, I found out it didn't work as intended. For that, the following version of switch-to-new-buffer is needed (I will post a new version of switch-to-new-buffer.el to gnu.emacs.sources and the EmacsWiki later): (defun switch-to-new-buffer () "Switch to a new buffer. The buffer name is the value of `switch-to-new-buffer-name', or \"*scratch*\" if that is nil. See `set-buffer-major-mode'." (interactive) (let ((new-buffer (generate-new-buffer (or switch-to-new-buffer-name "*scratch*")))) (set-buffer-major-mode new-buffer) ;; Protect against kill-emacs: (setq buffer-offer-save t) ;; Protect against kill-buffer: (add-hook 'kill-buffer-query-functions 'switch-to-new-buffer-kill-buffer-query-function nil t) ;; Finally, select: (switch-to-buffer new-buffer))) > I guess changing the mode somehow overwrites the kill protections in switch-to-new-buffer? Yes, via kill-all-local-variables. -- Kevin Rodgers Denver, Colorado, USA ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Emacs ignores modified state of "untitled" buffer 2010-05-21 13:17 ` Kevin Rodgers @ 2010-05-21 13:59 ` Stefan Vollmar 2010-05-21 14:11 ` Kevin Rodgers 2010-05-21 17:15 ` Lennart Borgman 1 sibling, 1 reply; 22+ messages in thread From: Stefan Vollmar @ 2010-05-21 13:59 UTC (permalink / raw) To: Kevin Rodgers; +Cc: Emacs mailing list [-- Attachment #1: Type: text/plain, Size: 1887 bytes --] Dear Kevin, On 21.05.2010, at 15:17, Kevin Rodgers wrote: > I was going to suggest: > > (let ((default-major-mode 'org-mode)) > (switch-to-new-untitled-buffer)) > > But when I tested it, I found out it didn't work as intended. For that, > the following version of switch-to-new-buffer is needed (I will post a > new version of switch-to-new-buffer.el to gnu.emacs.sources and the > EmacsWiki later): > > (defun switch-to-new-buffer () > "Switch to a new buffer. > The buffer name is the value of `switch-to-new-buffer-name', or \"*scratch*\" > if that is nil. > See `set-buffer-major-mode'." > (interactive) > (let ((new-buffer (generate-new-buffer (or switch-to-new-buffer-name > "*scratch*")))) > (set-buffer-major-mode new-buffer) > ;; Protect against kill-emacs: > (setq buffer-offer-save t) > ;; Protect against kill-buffer: > (add-hook 'kill-buffer-query-functions > 'switch-to-new-buffer-kill-buffer-query-function > nil > t) > ;; Finally, select: > (switch-to-buffer new-buffer))) we now use (require 'switch-to-new-buffer) (let ((default-major-mode 'org-mode)) (switch-to-new-untitled-buffer)) in site-start.el and also have replaced switch-to-new-buffer() with your new routine. Emacs starts with an "untitled" buffer in Org-mode, but does not ask when closing the buffer with unsaved data. If this did work (it does not), what would happen to the "untitled" buffer if the user switches "manually" to another major mode? Many thanks in advance. Warm regards, Stefan -- Dr. Stefan Vollmar, Dipl.-Phys. Head of IT group Max-Planck-Institut für neurologische Forschung Gleuelerstr. 50, 50931 Köln, Germany Tel.: +49-221-4726-213 FAX +49-221-4726-298 Tel.: +49-221-478-5713 Mobile: 0160-93874279 Email: vollmar@nf.mpg.de http://www.nf.mpg.de [-- Attachment #2: smime.p7s --] [-- Type: application/pkcs7-signature, Size: 4409 bytes --] ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Emacs ignores modified state of "untitled" buffer 2010-05-21 13:59 ` Stefan Vollmar @ 2010-05-21 14:11 ` Kevin Rodgers 2010-05-21 14:30 ` Stefan Vollmar 0 siblings, 1 reply; 22+ messages in thread From: Kevin Rodgers @ 2010-05-21 14:11 UTC (permalink / raw) To: help-gnu-emacs Stefan Vollmar wrote: > we now use > > (require 'switch-to-new-buffer) > (let ((default-major-mode 'org-mode)) > (switch-to-new-untitled-buffer)) > > in site-start.el and also have replaced switch-to-new-buffer() with > your new routine. Emacs starts with an "untitled" buffer in Org-mode, > but does not ask when closing the buffer with unsaved data. If this > did work (it does not), what would happen to the "untitled" buffer if > the user switches "manually" to another major mode? Hi Stefan, sorry about that -- I moved the function to display the buffer from the beginning to the end and didn't take into account that it also is responsible for making the buffer current. Here's the fixed version: (defun switch-to-new-buffer () "Switch to a new buffer. The buffer name is the value of `switch-to-new-buffer-name', or \"*scratch*\" if that is nil. See `set-buffer-major-mode'." (interactive) (let ((new-buffer (generate-new-buffer (or switch-to-new-buffer-name "*scratch*")))) (set-buffer-major-mode new-buffer) (with-current-buffer new-buffer ;; Protect against kill-emacs: (setq buffer-offer-save t) ;; Protect against kill-buffer: (add-hook 'kill-buffer-query-functions 'switch-to-new-buffer-kill-buffer-query-function nil t) ) ;; Finally, select: (switch-to-buffer new-buffer))) -- Kevin Rodgers Denver, Colorado, USA ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Emacs ignores modified state of "untitled" buffer 2010-05-21 14:11 ` Kevin Rodgers @ 2010-05-21 14:30 ` Stefan Vollmar 0 siblings, 0 replies; 22+ messages in thread From: Stefan Vollmar @ 2010-05-21 14:30 UTC (permalink / raw) To: Kevin Rodgers; +Cc: Emacs mailing list [-- Attachment #1: Type: text/plain, Size: 1607 bytes --] Dear Kevin, On 21.05.2010, at 16:11, Kevin Rodgers wrote: > Here's the fixed version: > > (defun switch-to-new-buffer () > "Switch to a new buffer. > The buffer name is the value of `switch-to-new-buffer-name', or \"*scratch*\" > if that is nil. > See `set-buffer-major-mode'." > (interactive) > (let ((new-buffer (generate-new-buffer (or switch-to-new-buffer-name > "*scratch*")))) > (set-buffer-major-mode new-buffer) > (with-current-buffer new-buffer > ;; Protect against kill-emacs: > (setq buffer-offer-save t) > ;; Protect against kill-buffer: > (add-hook 'kill-buffer-query-functions > 'switch-to-new-buffer-kill-buffer-query-function > nil > t) > ) > ;; Finally, select: > (switch-to-buffer new-buffer))) we are almost there: Emacs now asks about unsaved data, fine! And we use (let ((default-major-mode 'org-mode)) (switch-to-new-untitled-buffer)) at the end of site-start.el. However, if I start Emacs (the "untitled" buffer is in front, set to Org-mode, everything as it should be), then do a M-x c-mode (or python-mode; probably any major-mode will do), type something and then quit Emacs - Emacs does not ask about saving data any longer, so that problem persists. Warm regards, Stefan -- Dr. Stefan Vollmar, Dipl.-Phys. Head of IT group Max-Planck-Institut für neurologische Forschung Gleuelerstr. 50, 50931 Köln, Germany Tel.: +49-221-4726-213 FAX +49-221-4726-298 Tel.: +49-221-478-5713 Mobile: 0160-93874279 Email: vollmar@nf.mpg.de http://www.nf.mpg.de [-- Attachment #2: smime.p7s --] [-- Type: application/pkcs7-signature, Size: 4409 bytes --] ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Emacs ignores modified state of "untitled" buffer 2010-05-21 13:17 ` Kevin Rodgers 2010-05-21 13:59 ` Stefan Vollmar @ 2010-05-21 17:15 ` Lennart Borgman 2010-05-21 20:49 ` Stefan Vollmar 1 sibling, 1 reply; 22+ messages in thread From: Lennart Borgman @ 2010-05-21 17:15 UTC (permalink / raw) To: Kevin Rodgers; +Cc: help-gnu-emacs On Fri, May 21, 2010 at 3:17 PM, Kevin Rodgers <kevin.d.rodgers@gmail.com> wrote: > ;; Protect against kill-emacs: > (setq buffer-offer-save t) >> I guess changing the mode somehow overwrites the kill protections in >> switch-to-new-buffer? > > Yes, via kill-all-local-variables. You have to use (put 'buffer-offer-save 'permanent-local t) to protect against kill-all-local-variables. I think it is a bug that this is not already done in Emacs. ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Emacs ignores modified state of "untitled" buffer 2010-05-21 17:15 ` Lennart Borgman @ 2010-05-21 20:49 ` Stefan Vollmar 2010-05-21 20:56 ` Lennart Borgman 0 siblings, 1 reply; 22+ messages in thread From: Stefan Vollmar @ 2010-05-21 20:49 UTC (permalink / raw) To: Lennart Borgman; +Cc: help-gnu-emacs, Kevin Rodgers [-- Attachment #1: Type: text/plain, Size: 1399 bytes --] Dear Lennart, On 21.05.2010, at 19:15, Lennart Borgman wrote: > On Fri, May 21, 2010 at 3:17 PM, Kevin Rodgers > <kevin.d.rodgers@gmail.com> wrote: > >> ;; Protect against kill-emacs: >> (setq buffer-offer-save t) > >>> I guess changing the mode somehow overwrites the kill protections in >>> switch-to-new-buffer? >> >> Yes, via kill-all-local-variables. > > You have to use > > (put 'buffer-offer-save 'permanent-local t) > > to protect against kill-all-local-variables. I think it is a bug that > this is not already done in Emacs. excellent! With (require 'switch-to-new-buffer) (put 'buffer-offer-save 'permanent-local t) (let ((default-major-mode 'org-mode)) (switch-to-new-untitled-buffer)) (setq initial-buffer-choice 'none) in site-start.el and Kevin's last version of switch-to-new-buffer, Emacs will now start with an "untitled" buffer (in Org-mode; no splashscreen), always ask to save data in a dirty "untitled" buffer and also dropping a file on the Emacs Windows icon shortcut will open it. Thank you! Warm regards, Stefan -- Dr. Stefan Vollmar, Dipl.-Phys. Head of IT group Max-Planck-Institut für neurologische Forschung Gleuelerstr. 50, 50931 Köln, Germany Tel.: +49-221-4726-213 FAX +49-221-4726-298 Tel.: +49-221-478-5713 Mobile: 0160-93874279 Email: vollmar@nf.mpg.de http://www.nf.mpg.de [-- Attachment #2: smime.p7s --] [-- Type: application/pkcs7-signature, Size: 4409 bytes --] ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Emacs ignores modified state of "untitled" buffer 2010-05-21 20:49 ` Stefan Vollmar @ 2010-05-21 20:56 ` Lennart Borgman 0 siblings, 0 replies; 22+ messages in thread From: Lennart Borgman @ 2010-05-21 20:56 UTC (permalink / raw) To: Stefan Vollmar; +Cc: help-gnu-emacs, Kevin Rodgers > With > > (require 'switch-to-new-buffer) > (put 'buffer-offer-save 'permanent-local t) > (let ((default-major-mode 'org-mode)) > (switch-to-new-untitled-buffer)) > (setq initial-buffer-choice 'none) > > in site-start.el and Kevin's last version of switch-to-new-buffer, Emacs will now start with an "untitled" buffer (in Org-mode; no splashscreen), always ask to save data in a dirty "untitled" buffer and also dropping a file on the Emacs Windows icon shortcut will open it. I have sent a bug report asking for buffer-offer-save to be permanent-local. ^ permalink raw reply [flat|nested] 22+ messages in thread
* RE: Emacs ignores modified state of "untitled" buffer 2010-05-21 1:56 ` Kevin Rodgers 2010-05-21 8:03 ` Stefan Vollmar @ 2010-05-21 14:20 ` Drew Adams 2010-05-28 14:32 ` Kevin Rodgers 1 sibling, 1 reply; 22+ messages in thread From: Drew Adams @ 2010-05-21 14:20 UTC (permalink / raw) To: 'Kevin Rodgers', help-gnu-emacs > > What am I missing? What is wrong with just using (find-file > > "untitled")? > > > > If a buffer is associated with a file name (which is what > > `find-file' does) then Emacs asks you about saving it. > > What else is the OP asking for? > > C-x C-s won't ask. > > I can think of a couple nuisances: > > * If the buffer gets saved to file "untitled", a subsequent > invocation of emacs will visit that file, not an empty buffer. > > * Changes to the buffer will be auto-saved to the #untitled# > file, and a subsequent invocation of emacs will ask to recover > the file (if the 2 invocations are concurrent, or if the first > invocation exited uncleanly). I see. It's clear now; thanks. C-x C-s saves quietly (to the `buffer-file-name') without asking for a target file (since it already has an associated file name). The behavior of most programs is different: If no _previously saved_ file is associated with the buffer, then trying to save makes the program ask for a file name. For the first save, users are typically required to use `Save As' (or else `Save' acts as `Save As' before the first save). Your code implements, I think, just what is needed for the OP (and others). It provides autosaving, saving without asking if already saved once, and saving with asking if not yet saved. You've offered this as command `switch-to-new-buffer' and put it on the `Buffers' menu as `Select New Buffer'. I would prefer that it be considered an improved behavior for `Visit New File', which is currently just `find-file'. The use of your command is, I think, for new file buffers only, so that intention should be reflected in both the command name and menu-item name. The `Buffers' menu is the wrong place for this, IMO. So I would suggest changing the command name to something like `new-file' or `visit-new-file' and (more importantly) replacing the `File' > `Visit New File' menu item with it. Those who are most likely to use such a menu item are newbies who expect that behavior. Any Emacs veteran who prefers `find-file' will not be likely to use the menu and choose `Visit New File'. And it is clear what a `new-file' command is for. I agree with Lennart that you should think about proposing this to emacs-devel. I would support it, especially with the changes I just mentioned. ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Emacs ignores modified state of "untitled" buffer 2010-05-21 14:20 ` Drew Adams @ 2010-05-28 14:32 ` Kevin Rodgers 2010-05-28 17:18 ` Drew Adams [not found] ` <mailman.2.1275067137.32597.help-gnu-emacs@gnu.org> 0 siblings, 2 replies; 22+ messages in thread From: Kevin Rodgers @ 2010-05-28 14:32 UTC (permalink / raw) To: help-gnu-emacs Drew Adams wrote: > You've offered this as command `switch-to-new-buffer' and put it on the > `Buffers' menu as `Select New Buffer'. > > I would prefer that it be considered an improved behavior for `Visit New File', > which is currently just `find-file'. The use of your command is, I think, for > new file buffers only, so that intention should be reflected in both the command > name and menu-item name. The `Buffers' menu is the wrong place for this, IMO. > > So I would suggest changing the command name to something like `new-file' or > `visit-new-file' and (more importantly) replacing the `File' > `Visit New File' > menu item with it. The term "visit" has a very specific meaning in Emacs, and switch-to-new-buffer doesn't actually visit a file (buffer-file-name is nil). I would prefer a name like open-new-file, defined an alias for switch-to-new-buffer. It seems to me the File menu entries are named backwards: "Visit New File" should be "Open New File", "Open File..." should be "Visit File...", and "Open Directory..." should be "Visit Directory..." > Those who are most likely to use such a menu item are newbies who expect that > behavior. Any Emacs veteran who prefers `find-file' will not be likely to use > the menu and choose `Visit New File'. And it is clear what a `new-file' command > is for. > > I agree with Lennart that you should think about proposing this to emacs-devel. > I would support it, especially with the changes I just mentioned. OK, we'll see how it goes. Thanks, -- Kevin Rodgers Denver, Colorado, USA ^ permalink raw reply [flat|nested] 22+ messages in thread
* RE: Emacs ignores modified state of "untitled" buffer 2010-05-28 14:32 ` Kevin Rodgers @ 2010-05-28 17:18 ` Drew Adams 2010-05-28 21:21 ` Stefan Vollmar [not found] ` <mailman.2.1275067137.32597.help-gnu-emacs@gnu.org> 1 sibling, 1 reply; 22+ messages in thread From: Drew Adams @ 2010-05-28 17:18 UTC (permalink / raw) To: 'Kevin Rodgers', help-gnu-emacs > > You've offered this as command `switch-to-new-buffer' and > > put it on the `Buffers' menu as `Select New Buffer'. > > > > I would prefer that it be considered an improved behavior > > for `Visit New File', which is currently just `find-file'. > > The use of your command is, I think, for new file buffers > > only, so that intention should be reflected in both the command > > name and menu-item name. The `Buffers' menu is the wrong > > place for this, IMO. > > > > So I would suggest changing the command name to something > > like `new-file' or `visit-new-file' and (more importantly) > > replacing the `File' > `Visit New File' menu item with it. > > The term "visit" has a very specific meaning in Emacs, and > switch-to-new-buffer doesn't actually visit a file > (buffer-file-name is nil). I would prefer a name > like open-new-file, defined an alias for switch-to-new-buffer. OK by me. But if you keep the original name also, I'd suggest modifying it to `switch-to-new-file-buffer'. It is a buffer intended for a new file; it is not just a new buffer. `open' is not really clearer here than `visit', but it is less specific. It is true that in Emacs we speak of "visiting" a file as reading its content into a buffer. Whether `buffer-file-name' is nil at that moment, so the buffer is not actually visiting a file yet, is less important than the purpose (use) of the command, which is to create a buffer that will be associated with a new file. The buffer switched to is intended for visiting a file, even if that file does not yet exist. > It seems to me the File menu entries are named backwards: > "Visit New File" should be "Open New File", "Open File..." > should be "Visit File...", and "Open Directory..." should be > "Visit Directory..." IMO, `Open' in a menu item is OK for both existing and new. But you are correct that in Emacs jargon the more correct term for an existing file would be `Visit'. I would propose (and have proposed ;-)) simply `New File' as the menu item. It is common nowadays to have a menu item `New' for creation when the object to be created is clear, and `New Foo' to make clear that it creates a foo object. (I use `New File' and `New Directory' in my own code, `menu-bar+.el'.) Whether we use `Visit' or `Open' for an existing whatever is not so important. What is important is to clearly distinguish the case of creation (`New'). > > Those who are most likely to use such a menu item are > > newbies who expect that behavior. Any Emacs veteran who prefers > > `find-file' will not be likely to use the menu and choose > > `Visit New File'. And it is clear what a `new-file' command is for. > > > > I agree with Lennart that you should think about proposing > > this to emacs-devel. I would support it, especially with the > > changes I just mentioned. > > OK, we'll see how it goes. ^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Emacs ignores modified state of "untitled" buffer 2010-05-28 17:18 ` Drew Adams @ 2010-05-28 21:21 ` Stefan Vollmar 0 siblings, 0 replies; 22+ messages in thread From: Stefan Vollmar @ 2010-05-28 21:21 UTC (permalink / raw) To: Drew Adams; +Cc: help-gnu-emacs, Kevin Rodgers [-- Attachment #1: Type: text/plain, Size: 1741 bytes --] Dear Drew, On 28.05.2010, at 19:18, Drew Adams wrote: [...] > I would propose (and have proposed ;-)) simply `New File' as the menu item. It > is common nowadays to have a menu item `New' for creation when the object to be > created is clear, and `New Foo' to make clear that it creates a foo object. (I > use `New File' and `New Directory' in my own code, `menu-bar+.el'.) > > Whether we use `Visit' or `Open' for an existing whatever is not so important. > What is important is to clearly distinguish the case of creation (`New'). in my reply to Kevin of May 26 the modified left-mode button in the toolbar was labelled "New Document (Org)" (we used the same label in the corresponding first entry of the "File" menu). I absolutely agree that the "New" part is essential. Kevin's code conforms (probably not a coincidence) to the Apple Human Interface Guidelines: http://www.devworld.apple.com/mac/library/documentation/UserExperience/Conceptual/AppleHIGuidelines/XHIGMenus/XHIGMenus.html I have had Windows users look at the Emacs version with the File New option and they said it was a significant improvement, immediately adding that, by the way, they had never heard of "visiting" a file (not surprising). I believe that Xah Lee had these kind of changes in mind here: http://xahlee.org/emacs/modernization.html I do not agree with everything but he has a few points, I think. Warm regards, Stefan -- Dr. Stefan Vollmar, Dipl.-Phys. Head of IT group Max-Planck-Institut für neurologische Forschung Gleuelerstr. 50, 50931 Köln, Germany Tel.: +49-221-4726-213 FAX +49-221-4726-298 Tel.: +49-221-478-5713 Mobile: 0160-93874279 Email: vollmar@nf.mpg.de http://www.nf.mpg.de [-- Attachment #2: smime.p7s --] [-- Type: application/pkcs7-signature, Size: 4409 bytes --] ^ permalink raw reply [flat|nested] 22+ messages in thread
[parent not found: <mailman.2.1275067137.32597.help-gnu-emacs@gnu.org>]
* Re: Emacs ignores modified state of "untitled" buffer [not found] ` <mailman.2.1275067137.32597.help-gnu-emacs@gnu.org> @ 2010-05-29 1:04 ` Tim X 0 siblings, 0 replies; 22+ messages in thread From: Tim X @ 2010-05-29 1:04 UTC (permalink / raw) To: help-gnu-emacs "Drew Adams" <drew.adams@oracle.com> writes: >> > You've offered this as command `switch-to-new-buffer' and >> > put it on the `Buffers' menu as `Select New Buffer'. >> > >> > I would prefer that it be considered an improved behavior >> > for `Visit New File', which is currently just `find-file'. >> > The use of your command is, I think, for new file buffers >> > only, so that intention should be reflected in both the command >> > name and menu-item name. The `Buffers' menu is the wrong >> > place for this, IMO. >> > >> > So I would suggest changing the command name to something >> > like `new-file' or `visit-new-file' and (more importantly) >> > replacing the `File' > `Visit New File' menu item with it. >> >> The term "visit" has a very specific meaning in Emacs, and >> switch-to-new-buffer doesn't actually visit a file >> (buffer-file-name is nil). I would prefer a name >> like open-new-file, defined an alias for switch-to-new-buffer. > > OK by me. But if you keep the original name also, I'd suggest modifying it to > `switch-to-new-file-buffer'. It is a buffer intended for a new file; it is not > just a new buffer. > > `open' is not really clearer here than `visit', but it is less specific. It is > true that in Emacs we speak of "visiting" a file as reading its content into a > buffer. > > Whether `buffer-file-name' is nil at that moment, so the buffer is not actually > visiting a file yet, is less important than the purpose (use) of the command, > which is to create a buffer that will be associated with a new file. The buffer > switched to is intended for visiting a file, even if that file does not yet > exist. > >> It seems to me the File menu entries are named backwards: >> "Visit New File" should be "Open New File", "Open File..." >> should be "Visit File...", and "Open Directory..." should be >> "Visit Directory..." > > IMO, `Open' in a menu item is OK for both existing and new. But you are correct > that in Emacs jargon the more correct term for an existing file would be > `Visit'. > > I would propose (and have proposed ;-)) simply `New File' as the menu item. It > is common nowadays to have a menu item `New' for creation when the object to be > created is clear, and `New Foo' to make clear that it creates a foo object. (I > use `New File' and `New Directory' in my own code, `menu-bar+.el'.) > > Whether we use `Visit' or `Open' for an existing whatever is not so important. > What is important is to clearly distinguish the case of creation (`New'). > >> > Those who are most likely to use such a menu item are >> > newbies who expect that behavior. Any Emacs veteran who prefers >> > `find-file' will not be likely to use the menu and choose >> > `Visit New File'. And it is clear what a `new-file' command is for. >> > >> > I agree with Lennart that you should think about proposing >> > this to emacs-devel. I would support it, especially with the >> > changes I just mentioned. >> >> OK, we'll see how it goes. > I think I agree with Drew's points here. Just adding my 2 cents worth in support. Having said that, I also want to highlight that this sort of nameing stuff is very difficult to get right and we need to be very careful. I agree with some of the criticisms of some emacs 'jargon' being old fashioned or outdated, but I have also noticed that many of the suggested changes are made by people who are ignorant of some of the more subtle meanings that can be important, but wold be lost if ore 'modern' terminology is used. I also have a slight concern that beginning to update terms to reflect current trends has the danger that we will spend too much time chasing a moving target as trends change. Having modern' terminology is IMO less important than having consistent terminology. It may be counter productive to use one set of terms on the menu for 'newbies' that are more familiar or in-line with those used on lesser systems and sticking to older terms 'under the hood'. Most newbies that stick with emacs for any time will at some point want to start customizing and writing a bit of elisp. Having one set of terminology for the menus and another for the functions/commands those menu options run will make their life more difficult and frustrating. Tim -- tcross (at) rapttech dot com dot au ^ permalink raw reply [flat|nested] 22+ messages in thread
end of thread, other threads:[~2010-05-29 1:04 UTC | newest] Thread overview: 22+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2010-05-19 14:52 Emacs ignores modified state of "untitled" buffer Stefan Vollmar 2010-05-19 15:04 ` Drew Adams 2010-05-19 20:34 ` Stephen Berman 2010-05-20 12:45 ` Kevin Rodgers 2010-05-20 13:29 ` Drew Adams 2010-05-20 14:00 ` Stefan Vollmar 2010-05-21 2:00 ` Kevin Rodgers 2010-05-21 2:06 ` Lennart Borgman 2010-05-21 1:56 ` Kevin Rodgers 2010-05-21 8:03 ` Stefan Vollmar 2010-05-21 13:17 ` Kevin Rodgers 2010-05-21 13:59 ` Stefan Vollmar 2010-05-21 14:11 ` Kevin Rodgers 2010-05-21 14:30 ` Stefan Vollmar 2010-05-21 17:15 ` Lennart Borgman 2010-05-21 20:49 ` Stefan Vollmar 2010-05-21 20:56 ` Lennart Borgman 2010-05-21 14:20 ` Drew Adams 2010-05-28 14:32 ` Kevin Rodgers 2010-05-28 17:18 ` Drew Adams 2010-05-28 21:21 ` Stefan Vollmar [not found] ` <mailman.2.1275067137.32597.help-gnu-emacs@gnu.org> 2010-05-29 1:04 ` Tim X
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).