diff options
| -rw-r--r-- | etc/NEWS | 3 | ||||
| -rw-r--r-- | lisp/ChangeLog | 10 | ||||
| -rw-r--r-- | lisp/window.el | 86 |
3 files changed, 69 insertions, 30 deletions
| @@ -159,6 +159,9 @@ operate on several directories (copy, rename, diff). | |||
| 159 | ** M-r is bound to the new `move-to-window-line-top-bottom' | 159 | ** M-r is bound to the new `move-to-window-line-top-bottom' |
| 160 | to mirror the new behavior of C-l in Emacs-23.1. | 160 | to mirror the new behavior of C-l in Emacs-23.1. |
| 161 | 161 | ||
| 162 | ** `recenter-positions' can redefine the default cycling order | ||
| 163 | of `recenter-top-bottom'. | ||
| 164 | |||
| 162 | 165 | ||
| 163 | * Changes in Specialized Modes and Packages in Emacs 23.2 | 166 | * Changes in Specialized Modes and Packages in Emacs 23.2 |
| 164 | 167 | ||
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 03d63d96b69..234d50442d4 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,13 @@ | |||
| 1 | 2009-11-29 Juri Linkov <juri@jurta.org> | ||
| 2 | |||
| 3 | Add defcustom to define the cycling order of `recenter-top-bottom'. | ||
| 4 | (Bug#4981) | ||
| 5 | |||
| 6 | * window.el (recenter-last-op): Doc fix. | ||
| 7 | (recenter-positions): New defcustom. | ||
| 8 | (recenter-top-bottom): Rewrite to use `recenter-positions'. | ||
| 9 | (move-to-window-line-top-bottom): Rewrite to use `recenter-positions'. | ||
| 10 | |||
| 1 | 2009-11-29 Michael Albinus <michael.albinus@gmx.de> | 11 | 2009-11-29 Michael Albinus <michael.albinus@gmx.de> |
| 2 | 12 | ||
| 3 | Improve integration of Tramp and ange-ftp in eshell. | 13 | Improve integration of Tramp and ange-ftp in eshell. |
diff --git a/lisp/window.el b/lisp/window.el index ed4cfb5653e..e1b2000844c 100644 --- a/lisp/window.el +++ b/lisp/window.el | |||
| @@ -1618,38 +1618,59 @@ Otherwise, bury WINDOW's buffer, see `bury-buffer'." | |||
| 1618 | 1618 | ||
| 1619 | (defvar recenter-last-op nil | 1619 | (defvar recenter-last-op nil |
| 1620 | "Indicates the last recenter operation performed. | 1620 | "Indicates the last recenter operation performed. |
| 1621 | Possible values: `top', `middle', `bottom'.") | 1621 | Possible values: `top', `middle', `bottom', integer or float numbers.") |
| 1622 | |||
| 1623 | (defcustom recenter-positions '(middle top bottom) | ||
| 1624 | "Cycling order for `recenter-top-bottom'. | ||
| 1625 | A list of elements with possible values `top', `middle', `bottom', | ||
| 1626 | integer or float numbers that define the cycling order for | ||
| 1627 | the command `recenter-top-bottom'. | ||
| 1628 | |||
| 1629 | Top and bottom destinations are `scroll-margin' lines the from true | ||
| 1630 | window top and bottom. Middle redraws the frame and centers point | ||
| 1631 | vertically within the window. Integer number moves current line to | ||
| 1632 | the specified absolute window-line. Float number between 0.0 and 1.0 | ||
| 1633 | means the percentage of the screen space from the top. The default | ||
| 1634 | cycling order is middle -> top -> bottom." | ||
| 1635 | :type '(repeat (choice | ||
| 1636 | (const :tag "Top" top) | ||
| 1637 | (const :tag "Middle" middle) | ||
| 1638 | (const :tag "Bottom" bottom) | ||
| 1639 | (integer :tag "Line number") | ||
| 1640 | (float :tag "Percentage"))) | ||
| 1641 | :version "23.2" | ||
| 1642 | :group 'windows) | ||
| 1622 | 1643 | ||
| 1623 | (defun recenter-top-bottom (&optional arg) | 1644 | (defun recenter-top-bottom (&optional arg) |
| 1624 | "Move current line to window center, top, and bottom, successively. | 1645 | "Move current buffer line to the specified window line. |
| 1625 | With no prefix argument, the first call redraws the frame and | 1646 | With no prefix argument, successive calls place point according |
| 1626 | centers point vertically within the window. Successive calls | 1647 | to the cycling order defined by `recenter-positions'. |
| 1627 | scroll the window, placing point on the top, bottom, and middle | ||
| 1628 | consecutively. The cycling order is middle -> top -> bottom. | ||
| 1629 | 1648 | ||
| 1630 | A prefix argument is handled like `recenter': | 1649 | A prefix argument is handled like `recenter': |
| 1631 | With numeric prefix ARG, move current line to window-line ARG. | 1650 | With numeric prefix ARG, move current line to window-line ARG. |
| 1632 | With plain `C-u', move current line to window center. | 1651 | With plain `C-u', move current line to window center." |
| 1633 | |||
| 1634 | Top and bottom destinations are actually `scroll-margin' lines | ||
| 1635 | the from true window top and bottom." | ||
| 1636 | (interactive "P") | 1652 | (interactive "P") |
| 1637 | (cond | 1653 | (cond |
| 1638 | (arg (recenter arg)) ; Always respect ARG. | 1654 | (arg (recenter arg)) ; Always respect ARG. |
| 1639 | ((or (not (eq this-command last-command)) | ||
| 1640 | (eq recenter-last-op 'bottom)) | ||
| 1641 | (setq recenter-last-op 'middle) | ||
| 1642 | (recenter)) | ||
| 1643 | (t | 1655 | (t |
| 1656 | (setq recenter-last-op | ||
| 1657 | (if (eq this-command last-command) | ||
| 1658 | (car (or (cdr (member recenter-last-op recenter-positions)) | ||
| 1659 | recenter-positions)) | ||
| 1660 | (car recenter-positions))) | ||
| 1644 | (let ((this-scroll-margin | 1661 | (let ((this-scroll-margin |
| 1645 | (min (max 0 scroll-margin) | 1662 | (min (max 0 scroll-margin) |
| 1646 | (truncate (/ (window-body-height) 4.0))))) | 1663 | (truncate (/ (window-body-height) 4.0))))) |
| 1647 | (cond ((eq recenter-last-op 'middle) | 1664 | (cond ((eq recenter-last-op 'middle) |
| 1648 | (setq recenter-last-op 'top) | 1665 | (recenter)) |
| 1649 | (recenter this-scroll-margin)) | ||
| 1650 | ((eq recenter-last-op 'top) | 1666 | ((eq recenter-last-op 'top) |
| 1651 | (setq recenter-last-op 'bottom) | 1667 | (recenter this-scroll-margin)) |
| 1652 | (recenter (- -1 this-scroll-margin)))))))) | 1668 | ((eq recenter-last-op 'bottom) |
| 1669 | (recenter (- -1 this-scroll-margin))) | ||
| 1670 | ((integerp recenter-last-op) | ||
| 1671 | (recenter recenter-last-op)) | ||
| 1672 | ((floatp recenter-last-op) | ||
| 1673 | (recenter (round (* recenter-last-op (window-height)))))))))) | ||
| 1653 | 1674 | ||
| 1654 | (define-key global-map [?\C-l] 'recenter-top-bottom) | 1675 | (define-key global-map [?\C-l] 'recenter-top-bottom) |
| 1655 | 1676 | ||
| @@ -1659,25 +1680,30 @@ Top and bottom destinations are actually `scroll-margin' lines | |||
| 1659 | With a prefix argument ARG, acts like `move-to-window-line'. | 1680 | With a prefix argument ARG, acts like `move-to-window-line'. |
| 1660 | 1681 | ||
| 1661 | With no argument, positions point at center of window. | 1682 | With no argument, positions point at center of window. |
| 1662 | Successive calls position point at the top, the bottom and again | 1683 | Successive calls position point at positions defined |
| 1663 | at the center of the window." | 1684 | by `recenter-positions'." |
| 1664 | (interactive "P") | 1685 | (interactive "P") |
| 1665 | (cond | 1686 | (cond |
| 1666 | (arg (move-to-window-line arg)) ; Always respect ARG. | 1687 | (arg (move-to-window-line arg)) ; Always respect ARG. |
| 1667 | ((or (not (eq this-command last-command)) | ||
| 1668 | (eq recenter-last-op 'bottom)) | ||
| 1669 | (setq recenter-last-op 'middle) | ||
| 1670 | (call-interactively 'move-to-window-line)) | ||
| 1671 | (t | 1688 | (t |
| 1689 | (setq recenter-last-op | ||
| 1690 | (if (eq this-command last-command) | ||
| 1691 | (car (or (cdr (member recenter-last-op recenter-positions)) | ||
| 1692 | recenter-positions)) | ||
| 1693 | (car recenter-positions))) | ||
| 1672 | (let ((this-scroll-margin | 1694 | (let ((this-scroll-margin |
| 1673 | (min (max 0 scroll-margin) | 1695 | (min (max 0 scroll-margin) |
| 1674 | (truncate (/ (window-body-height) 4.0))))) | 1696 | (truncate (/ (window-body-height) 4.0))))) |
| 1675 | (cond ((eq recenter-last-op 'middle) | 1697 | (cond ((eq recenter-last-op 'middle) |
| 1676 | (setq recenter-last-op 'top) | 1698 | (call-interactively 'move-to-window-line)) |
| 1677 | (move-to-window-line this-scroll-margin)) | ||
| 1678 | ((eq recenter-last-op 'top) | 1699 | ((eq recenter-last-op 'top) |
| 1679 | (setq recenter-last-op 'bottom) | 1700 | (move-to-window-line this-scroll-margin)) |
| 1680 | (move-to-window-line (- -1 this-scroll-margin)))))))) | 1701 | ((eq recenter-last-op 'bottom) |
| 1702 | (move-to-window-line (- -1 this-scroll-margin))) | ||
| 1703 | ((integerp recenter-last-op) | ||
| 1704 | (move-to-window-line recenter-last-op)) | ||
| 1705 | ((floatp recenter-last-op) | ||
| 1706 | (move-to-window-line (round (* recenter-last-op (window-height)))))))))) | ||
| 1681 | 1707 | ||
| 1682 | (define-key global-map [?\M-r] 'move-to-window-line-top-bottom) | 1708 | (define-key global-map [?\M-r] 'move-to-window-line-top-bottom) |
| 1683 | 1709 | ||