* bug#5405: select-frame losing current-buffer @ 2010-01-17 18:26 Uday S Reddy 2010-01-17 20:02 ` Chong Yidong 2010-01-18 8:11 ` martin rudalics 0 siblings, 2 replies; 7+ messages in thread From: Uday S Reddy @ 2010-01-17 18:26 UTC (permalink / raw) To: bug-gnu-emacs; +Cc: U.S.Reddy The documentation of make-frame says that current-buffer continues to selected in the new frame. The documentation of select-frame doesn't say anything about the matter, but one would normally expect that the current-buffer should still remain the same. However, the following example shows that select-frame loses the current-buffer: (defun testing () (interactive) (let ((new-buffer (get-buffer-create " testing"))) (set-buffer new-buffer) (select-frame (make-frame nil)) (if (not (equal (current-buffer) new-buffer)) (debug)))) I presume that the space at the beginning of the buffer name is a partial cause of this misbehaviour. Cheers, Uday Reddy In GNU Emacs 22.3.1 (i386-mingw-nt5.1.2600) of 2008-09-06 on SOFT-MJASON Windowing system distributor `Microsoft Corp.', version 5.1.2600 configured using `configure --with-gcc (3.4)' Important settings: value of $LC_ALL: nil value of $LC_COLLATE: nil value of $LC_CTYPE: nil value of $LC_MESSAGES: nil value of $LC_MONETARY: nil value of $LC_NUMERIC: nil value of $LC_TIME: nil value of $LANG: ENU locale-coding-system: cp1252 default-enable-multibyte-characters: t Major mode: Mail Minor modes in effect: savehist-mode: t encoded-kbd-mode: t tooltip-mode: t mouse-wheel-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t unify-8859-on-encoding-mode: t utf-translate-cjk-mode: t line-number-mode: t transient-mark-mode: t abbrev-mode: t Recent input: C-x b * s c SPC <return> <f1> C-x . <return> ( d e f u n SPC t e s t i n g SPC ( ) <return> TAB C-( ( i n t e r a c t i v e ) <return> TAB ( l e t SPC ( ( n e w - b u f f e r SPC ( g e t - b u f f e r - c r e a t e SPC " SPC t e s t i n g " ) ) ) <return> TAB ( s e t - b u f f e r SPC n e w - b u f f e r ) <return> TAB ( l e t SPC ( ( n e w - f r a m e SPC C-a C-k TAB ( s e l e c t - f r a m e SPC ( m a k e - f r a m e SPC n i l ) ) <return> TAB ( i f SPC ( n o t SPC ( e u q <backspace> <backspace> q u a l SPC ( c u r r e n t - b u f f e r ) SPC n e w - b u f f e r ) ) <return> TAB 9 d e <backspace> <backspace> <backspace> ( d e b u g ) ) ) ) <escape> C-x M-x t e s t i n g <return> q C-x b <return> C-x b * s c SPC <return> C-p C-p C-p C-p C-p C-p C-a C-SPC C-n C-n C-n C-n C-n C-n C-n <return> C-x C-x C-x C-k C-x m M-x r e p o r t - e m SPC SPC <return> Recent messages: There are unsaved changes, quit anyway? (y or n) Delete auto save file y:/tmpmail/#vm-bug-forwarding.msg#? (y or n) Mark set Auto-saving...done testing Entering debugger... Back to top level. Mark set Loading mail-utils...done Loading emacsbug...done ^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#5405: select-frame losing current-buffer 2010-01-17 18:26 bug#5405: select-frame losing current-buffer Uday S Reddy @ 2010-01-17 20:02 ` Chong Yidong 2010-01-17 20:21 ` Uday S Reddy 2010-01-18 8:11 ` martin rudalics 1 sibling, 1 reply; 7+ messages in thread From: Chong Yidong @ 2010-01-17 20:02 UTC (permalink / raw) To: Uday S Reddy; +Cc: 5405 Uday S Reddy <u.s.reddy@cs.bham.ac.uk> writes: > The documentation of make-frame says that current-buffer continues to > selected in the new frame. The documentation of select-frame doesn't > say anything about the matter, but one would normally expect that the > current-buffer should still remain the same. However, the following > example shows that select-frame loses the current-buffer: > > (defun testing () > (interactive) > (let ((new-buffer (get-buffer-create " testing"))) > (set-buffer new-buffer) > (select-frame (make-frame nil)) > (if (not (equal (current-buffer) new-buffer)) > (debug)))) > > I presume that the space at the beginning of the buffer name is > a partial cause of this misbehaviour. This is deliberate behavior dating back about a decade (frame.c:392). Buffers whose names start with a space are considered "hidden buffers" that should not ordinarily be displayed (e.g. they don't show up in M-x list-buffers either). I'll update the documentation to mention this. ^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#5405: select-frame losing current-buffer 2010-01-17 20:02 ` Chong Yidong @ 2010-01-17 20:21 ` Uday S Reddy 2010-01-17 21:26 ` Drew Adams 0 siblings, 1 reply; 7+ messages in thread From: Uday S Reddy @ 2010-01-17 20:21 UTC (permalink / raw) To: Chong Yidong; +Cc: 5405, Uday S Reddy Dear Chong, Thanks very much for the quick response. But I am not convinced the hidden buffer idea explains the behaviour I found. Before doing select-frame, the "hidden buffer" is the current buffer. For whatever reason, the user or the code chose it as the current buffer. I don't believe that the buffer should be forcibly dumped and the focus placed on some other random buffer that happens to be around. This behaviour was found in maintaining VM which, for some indepdent reasons, chose a buffer name with a leading space, and some serious buffer corruption resulted from it. This seems dangerous, undesirable behaviour. I have now modified VM to avoid the leading space. So the issue doesn't affect me any more. But it took me a day's labour to find the problem. I hope there won't be others who will get simiarly burned. Cheers, Uday Chong Yidong writes: > Uday S Reddy <u.s.reddy@cs.bham.ac.uk> writes: > > > The documentation of make-frame says that current-buffer continues to > > selected in the new frame. The documentation of select-frame doesn't > > say anything about the matter, but one would normally expect that the > > current-buffer should still remain the same. However, the following > > example shows that select-frame loses the current-buffer: > > > > (defun testing () > > (interactive) > > (let ((new-buffer (get-buffer-create " testing"))) > > (set-buffer new-buffer) > > (select-frame (make-frame nil)) > > (if (not (equal (current-buffer) new-buffer)) > > (debug)))) > > > > I presume that the space at the beginning of the buffer name is > > a partial cause of this misbehaviour. > > This is deliberate behavior dating back about a decade (frame.c:392). > Buffers whose names start with a space are considered "hidden buffers" > that should not ordinarily be displayed (e.g. they don't show up in > M-x list-buffers either). I'll update the documentation to mention > this. > > ^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#5405: select-frame losing current-buffer 2010-01-17 20:21 ` Uday S Reddy @ 2010-01-17 21:26 ` Drew Adams 0 siblings, 0 replies; 7+ messages in thread From: Drew Adams @ 2010-01-17 21:26 UTC (permalink / raw) To: 'Uday S Reddy', 'Chong Yidong'; +Cc: 5405 > > > The documentation of make-frame says that current-buffer > > > continues to selected in the new frame. The > > > documentation of select-frame doesn't > > > say anything about the matter, but one would normally > > > expect that the current-buffer should still remain the same. ... > > > I presume that the space at the beginning of the buffer name is > > > a partial cause of this misbehaviour. > > > > This is deliberate behavior dating back about a decade > > (frame.c:392). Buffers whose names start with a space are > > considered "hidden buffers" that should not ordinarily be > > displayed (e.g. they don't show up in M-x list-buffers either). > > I'll update the documentation to mention this. > > Thanks very much for the quick response. But I am not convinced the > hidden buffer idea explains the behaviour I found. Before doing > select-frame, the "hidden buffer" is the current buffer. For whatever > reason, the user or the code chose it as the current buffer. I don't > believe that the buffer should be forcibly dumped and the focus placed > on some other random buffer that happens to be around. > > This behaviour was found in maintaining VM which, for some indepdent > reasons, chose a buffer name with a leading space, and some serious > buffer corruption resulted from it. This seems dangerous, undesirable > behaviour. > > I have now modified VM to avoid the leading space. So the issue > doesn't affect me any more. But it took me a day's labour to find the > problem. I hope there won't be others who will get simiarly burned. Without speaking directly to what `select-frame'/`make-frame' should do in this regard, let me say that speaking in terms of "normally expect" (Uday) and "should not ordinarily" (Yidong) simply begs the question. No such general rule can answer the question completely for this particular situation. By _default_, in many common situations, such buffers are hidden or ignored in some _particular sense_ - for example, as completion candidates. That does not mean that they must or should be ignored in all contexts, or that users should not have a way to override a default behavior that ignores them. The reason for such a general/default/common treatment is more important than the "rule" itself, as only it provides guidance. The reason is that not ignoring such buffers can distract or confuse users. Users _typically_ do not need to consider such buffers - they just get in the way. But the fact that users _can_ consider them if they want (including for completion) speaks to not casting such a generally helpful rule in concrete. IOW, the question was raised - for `select-frame'/`make-frame' in particular - and it is still raised (unanswered). The argument that such buffers must by definition be ignored is not a valid one. It begs the question to be answered - both generally, and in this particular case. Wrt `select-frame'/`make-frame': I'm not sure what the right behavior is. If, as Uday says, the "hidden" buffer was already chosen then, analogously to completion when the user explicitly types a pattern that chooses an otherwise hidden buffer, that choice should probably be respected. If the user types `foo.log' or ` *foo*' during completion, we don't refuse to give access to that buffer under the pretext that it is a hidden buffer. If a program or user has already chosen, then we should probably let it be. But there might be other considerations for this particular case, which would also need to be taken into account - dunno. Only attention to the details can help, not some general rule about a priori hiddenness. ^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#5405: select-frame losing current-buffer 2010-01-17 18:26 bug#5405: select-frame losing current-buffer Uday S Reddy 2010-01-17 20:02 ` Chong Yidong @ 2010-01-18 8:11 ` martin rudalics 2010-01-18 15:32 ` Uday S Reddy 1 sibling, 1 reply; 7+ messages in thread From: martin rudalics @ 2010-01-18 8:11 UTC (permalink / raw) To: Uday S Reddy, 5405 > The documentation of make-frame says that current-buffer continues to > selected in the new frame. The documentation also says that The previously selected frame remains selected. However, the window system may select the new frame for its own reasons, for instance if the frame appears under the mouse pointer and your setup is for focus to follow the pointer. so the current buffer may change (as described below) in some cases. > The documentation of select-frame doesn't > say anything about the matter, but one would normally expect that the > current-buffer should still remain the same. The documentation of `select-frame' says Subsequent editing commands apply to its selected window. which inherently means that that frame's selected window becomes the selected window. Selecting a window WINDOW means to assure that If WINDOW is not already selected, make WINDOW's buffer current and make WINDOW the frame's selected window. Which doesn't mean that the documentation can't be improved ;-) > I presume that the space at the beginning of the buffer name is > a partial cause of this misbehaviour. It's not related. martin ^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#5405: select-frame losing current-buffer 2010-01-18 8:11 ` martin rudalics @ 2010-01-18 15:32 ` Uday S Reddy 2011-09-18 11:45 ` Lars Magne Ingebrigtsen 0 siblings, 1 reply; 7+ messages in thread From: Uday S Reddy @ 2010-01-18 15:32 UTC (permalink / raw) To: martin rudalics; +Cc: 5405, Uday S Reddy I didn't understand this message entirely, but I can confirm that the problem arises in interactive use as well. If you have the focus on a non-hidden buffer and create a new-frame, then this buffer is displayed in the new frame. If it is a "hidden" buffer then it is ignored and some other buffer is displayed in the new frame. This can be confusing and perhaps annoying to the users, but it is probably not a serious problem during interactive use. Buf if the same problem occurs inside application code, then it can be more dangerous because the code might errorneously assume that the correct buffer is in place and modify it. The fact that it is a *special case* means that it might go unnoticed during testing and faulty application code gets delivered. So, I recommend that no special case should be made for "hidden" buffers. As Drew has argued cogently, the case for the special case is weak. Cheers, Uday martin rudalics writes: > > The documentation of make-frame says that current-buffer continues to > > selected in the new frame. > > The documentation also says that > > The previously selected frame remains selected. However, the > window system may select the new frame for its own reasons, for > instance if the frame appears under the mouse pointer and your > setup is for focus to follow the pointer. > > so the current buffer may change (as described below) in some cases. > > > The documentation of select-frame doesn't > > say anything about the matter, but one would normally expect that the > > current-buffer should still remain the same. > > The documentation of `select-frame' says > > Subsequent editing commands apply to its selected window. > > which inherently means that that frame's selected window becomes the > selected window. Selecting a window WINDOW means to assure that > > If WINDOW is not already selected, make WINDOW's buffer current > and make WINDOW the frame's selected window. > > Which doesn't mean that the documentation can't be improved ;-) > > > I presume that the space at the beginning of the buffer name is > > a partial cause of this misbehaviour. > > It's not related. > > martin > ^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#5405: select-frame losing current-buffer 2010-01-18 15:32 ` Uday S Reddy @ 2011-09-18 11:45 ` Lars Magne Ingebrigtsen 0 siblings, 0 replies; 7+ messages in thread From: Lars Magne Ingebrigtsen @ 2011-09-18 11:45 UTC (permalink / raw) To: Uday S Reddy; +Cc: 5405 Uday S Reddy <u.s.reddy@cs.bham.ac.uk> writes: > So, I recommend that no special case should be made for "hidden" > buffers. I think this is a feature, and not a bug, so I'm closing this report. -- (domestic pets only, the antidote for overdose, milk.) bloggy blog http://lars.ingebrigtsen.no/ ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2011-09-18 11:45 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2010-01-17 18:26 bug#5405: select-frame losing current-buffer Uday S Reddy 2010-01-17 20:02 ` Chong Yidong 2010-01-17 20:21 ` Uday S Reddy 2010-01-17 21:26 ` Drew Adams 2010-01-18 8:11 ` martin rudalics 2010-01-18 15:32 ` Uday S Reddy 2011-09-18 11:45 ` Lars Magne Ingebrigtsen
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.