From: Martin Rudalics Date: Tue, 31 Jul 2012 08:36:32 +0000 (+0200) Subject: Fix return values of switch-to-prev/next-buffer. X-Git-Tag: emacs-24.2.90~965 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=502e3f8935f177f2d998c38cb3367439a77292c5;p=emacs.git Fix return values of switch-to-prev/next-buffer. * window.el (switch-to-prev-buffer, switch-to-next-buffer): Don't return a non-nil value when no suitable buffer was found. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 20b31e1f9f4..d56963ac5b0 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2012-07-31 Martin Rudalics + + * window.el (switch-to-prev-buffer, switch-to-next-buffer): + Don't return a non-nil value when no suitable buffer was found. + 2012-07-31 Fabián Ezequiel Gallina * progmodes/python.el (run-python-internal): Disable font lock for diff --git a/lisp/window.el b/lisp/window.el index d58fa81a8de..910164043d9 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -2669,6 +2669,8 @@ that is already visible in another window on the same frame." (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. +Return the buffer switched to, nil if no suitable buffer could be +found. Optional argument BURY-OR-KILL non-nil means the buffer currently shown in WINDOW is about to be buried or killed and consequently @@ -2679,7 +2681,7 @@ shall not be switched to in future invocations of this command." (old-buffer (window-buffer window)) ;; Save this since it's destroyed by `set-window-buffer'. (next-buffers (window-next-buffers window)) - entry new-buffer killed-buffers visible) + entry buffer new-buffer killed-buffers visible) (when (window-dedicated-p window) (error "Window %s is dedicated to buffer %s" window old-buffer)) @@ -2687,20 +2689,20 @@ shall not be switched to in future invocations of this command." ;; Scan WINDOW's previous buffers first, skipping entries of next ;; buffers. (dolist (entry (window-prev-buffers window)) - (when (and (setq new-buffer (car entry)) - (or (buffer-live-p new-buffer) + (when (and (setq buffer (car entry)) + (or (buffer-live-p buffer) (not (setq killed-buffers - (cons new-buffer killed-buffers)))) - (not (eq new-buffer old-buffer)) - (or bury-or-kill - (not (memq new-buffer next-buffers)))) + (cons buffer killed-buffers)))) + (not (eq buffer old-buffer)) + (or bury-or-kill (not (memq buffer next-buffers)))) (if (and (not switch-to-visible-buffer) - (get-buffer-window new-buffer frame)) + (get-buffer-window 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)))) + (setq visible buffer) + (setq new-buffer buffer) + (set-window-buffer-start-and-point + window new-buffer (nth 1 entry) (nth 2 entry)) + (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 @@ -2767,13 +2769,15 @@ shall not be switched to in future invocations of this command." (defun switch-to-next-buffer (&optional window) "In WINDOW switch to next buffer. -WINDOW must be a live window and defaults to the selected one." +WINDOW must be a live window and defaults to the selected one. +Return the buffer switched to, nil if no suitable buffer could be +found." (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) + buffer new-buffer entry killed-buffers visible) (when (window-dedicated-p window) (error "Window %s is dedicated to buffer %s" window old-buffer)) @@ -2804,16 +2808,17 @@ WINDOW must be a live window and defaults to the selected one." ;; Scan WINDOW's reverted previous buffers last (must not use ;; nreverse here!) (dolist (entry (reverse (window-prev-buffers window))) - (when (and (setq new-buffer (car entry)) - (or (buffer-live-p new-buffer) + (when (and (setq buffer (car entry)) + (or (buffer-live-p buffer) (not (setq killed-buffers - (cons new-buffer killed-buffers)))) - (not (eq new-buffer old-buffer))) + (cons buffer killed-buffers)))) + (not (eq buffer old-buffer))) (if (and (not switch-to-visible-buffer) - (get-buffer-window new-buffer frame)) + (get-buffer-window buffer frame)) ;; Try to avoid showing a buffer visible in some other window. (unless visible - (setq visible new-buffer)) + (setq visible buffer)) + (setq new-buffer buffer) (set-window-buffer-start-and-point window new-buffer (nth 1 entry) (nth 2 entry)) (throw 'found t))))