From 159284a8e5ef2125a879d6e864ed1f308b518c4f Mon Sep 17 00:00:00 2001 From: Andreas Gerler Date: Tue, 13 Nov 2018 11:41:26 +0100 Subject: [PATCH] update centered-cursor-mode. Signed-off-by: Andreas Gerler --- .../centered-cursor-mode-pkg.el | 1 - .../centered-cursor-mode-autoloads.el | 15 ++++- .../centered-cursor-mode-pkg.el | 2 + .../centered-cursor-mode.el | 55 ++++++++++++------- 4 files changed, 50 insertions(+), 23 deletions(-) delete mode 100644 elpa/centered-cursor-mode-20151001.634/centered-cursor-mode-pkg.el rename elpa/{centered-cursor-mode-20151001.634 => centered-cursor-mode-20180112.1555}/centered-cursor-mode-autoloads.el (55%) create mode 100644 elpa/centered-cursor-mode-20180112.1555/centered-cursor-mode-pkg.el rename elpa/{centered-cursor-mode-20151001.634 => centered-cursor-mode-20180112.1555}/centered-cursor-mode.el (89%) diff --git a/elpa/centered-cursor-mode-20151001.634/centered-cursor-mode-pkg.el b/elpa/centered-cursor-mode-20151001.634/centered-cursor-mode-pkg.el deleted file mode 100644 index b899942b..00000000 --- a/elpa/centered-cursor-mode-20151001.634/centered-cursor-mode-pkg.el +++ /dev/null @@ -1 +0,0 @@ -(define-package "centered-cursor-mode" "20151001.634" "cursor stays vertically centered" 'nil :url "http://www.emacswiki.org/cgi-bin/wiki/centered-cursor-mode.el" :keywords '("convenience")) diff --git a/elpa/centered-cursor-mode-20151001.634/centered-cursor-mode-autoloads.el b/elpa/centered-cursor-mode-20180112.1555/centered-cursor-mode-autoloads.el similarity index 55% rename from elpa/centered-cursor-mode-20151001.634/centered-cursor-mode-autoloads.el rename to elpa/centered-cursor-mode-20180112.1555/centered-cursor-mode-autoloads.el index 4d14f051..474f1bff 100644 --- a/elpa/centered-cursor-mode-20151001.634/centered-cursor-mode-autoloads.el +++ b/elpa/centered-cursor-mode-20180112.1555/centered-cursor-mode-autoloads.el @@ -1,23 +1,34 @@ ;;; centered-cursor-mode-autoloads.el --- automatically extracted autoloads ;; ;;; Code: -(add-to-list 'load-path (or (file-name-directory #$) (car load-path))) + +(add-to-list 'load-path (directory-file-name + (or (file-name-directory #$) (car load-path)))) + ;;;### (autoloads nil "centered-cursor-mode" "centered-cursor-mode.el" -;;;;;; (22215 9186 0 0)) +;;;;;; (0 0 0 0)) ;;; Generated autoloads from centered-cursor-mode.el +(autoload 'ccm-visible-text-lines "centered-cursor-mode" "\ +Visible text lines + +\(fn)" nil nil) + (autoload 'centered-cursor-mode "centered-cursor-mode" "\ Makes the cursor stay vertically in a defined position (usually centered). \(fn &optional ARG)" t nil) +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "centered-cursor-mode" '("global-centered-cursor-mode" "ccm-" "recenter-sequence" "animate-first-start-p"))) + ;;;*** ;; Local Variables: ;; version-control: never ;; no-byte-compile: t ;; no-update-autoloads: t +;; coding: utf-8 ;; End: ;;; centered-cursor-mode-autoloads.el ends here diff --git a/elpa/centered-cursor-mode-20180112.1555/centered-cursor-mode-pkg.el b/elpa/centered-cursor-mode-20180112.1555/centered-cursor-mode-pkg.el new file mode 100644 index 00000000..684c4b51 --- /dev/null +++ b/elpa/centered-cursor-mode-20180112.1555/centered-cursor-mode-pkg.el @@ -0,0 +1,2 @@ +;;; -*- no-byte-compile: t -*- +(define-package "centered-cursor-mode" "20180112.1555" "cursor stays vertically centered" 'nil :commit "00fb47d227f9e211ec1c58161a501a1550c3a60d" :keywords '("convenience") :authors '(("André Riemann" . "andre.riemann@web.de")) :maintainer '("André Riemann" . "andre.riemann@web.de") :url "https://github.com/andre-r/centered-cursor-mode.el") diff --git a/elpa/centered-cursor-mode-20151001.634/centered-cursor-mode.el b/elpa/centered-cursor-mode-20180112.1555/centered-cursor-mode.el similarity index 89% rename from elpa/centered-cursor-mode-20151001.634/centered-cursor-mode.el rename to elpa/centered-cursor-mode-20180112.1555/centered-cursor-mode.el index 1e2f6155..1b194e86 100644 --- a/elpa/centered-cursor-mode-20151001.634/centered-cursor-mode.el +++ b/elpa/centered-cursor-mode-20180112.1555/centered-cursor-mode.el @@ -6,13 +6,12 @@ ;; Maintainer: André Riemann ;; Created: 2007-09-14 ;; Keywords: convenience -;; Package-Version: 20151001.634 -;; Package-X-Original-Version: 20150302.831 +;; Package-Version: 20180112.1555 -;; URL: http://www.emacswiki.org/cgi-bin/wiki/centered-cursor-mode.el -;; Compatibility: tested with GNU Emacs 23.0, 24 -;; Version: 0.5.4 -;; Last-Updated: 2015-10-01 +;; URL: https://github.com/andre-r/centered-cursor-mode.el +;; Compatibility: tested with GNU Emacs 23.0, 24, 26 +;; Version: 0.5.7 +;; Last-Updated: 2018-01-12 ;; This file is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by @@ -58,6 +57,13 @@ ;; - more bugs? ;;; Change Log: +;; 2018-01-12 andre-r +;; * #3: Centering does not take line-height into account +;; - added new function for calculating visible lines +;; * #2: Bug with collapsed lines (eg. org-mode) +;; - used count-screen-lines instead of count-lines +;; 2017-08-30 chrm +;; * Fixed a bug with recentering at end of file ;; 2015-10-01 Hinrik Örn Sigurðsson ;; * Avoided calling count-lines when unnecessary, which ;; fixes slow scrolling in large files @@ -127,6 +133,7 @@ If you want a different animation speed." :type 'number) (defcustom ccm-ignored-commands '(mouse-drag-region + mouse-set-region mouse-set-point widget-button-click scroll-bar-toolkit-scroll) @@ -139,12 +146,18 @@ jumping to the center." :tag "Ignored commands" :type '(repeat (symbol :tag "Command"))) -(defcustom ccm-vpos-init '(round (window-text-height) 2) +;;;###autoload +(defun ccm-visible-text-lines () + "Visible text lines" + (/ (- (window-pixel-height) (window-header-line-height) (window-mode-line-height)) + (default-line-height))) + +(defcustom ccm-vpos-init '(round (ccm-visible-text-lines) 2) "This is the screen line position where the cursor initially stays." :group 'centered-cursor :tag "Vertical cursor position" - :type '(choice (const :tag "Center" (round (window-text-height) 2)) - (const :tag "Golden ratio" (round (* 21 (window-text-height)) 34)) + :type '(choice (const :tag "Center" (round (ccm-visible-text-lines) 2)) + (const :tag "Golden ratio" (round (* 21 (ccm-visible-text-lines)) 34)) (integer :tag "Lines from top" :value 10))) (make-variable-buffer-local 'ccm-vpos-init) @@ -224,7 +237,7 @@ behaviour with automatic recentering." ;;(message "%S" mods) (if amt (setq amt (or (cdr amt) - (- (window-text-height) + (- (ccm-visible-text-lines) next-screen-context-lines))) (let ((list-elt mouse-wheel-scroll-amount)) (while (consp (setq amt (pop list-elt)))))) @@ -247,7 +260,7 @@ buffer. This version actually moves the cursor with `previous-line'. Since with centered-cursor-mode the cursor is in a fixed position the movement appears as page up." (interactive "P") - (let ((amt (or arg (- (window-text-height) + (let ((amt (or arg (- (ccm-visible-text-lines) next-screen-context-lines)))) (forward-line (- amt)))) @@ -257,7 +270,7 @@ This version actually moves the cursor with `previous-line'. Since with centered-cursor-mode the cursor is in a fixed position the movement appears as page up." (interactive "P") - (let ((amt (or arg (- (window-text-height) + (let ((amt (or arg (- (ccm-visible-text-lines) next-screen-context-lines)))) (forward-line amt))) @@ -274,9 +287,9 @@ is set." ;; see pos-visible-in-window-p (vpos-max (if (< ccm-vpos 0) -1 - (- (window-text-height) 1))) + (- (ccm-visible-text-lines) 1))) (vpos-min (if (< ccm-vpos 0) - (- (window-text-height)) + (- (ccm-visible-text-lines)) 0))) (setq ccm-vpos (cond @@ -313,14 +326,14 @@ the center. Just the variable ccm-vpos is set." (let* ((current-line (if (< ccm-vpos 0) ;; one-based, from bottom, negative - (- (count-lines (point) + (- (count-screen-lines (point) ;; window-end is sometimes < 0 ;; when opening a help buffer (if (> (window-end) 0) (window-end) 1))) ;; zero-based, from top, positive - (+ (count-lines (window-start) (point)) + (+ (count-screen-lines (window-start) (point)) ;; count-lines returns different value in column 0 (if (= (current-column) 0) 0 -1)))) (diff (- ccm-vpos current-line)) @@ -331,17 +344,19 @@ the center. Just the variable ccm-vpos is set." (let* ((bottom-vpos (if (< ccm-vpos 0) (- ccm-vpos) - (- (window-text-height) ccm-vpos))) + (- (ccm-visible-text-lines) ccm-vpos))) (correction (save-excursion (if (or (= (point) (point-max)) (progn (goto-char (point-max)) (zerop (current-column)))) 1 0))) - (window-is-at-bottom (= (window-end) (point-max))) + (window-is-at-bottom (or (= (window-end) (point-max)) ; doesn't work when scrolling (eg. pgdwn) + (= (line-end-position ccm-vpos) (point-max)) ; doesn't work on repls second to last line, because the prompt gets inserted later? + )) ;; lines from point to end of buffer (bottom-lines (if window-is-at-bottom - (+ (count-lines (point) (point-max)) + (+ (count-screen-lines (point) (point-max)) correction)))) ;; only animate if the point was moved rather far away @@ -379,7 +394,7 @@ the center. Just the variable ccm-vpos is set." (- bottom-lines) (if (< ccm-vpos 0) current-line - (- (- (window-text-height) current-line))) + (- (- (ccm-visible-text-lines) current-line))) (* (/ diff (abs diff)) (- step-size))))) (cdr (reverse (number-sequence ccm-vpos -- 2.47.3