* Re: splitting windows and switching buffers [not found] ` <4F6C51C1.7080903@gmx.at> @ 2012-03-23 14:59 ` Sam Steingold 2012-03-23 19:31 ` martin rudalics 2012-03-28 0:39 ` chad 0 siblings, 2 replies; 7+ messages in thread From: Sam Steingold @ 2012-03-23 14:59 UTC (permalink / raw) To: martin rudalics; +Cc: emacs-devel > * martin rudalics <ehqnyvpf@tzk.ng> [2012-03-23 11:34:41 +0100]: > >> Can we introduce a user option show-visible-buffer? > > First of all I would have to know a practical use case where this > would be better. Showing the same buffer in two windows > simultaneously is practically always the result of C-x 2 or C-x 3 That's why I have (defun sds-split-window (size) "Split the window (sideways if it is wide) and switch buffer." (interactive "P") (if (< split-width-threshold (window-width)) (split-window-right size) (split-window-below size)) (unrecord-window-buffer) (switch-to-buffer (other-buffer))) bound to [f2] and I (almost) never use C-x 2 or C-x 3. I understand and recognize that some people like to show the same buffer in two windows, but I don't think I ever do, and I wish there were a way to ensure that this actually never happen without an express request from me. E.g., make the buffer lists associated with windows disjoint. -- Sam Steingold (http://sds.podval.org/) on Ubuntu 11.10 (oneiric) X 11.0.11004000 http://www.childpsy.net/ http://camera.org http://americancensorship.org http://palestinefacts.org http://thereligionofpeace.com http://ffii.org Money does not buy happiness, but it helps to make unhappiness comfortable. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: splitting windows and switching buffers 2012-03-23 14:59 ` splitting windows and switching buffers Sam Steingold @ 2012-03-23 19:31 ` martin rudalics 2012-03-24 11:16 ` martin rudalics 2012-03-28 0:39 ` chad 1 sibling, 1 reply; 7+ messages in thread From: martin rudalics @ 2012-03-23 19:31 UTC (permalink / raw) To: sds; +Cc: emacs-devel > That's why I have > > (defun sds-split-window (size) > "Split the window (sideways if it is wide) and switch buffer." > (interactive "P") > (if (< split-width-threshold (window-width)) > (split-window-right size) > (split-window-below size)) > (unrecord-window-buffer) > (switch-to-buffer (other-buffer))) > > bound to [f2] and I (almost) never use C-x 2 or C-x 3. IIUC you do this to show the other buffer in the window above or on the left and make sure that the buffer previously shown is not reshown. I don't understand yet whether you have problems when using `sds-split-window' or whether `sds-split-window' avoids showing the same buffer twice thus solving your problems. > I understand and recognize that some people like to show the same buffer > in two windows, but I don't think I ever do, and I wish there were a way > to ensure that this actually never happen without an express request > from me. E.g., make the buffer lists associated with windows disjoint. Could you file a request at emacs-devel, explicitly stating that the behavior you need was supported until Emacs 23.4 and is no more supported in Emacs 24.1? The appropriate patch would be similar to the one you applied with the exception that the actual behavior would depend on the value of a user option. martin ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: splitting windows and switching buffers 2012-03-23 19:31 ` martin rudalics @ 2012-03-24 11:16 ` martin rudalics 2012-03-26 18:37 ` Sam Steingold 0 siblings, 1 reply; 7+ messages in thread From: martin rudalics @ 2012-03-24 11:16 UTC (permalink / raw) To: sds; +Cc: emacs-devel [-- Attachment #1: Type: text/plain, Size: 67 bytes --] A patch for this and some other minor issues is attached. martin [-- Attachment #2: switch-to-visible-buffer.diff --] [-- Type: text/plain, Size: 6183 bytes --] === modified file 'doc/lispref/windows.texi' --- doc/lispref/windows.texi 2012-03-11 16:10:07 +0000 +++ doc/lispref/windows.texi 2012-03-24 10:56:10 +0000 @@ -2073,7 +2073,8 @@ If repeated invocations of this command have already shown all buffers previously shown in @var{window}, further invocations will show buffers from the buffer list of the frame @var{window} appears on (@pxref{The -Buffer List}). +Buffer List}) trying to skip buffers that are already shown in another +window on that frame. @end deffn @deffn Command switch-to-next-buffer &optional window @@ -2087,6 +2088,19 @@ of the frame @var{window} appears on (@pxref{The Buffer List}). @end deffn +By default @code{switch-to-prev-buffer} and @code{switch-to-next-buffer} +can switch to a buffer that is already shown in another window on the +same frame. The following option can be used to override that behavior. + +@defopt switch-to-visible-buffer +If this variable is non-@code{nil}, @code{switch-to-prev-buffer} and +@code{switch-to-next-buffer} may switch to a buffer that is already +visible on the same frame, provided the buffer was shown in the argument +window before. If it's @code{nil}, @code{switch-to-prev-buffer} and +@code{switch-to-next-buffer} always try to avoid switching to a buffer +that is already visible in another window on the same frame. +@end defopt + @node Dedicated Windows @section Dedicated Windows === modified file 'lisp/window.el' --- lisp/window.el 2012-03-22 20:49:04 +0000 +++ lisp/window.el 2012-03-24 11:00:06 +0000 @@ -2575,6 +2575,18 @@ (when point (set-window-point-1 window point)))) +(defcustom switch-to-visible-buffer t + "If non-nil, allow switching to an already visible buffer. +If this variable is non-nil, `switch-to-prev-buffer' and +`switch-to-next-buffer' may switch to an already visible buffer +provided the buffer was shown in the argument window before. If +this variable is nil, `switch-to-prev-buffer' and +`switch-to-next-buffer' always try to avoid switching to a buffer +that is already visible in another window on the same frame." + :type 'boolean + :version "24.1" + :group 'windows) + (defun switch-to-prev-buffer (&optional window bury-or-kill) "In WINDOW switch to previous buffer. WINDOW must be a live window and defaults to the selected one. @@ -2584,6 +2596,7 @@ shall not be switched to in future invocations of this command." (interactive) (let* ((window (window-normalize-window window t)) + (frame (window-frame window)) (old-buffer (window-buffer window)) ;; Save this since it's destroyed by `set-window-buffer'. (next-buffers (window-next-buffers window)) @@ -2602,14 +2615,13 @@ (not (eq new-buffer old-buffer)) (or bury-or-kill (not (memq new-buffer next-buffers)))) - ;; _DO_ show visible buffers as advertized in Elisp manual 28.14 - ;; on `switch-to-prev-buffer' & `switch-to-next-buffer' - ;;(if (get-buffer-window new-buffer) - ;; ;; Try to avoid showing a buffer visible in some other window. - ;; (setq visible new-buffer) + (if (and (not switch-to-visible-buffer) + (get-buffer-window new-buffer frame)) + ;; Try to avoid showing a buffer visible in some other window. + (setq visible new-buffer) (set-window-buffer-start-and-point window new-buffer (nth 1 entry) (nth 2 entry)) - (throw 'found t))) + (throw 'found t)))) ;; Scan reverted buffer list of WINDOW's frame next, skipping ;; entries of next buffers. Note that when we bury or kill a ;; buffer we don't reverse the global buffer list to avoid showing @@ -2617,15 +2629,16 @@ ;; buffer list in order to make sure that switching to the ;; previous/next buffer traverse it in opposite directions. (dolist (buffer (if bury-or-kill - (buffer-list (window-frame window)) - (nreverse (buffer-list (window-frame window))))) + (buffer-list frame) + (nreverse (buffer-list frame)))) (when (and (buffer-live-p buffer) (not (eq buffer old-buffer)) (not (eq (aref (buffer-name buffer) 0) ?\s)) (or bury-or-kill (not (memq buffer next-buffers)))) - (if (get-buffer-window buffer) + (if (get-buffer-window buffer frame) ;; Try to avoid showing a buffer visible in some other window. - (setq visible buffer) + (unless visible + (setq visible buffer)) (setq new-buffer buffer) (set-window-buffer-start-and-point window new-buffer) (throw 'found t)))) @@ -2678,6 +2691,7 @@ WINDOW must be a live window and defaults to the selected one." (interactive) (let* ((window (window-normalize-window window t)) + (frame (window-frame window)) (old-buffer (window-buffer window)) (next-buffers (window-next-buffers window)) new-buffer entry killed-buffers visible) @@ -2698,11 +2712,11 @@ (throw 'found t))) ;; Scan the buffer list of WINDOW's frame next, skipping previous ;; buffers entries. - (dolist (buffer (buffer-list (window-frame window))) + (dolist (buffer (buffer-list frame)) (when (and (buffer-live-p buffer) (not (eq buffer old-buffer)) (not (eq (aref (buffer-name buffer) 0) ?\s)) (not (assq buffer (window-prev-buffers window)))) - (if (get-buffer-window buffer) + (if (get-buffer-window buffer frame) ;; Try to avoid showing a buffer visible in some other window. (setq visible buffer) (setq new-buffer buffer) @@ -2716,9 +2730,14 @@ (not (setq killed-buffers (cons new-buffer killed-buffers)))) (not (eq new-buffer old-buffer))) - (set-window-buffer-start-and-point - window new-buffer (nth 1 entry) (nth 2 entry)) - (throw 'found t))) + (if (and (not switch-to-visible-buffer) + (get-buffer-window new-buffer frame)) + ;; Try to avoid showing a buffer visible in some other window. + (unless visible + (setq visible new-buffer)) + (set-window-buffer-start-and-point + window new-buffer (nth 1 entry) (nth 2 entry)) + (throw 'found t)))) ;; Show a buffer visible in another window. (when visible ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: splitting windows and switching buffers 2012-03-24 11:16 ` martin rudalics @ 2012-03-26 18:37 ` Sam Steingold 2012-03-27 9:24 ` martin rudalics 0 siblings, 1 reply; 7+ messages in thread From: Sam Steingold @ 2012-03-26 18:37 UTC (permalink / raw) To: emacs-devel > * martin rudalics <ehqnyvpf@tzk.ng> [2012-03-24 12:16:16 +0100]: > > A patch for this and some other minor issues is attached. looks interesting. gonna commit? -- Sam Steingold (http://sds.podval.org/) on Ubuntu 11.10 (oneiric) X 11.0.11004000 http://www.childpsy.net/ http://www.memritv.org http://honestreporting.com http://jihadwatch.org http://palestinefacts.org http://truepeace.org Lottery is a tax on statistics ignorants. MS is a tax on computer-idiots. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: splitting windows and switching buffers 2012-03-26 18:37 ` Sam Steingold @ 2012-03-27 9:24 ` martin rudalics 0 siblings, 0 replies; 7+ messages in thread From: martin rudalics @ 2012-03-27 9:24 UTC (permalink / raw) To: sds; +Cc: emacs-devel > gonna commit? Committed, martin ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: splitting windows and switching buffers 2012-03-23 14:59 ` splitting windows and switching buffers Sam Steingold 2012-03-23 19:31 ` martin rudalics @ 2012-03-28 0:39 ` chad 2012-03-28 15:06 ` Sam Steingold 1 sibling, 1 reply; 7+ messages in thread From: chad @ 2012-03-28 0:39 UTC (permalink / raw) To: sds, Emacs developers [-- Attachment #1: Type: text/plain, Size: 427 bytes --] On Mar 23, 2012, at 7:59 AM, Sam Steingold wrote: > > That's why I have > > (defun sds-split-window (size) [...] > > bound to [f2] and I (almost) never use C-x 2 or C-x 3. I'm curious about this usage pattern; do you often want to split windows in emacs without doing something specific in the other window? I rebound find-file-other-window to a convenient place and almost never used C-x 2/3 again. *Chad [-- Attachment #2: Type: text/html, Size: 738 bytes --] ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: splitting windows and switching buffers 2012-03-28 0:39 ` chad @ 2012-03-28 15:06 ` Sam Steingold 0 siblings, 0 replies; 7+ messages in thread From: Sam Steingold @ 2012-03-28 15:06 UTC (permalink / raw) To: chad; +Cc: Emacs developers > * chad <lnaqebf@tznvy.pbz> [2012-03-27 17:39:31 -0700]: > > On Mar 23, 2012, at 7:59 AM, Sam Steingold wrote: >> >> That's why I have >> >> (defun sds-split-window (size) [...] >> >> bound to [f2] and I (almost) never use C-x 2 or C-x 3. > > I'm curious about this usage pattern; do you often want to split windows > in emacs without doing something specific in the other window? usually f2 gives me the buffer I need in the new window; if it does not, I just hit f9 (bound to quit-window) a few times or f8 (bound to switch-to-prev-buffer). > I rebound find-file-other-window to a convenient place and almost > never used C-x 2/3 again. I usually have all the files I am interested in already in buffers, so typing the full path to find-file-other-window is a waste. -- Sam Steingold (http://sds.podval.org/) on Ubuntu 11.10 (oneiric) X 11.0.11004000 http://www.childpsy.net/ http://palestinefacts.org http://truepeace.org http://camera.org http://dhimmi.com Can I do it in Lisp, or would you rather wait an extra couple of months? ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2012-03-28 15:06 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <4F6AD765.3050404@gmx.at> [not found] ` <87lims5x1q.fsf@gnu.org> [not found] ` <4F6B7937.2070202@gmx.at> [not found] ` <87d3845pk9.fsf@gnu.org> [not found] ` <4F6C51C1.7080903@gmx.at> 2012-03-23 14:59 ` splitting windows and switching buffers Sam Steingold 2012-03-23 19:31 ` martin rudalics 2012-03-24 11:16 ` martin rudalics 2012-03-26 18:37 ` Sam Steingold 2012-03-27 9:24 ` martin rudalics 2012-03-28 0:39 ` chad 2012-03-28 15:06 ` Sam Steingold
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.