diff options
| author | Martin Rudalics | 2011-10-05 10:59:13 +0200 |
|---|---|---|
| committer | Martin Rudalics | 2011-10-05 10:59:13 +0200 |
| commit | c96111ea5502c92b1b0f25125bede71efbbc1b82 (patch) | |
| tree | f2f51b928610a51a394b9651128ca42a2cd2b71f | |
| parent | 5a4cf282349bc0cb2a6a30321c6418907c5f37a4 (diff) | |
| download | emacs-c96111ea5502c92b1b0f25125bede71efbbc1b82.tar.gz emacs-c96111ea5502c92b1b0f25125bede71efbbc1b82.zip | |
New functions window-point-1 and set-window-point-1.
* window.el (window-point-1, set-window-point-1): New functions.
(window-in-direction, record-window-buffer, window-state-get-1)
(display-buffer-record-window): Use window-point-1 instead of
window-point.
(set-window-buffer-start-and-point): Use set-window-point-1.
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/window.el | 46 |
2 files changed, 36 insertions, 15 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index e8196fbea75..91f66fcf938 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -4,6 +4,11 @@ | |||
| 4 | frame-auto-delete. Suggested by Stefan Monnier. | 4 | frame-auto-delete. Suggested by Stefan Monnier. |
| 5 | (window--delete): Call frame-auto-hide-function instead of | 5 | (window--delete): Call frame-auto-hide-function instead of |
| 6 | investigating frame-auto-delete. | 6 | investigating frame-auto-delete. |
| 7 | (window-point-1, set-window-point-1): New functions. | ||
| 8 | (window-in-direction, record-window-buffer, window-state-get-1) | ||
| 9 | (display-buffer-record-window): Use window-point-1 instead of | ||
| 10 | window-point. | ||
| 11 | (set-window-buffer-start-and-point): Use set-window-point-1. | ||
| 7 | 12 | ||
| 8 | 2011-10-05 Stefan Monnier <monnier@iro.umontreal.ca> | 13 | 2011-10-05 Stefan Monnier <monnier@iro.umontreal.ca> |
| 9 | 14 | ||
diff --git a/lisp/window.el b/lisp/window.el index a8b506cb7bf..74460ae6058 100644 --- a/lisp/window.el +++ b/lisp/window.el | |||
| @@ -1058,6 +1058,32 @@ windows nor the buffer list." | |||
| 1058 | (dolist (walk-windows-window (window-list-1 nil minibuf all-frames)) | 1058 | (dolist (walk-windows-window (window-list-1 nil minibuf all-frames)) |
| 1059 | (funcall proc walk-windows-window)))) | 1059 | (funcall proc walk-windows-window)))) |
| 1060 | 1060 | ||
| 1061 | (defun window-point-1 (&optional window) | ||
| 1062 | "Return value of WINDOW's point. | ||
| 1063 | WINDOW can be any live window and defaults to the selected one. | ||
| 1064 | |||
| 1065 | This function is like `window-point' with one exception: If | ||
| 1066 | WINDOW is selected, it returns the value of `point' of WINDOW's | ||
| 1067 | buffer regardless of whether that buffer is current or not." | ||
| 1068 | (setq window (window-normalize-live-window window)) | ||
| 1069 | (if (eq window (selected-window)) | ||
| 1070 | (with-current-buffer (window-buffer window) | ||
| 1071 | (point)) | ||
| 1072 | (window-point window))) | ||
| 1073 | |||
| 1074 | (defun set-window-point-1 (window pos) | ||
| 1075 | "Set value of WINDOW's point to POS. | ||
| 1076 | WINDOW can be any live window and defaults to the selected one. | ||
| 1077 | |||
| 1078 | This function is like `set-window-point' with one exception: If | ||
| 1079 | WINDOW is selected, it moves `point' of WINDOW's buffer to POS | ||
| 1080 | regardless of whether that buffer is current or not." | ||
| 1081 | (setq window (window-normalize-live-window window)) | ||
| 1082 | (if (eq window (selected-window)) | ||
| 1083 | (with-current-buffer (window-buffer window) | ||
| 1084 | (goto-char pos)) | ||
| 1085 | (set-window-point window pos))) | ||
| 1086 | |||
| 1061 | (defun window-in-direction-2 (window posn &optional horizontal) | 1087 | (defun window-in-direction-2 (window posn &optional horizontal) |
| 1062 | "Support function for `window-in-direction'." | 1088 | "Support function for `window-in-direction'." |
| 1063 | (if horizontal | 1089 | (if horizontal |
| @@ -1087,7 +1113,7 @@ IGNORE, when non-nil means a window can be returned even if its | |||
| 1087 | (last (+ first (if hor | 1113 | (last (+ first (if hor |
| 1088 | (window-total-width window) | 1114 | (window-total-width window) |
| 1089 | (window-total-height window)))) | 1115 | (window-total-height window)))) |
| 1090 | (posn-cons (nth 6 (posn-at-point (window-point window) window))) | 1116 | (posn-cons (nth 6 (posn-at-point (window-point-1 window) window))) |
| 1091 | ;; The column / row value of `posn-at-point' can be nil for the | 1117 | ;; The column / row value of `posn-at-point' can be nil for the |
| 1092 | ;; mini-window, guard against that. | 1118 | ;; mini-window, guard against that. |
| 1093 | (posn (if hor | 1119 | (posn (if hor |
| @@ -2492,7 +2518,7 @@ WINDOW must be a live window and defaults to the selected one." | |||
| 2492 | ;; Add an entry for buffer to WINDOW's previous buffers. | 2518 | ;; Add an entry for buffer to WINDOW's previous buffers. |
| 2493 | (with-current-buffer buffer | 2519 | (with-current-buffer buffer |
| 2494 | (let ((start (window-start window)) | 2520 | (let ((start (window-start window)) |
| 2495 | (point (window-point window))) | 2521 | (point (window-point-1 window))) |
| 2496 | (setq entry | 2522 | (setq entry |
| 2497 | (cons buffer | 2523 | (cons buffer |
| 2498 | (if entry | 2524 | (if entry |
| @@ -2534,10 +2560,7 @@ before was current this also makes BUFFER the current buffer." | |||
| 2534 | ;; Don't force window-start here (even if POINT is nil). | 2560 | ;; Don't force window-start here (even if POINT is nil). |
| 2535 | (set-window-start window start t)) | 2561 | (set-window-start window start t)) |
| 2536 | (when point | 2562 | (when point |
| 2537 | (if selected | 2563 | (set-window-point-1 window point)))) |
| 2538 | (with-current-buffer buffer | ||
| 2539 | (goto-char point)) | ||
| 2540 | (set-window-point window point))))) | ||
| 2541 | 2564 | ||
| 2542 | (defun switch-to-prev-buffer (&optional window bury-or-kill) | 2565 | (defun switch-to-prev-buffer (&optional window bury-or-kill) |
| 2543 | "In WINDOW switch to previous buffer. | 2566 | "In WINDOW switch to previous buffer. |
| @@ -3550,7 +3573,7 @@ specific buffers." | |||
| 3550 | ;; All buffer related things go in here - make the buffer | 3573 | ;; All buffer related things go in here - make the buffer |
| 3551 | ;; current when retrieving `point' and `mark'. | 3574 | ;; current when retrieving `point' and `mark'. |
| 3552 | (with-current-buffer (window-buffer window) | 3575 | (with-current-buffer (window-buffer window) |
| 3553 | (let ((point (if selected (point) (window-point window))) | 3576 | (let ((point (window-point-1 window)) |
| 3554 | (start (window-start window)) | 3577 | (start (window-start window)) |
| 3555 | (mark (mark))) | 3578 | (mark (mark))) |
| 3556 | (window-list-no-nils | 3579 | (window-list-no-nils |
| @@ -3845,14 +3868,7 @@ element is BUFFER." | |||
| 3845 | (list 'other | 3868 | (list 'other |
| 3846 | ;; A quadruple of WINDOW's buffer, start, point and height. | 3869 | ;; A quadruple of WINDOW's buffer, start, point and height. |
| 3847 | (list (window-buffer window) (window-start window) | 3870 | (list (window-buffer window) (window-start window) |
| 3848 | (if (eq window (selected-window)) | 3871 | (window-point-1 window) (window-total-size window)) |
| 3849 | ;; When WINDOW is the selected window use its | ||
| 3850 | ;; buffer's `point' instead of `window-point' | ||
| 3851 | ;; (Bug#9626). | ||
| 3852 | (with-current-buffer (window-buffer window) | ||
| 3853 | (point)) | ||
| 3854 | (window-point window)) | ||
| 3855 | (window-total-size window)) | ||
| 3856 | (selected-window) buffer)))) | 3872 | (selected-window) buffer)))) |
| 3857 | ((eq type 'window) | 3873 | ((eq type 'window) |
| 3858 | ;; WINDOW has been created on an existing frame. | 3874 | ;; WINDOW has been created on an existing frame. |