diff options
| author | Martin Rudalics | 2012-07-31 10:36:32 +0200 |
|---|---|---|
| committer | Martin Rudalics | 2012-07-31 10:36:32 +0200 |
| commit | 502e3f8935f177f2d998c38cb3367439a77292c5 (patch) | |
| tree | d20426bf79f84e0254c7ec2fe3a03718e2637cd6 | |
| parent | 57ae02b1db359c1d00baf7b4323e2bb313f0fd8c (diff) | |
| download | emacs-502e3f8935f177f2d998c38cb3367439a77292c5.tar.gz emacs-502e3f8935f177f2d998c38cb3367439a77292c5.zip | |
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.
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/window.el | 45 |
2 files changed, 30 insertions, 20 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 20b31e1f9f4..d56963ac5b0 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2012-07-31 Martin Rudalics <rudalics@gmx.at> | ||
| 2 | |||
| 3 | * window.el (switch-to-prev-buffer, switch-to-next-buffer): | ||
| 4 | Don't return a non-nil value when no suitable buffer was found. | ||
| 5 | |||
| 1 | 2012-07-31 Fabián Ezequiel Gallina <fgallina@cuca> | 6 | 2012-07-31 Fabián Ezequiel Gallina <fgallina@cuca> |
| 2 | 7 | ||
| 3 | * progmodes/python.el (run-python-internal): Disable font lock for | 8 | * 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." | |||
| 2669 | (defun switch-to-prev-buffer (&optional window bury-or-kill) | 2669 | (defun switch-to-prev-buffer (&optional window bury-or-kill) |
| 2670 | "In WINDOW switch to previous buffer. | 2670 | "In WINDOW switch to previous buffer. |
| 2671 | WINDOW must be a live window and defaults to the selected one. | 2671 | WINDOW must be a live window and defaults to the selected one. |
| 2672 | Return the buffer switched to, nil if no suitable buffer could be | ||
| 2673 | found. | ||
| 2672 | 2674 | ||
| 2673 | Optional argument BURY-OR-KILL non-nil means the buffer currently | 2675 | Optional argument BURY-OR-KILL non-nil means the buffer currently |
| 2674 | shown in WINDOW is about to be buried or killed and consequently | 2676 | 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." | |||
| 2679 | (old-buffer (window-buffer window)) | 2681 | (old-buffer (window-buffer window)) |
| 2680 | ;; Save this since it's destroyed by `set-window-buffer'. | 2682 | ;; Save this since it's destroyed by `set-window-buffer'. |
| 2681 | (next-buffers (window-next-buffers window)) | 2683 | (next-buffers (window-next-buffers window)) |
| 2682 | entry new-buffer killed-buffers visible) | 2684 | entry buffer new-buffer killed-buffers visible) |
| 2683 | (when (window-dedicated-p window) | 2685 | (when (window-dedicated-p window) |
| 2684 | (error "Window %s is dedicated to buffer %s" window old-buffer)) | 2686 | (error "Window %s is dedicated to buffer %s" window old-buffer)) |
| 2685 | 2687 | ||
| @@ -2687,20 +2689,20 @@ shall not be switched to in future invocations of this command." | |||
| 2687 | ;; Scan WINDOW's previous buffers first, skipping entries of next | 2689 | ;; Scan WINDOW's previous buffers first, skipping entries of next |
| 2688 | ;; buffers. | 2690 | ;; buffers. |
| 2689 | (dolist (entry (window-prev-buffers window)) | 2691 | (dolist (entry (window-prev-buffers window)) |
| 2690 | (when (and (setq new-buffer (car entry)) | 2692 | (when (and (setq buffer (car entry)) |
| 2691 | (or (buffer-live-p new-buffer) | 2693 | (or (buffer-live-p buffer) |
| 2692 | (not (setq killed-buffers | 2694 | (not (setq killed-buffers |
| 2693 | (cons new-buffer killed-buffers)))) | 2695 | (cons buffer killed-buffers)))) |
| 2694 | (not (eq new-buffer old-buffer)) | 2696 | (not (eq buffer old-buffer)) |
| 2695 | (or bury-or-kill | 2697 | (or bury-or-kill (not (memq buffer next-buffers)))) |
| 2696 | (not (memq new-buffer next-buffers)))) | ||
| 2697 | (if (and (not switch-to-visible-buffer) | 2698 | (if (and (not switch-to-visible-buffer) |
| 2698 | (get-buffer-window new-buffer frame)) | 2699 | (get-buffer-window buffer frame)) |
| 2699 | ;; Try to avoid showing a buffer visible in some other window. | 2700 | ;; Try to avoid showing a buffer visible in some other window. |
| 2700 | (setq visible new-buffer) | 2701 | (setq visible buffer) |
| 2701 | (set-window-buffer-start-and-point | 2702 | (setq new-buffer buffer) |
| 2702 | window new-buffer (nth 1 entry) (nth 2 entry)) | 2703 | (set-window-buffer-start-and-point |
| 2703 | (throw 'found t)))) | 2704 | window new-buffer (nth 1 entry) (nth 2 entry)) |
| 2705 | (throw 'found t)))) | ||
| 2704 | ;; Scan reverted buffer list of WINDOW's frame next, skipping | 2706 | ;; Scan reverted buffer list of WINDOW's frame next, skipping |
| 2705 | ;; entries of next buffers. Note that when we bury or kill a | 2707 | ;; entries of next buffers. Note that when we bury or kill a |
| 2706 | ;; buffer we don't reverse the global buffer list to avoid showing | 2708 | ;; 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." | |||
| 2767 | 2769 | ||
| 2768 | (defun switch-to-next-buffer (&optional window) | 2770 | (defun switch-to-next-buffer (&optional window) |
| 2769 | "In WINDOW switch to next buffer. | 2771 | "In WINDOW switch to next buffer. |
| 2770 | WINDOW must be a live window and defaults to the selected one." | 2772 | WINDOW must be a live window and defaults to the selected one. |
| 2773 | Return the buffer switched to, nil if no suitable buffer could be | ||
| 2774 | found." | ||
| 2771 | (interactive) | 2775 | (interactive) |
| 2772 | (let* ((window (window-normalize-window window t)) | 2776 | (let* ((window (window-normalize-window window t)) |
| 2773 | (frame (window-frame window)) | 2777 | (frame (window-frame window)) |
| 2774 | (old-buffer (window-buffer window)) | 2778 | (old-buffer (window-buffer window)) |
| 2775 | (next-buffers (window-next-buffers window)) | 2779 | (next-buffers (window-next-buffers window)) |
| 2776 | new-buffer entry killed-buffers visible) | 2780 | buffer new-buffer entry killed-buffers visible) |
| 2777 | (when (window-dedicated-p window) | 2781 | (when (window-dedicated-p window) |
| 2778 | (error "Window %s is dedicated to buffer %s" window old-buffer)) | 2782 | (error "Window %s is dedicated to buffer %s" window old-buffer)) |
| 2779 | 2783 | ||
| @@ -2804,16 +2808,17 @@ WINDOW must be a live window and defaults to the selected one." | |||
| 2804 | ;; Scan WINDOW's reverted previous buffers last (must not use | 2808 | ;; Scan WINDOW's reverted previous buffers last (must not use |
| 2805 | ;; nreverse here!) | 2809 | ;; nreverse here!) |
| 2806 | (dolist (entry (reverse (window-prev-buffers window))) | 2810 | (dolist (entry (reverse (window-prev-buffers window))) |
| 2807 | (when (and (setq new-buffer (car entry)) | 2811 | (when (and (setq buffer (car entry)) |
| 2808 | (or (buffer-live-p new-buffer) | 2812 | (or (buffer-live-p buffer) |
| 2809 | (not (setq killed-buffers | 2813 | (not (setq killed-buffers |
| 2810 | (cons new-buffer killed-buffers)))) | 2814 | (cons buffer killed-buffers)))) |
| 2811 | (not (eq new-buffer old-buffer))) | 2815 | (not (eq buffer old-buffer))) |
| 2812 | (if (and (not switch-to-visible-buffer) | 2816 | (if (and (not switch-to-visible-buffer) |
| 2813 | (get-buffer-window new-buffer frame)) | 2817 | (get-buffer-window buffer frame)) |
| 2814 | ;; Try to avoid showing a buffer visible in some other window. | 2818 | ;; Try to avoid showing a buffer visible in some other window. |
| 2815 | (unless visible | 2819 | (unless visible |
| 2816 | (setq visible new-buffer)) | 2820 | (setq visible buffer)) |
| 2821 | (setq new-buffer buffer) | ||
| 2817 | (set-window-buffer-start-and-point | 2822 | (set-window-buffer-start-and-point |
| 2818 | window new-buffer (nth 1 entry) (nth 2 entry)) | 2823 | window new-buffer (nth 1 entry) (nth 2 entry)) |
| 2819 | (throw 'found t)))) | 2824 | (throw 'found t)))) |