From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Keith David Bershatsky Newsgroups: gmane.emacs.bugs Subject: bug#22404: 25.1.50; Forcing `window-scroll-functions` to run. Date: Tue, 02 Feb 2016 12:00:23 -0800 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 (generated by - "") Content-Type: text/plain; charset=US-ASCII X-Trace: ger.gmane.org 1454443286 8958 80.91.229.3 (2 Feb 2016 20:01:26 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 2 Feb 2016 20:01:26 +0000 (UTC) Cc: 22404@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Feb 02 21:01:11 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1aQh8P-0005K6-B2 for geb-bug-gnu-emacs@m.gmane.org; Tue, 02 Feb 2016 21:01:09 +0100 Original-Received: from localhost ([::1]:59244 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aQh8O-0000U0-TP for geb-bug-gnu-emacs@m.gmane.org; Tue, 02 Feb 2016 15:01:08 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37274) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aQh8L-0000Tr-5V for bug-gnu-emacs@gnu.org; Tue, 02 Feb 2016 15:01:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aQh8H-0008On-V9 for bug-gnu-emacs@gnu.org; Tue, 02 Feb 2016 15:01:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:48518) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aQh8H-0008Oj-R4 for bug-gnu-emacs@gnu.org; Tue, 02 Feb 2016 15:01:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84) (envelope-from ) id 1aQh8H-0001lD-Lf for bug-gnu-emacs@gnu.org; Tue, 02 Feb 2016 15:01:01 -0500 X-Loop: help-debbugs@gnu.org In-Reply-To: Resent-From: Keith David Bershatsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 02 Feb 2016 20:01:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22404 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 22404-submit@debbugs.gnu.org id=B22404.14544432356724 (code B ref 22404); Tue, 02 Feb 2016 20:01:01 +0000 Original-Received: (at 22404) by debbugs.gnu.org; 2 Feb 2016 20:00:35 +0000 Original-Received: from localhost ([127.0.0.1]:57107 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aQh7r-0001kN-Hr for submit@debbugs.gnu.org; Tue, 02 Feb 2016 15:00:35 -0500 Original-Received: from cobb.liquidweb.com ([50.28.13.150]:54790) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aQh7o-0001k9-UE for 22404@debbugs.gnu.org; Tue, 02 Feb 2016 15:00:33 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lawlist.com; s=default; h=Content-Type:MIME-Version:Subject:Cc:To:From:Message-ID:Date; bh=v57p0IxMEzrs74tuaIovEq7xv688NfBgFHOejgmWr/M=; b=p3TuwkFuadEWDP6F9TcCQ1kkdZHDcat7aftYr6NU5W59YkdANcpnrtfIeVLn4AHWpRCDmlsqwKdun8vE3sgOWtEOmtxIH1ME9e1FVUKv/fJSZpgcS3d1c2/enlV1tApD; Original-Received: from cpe-45-48-239-195.socal.res.rr.com ([45.48.239.195]:50369 helo=server.private.localhost) by cobb.liquidweb.com with esmtp (Exim 4.82) (envelope-from ) id 1aQh7e-00063x-AK; Tue, 02 Feb 2016 15:00:22 -0500 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - cobb.liquidweb.com X-AntiAbuse: Original Domain - debbugs.gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - lawlist.com X-Get-Message-Sender-Via: cobb.liquidweb.com: acl_c_relayhosts_text_entry: lawlist|lawlist.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:112290 Archived-At: I will go through your most recent e-mail in a little while, but I wanted to get this test minor-mode over to you so that you can visually see exactly what I see when performing these tests. It is a scaled-down example of my current usage -- this example just draws line numbers in the left margin of the visible window and uses `forward-line` instead of `vertical-motion`. This minor-mode will work with your new `post-redisplay-hook` and it also works with the latest example `window_start_end.diff` that I e-mailed last night. I have included an exception for `mhweel-scroll` so that we can use the mouse wheel to scroll up/down to see how the overlays have been placed. If we use a large buffer for testing and go to `beginning-of-buffer` or `end-of-buffer` or scroll-up or scroll-down, the l ine numbers should be drawn by the time that redisplay finishes. I have already taken the liberty of adding `ln-draw-numbers` to the `post-redisplay-hook` in anticipation of its future creation. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defvar ln-before-string-list nil "Doc-string -- `ln-before-string-list`.") (make-variable-buffer-local 'ln-before-string-list) (defvar ln-str-list nil "Doc-string -- `ln-str-list`.") (make-variable-buffer-local 'ln-str-list) (defvar ln-this-command nil "This local variable is set within the `post-command-hook`; and, is also used by the `window-start-end-hook` hook.") (make-variable-buffer-local 'ln-this-command) (defvar ln-overlays nil "Overlays used in this buffer.") (defvar ln-available nil "Overlays available for reuse.") (mapc #'make-variable-buffer-local '(ln-overlays ln-available)) (defgroup ln nil "Show line numbers in the left margin." :group 'convenience) (defface ln-active-face '((t (:background "black" :foreground "#eab700" :weight normal :italic nil :underline nil :box nil :overline nil))) "Face for `ln-active-face'." :group 'ln) (defface ln-inactive-face '((t (:background "black" :foreground "SteelBlue" :weight normal :italic nil :underline nil :box nil :overline nil))) "Face for `ln-inactive-face'." :group 'ln) (defvar ln-mode nil) (defun ln-record-this-command () (setq ln-this-command this-command)) (defun ln-draw-numbers (win &optional start end pbol-start peol-end force) "Update line numbers for the portion visible in window WIN." (message "win: %s | start: %s | end: %s | pbol-start: %s | peol-end: %s" win start end pbol-start peol-end) (when (and ln-mode (or ln-this-command force) (not (eq ln-this-command 'mwheel-scroll)) (window-live-p win) (not (minibufferp)) (pos-visible-in-window-p nil nil nil) ) (setq ln-available ln-overlays) (setq ln-overlays nil) (setq ln-before-string-list nil) (setq ln-str-list nil) (let* ( line my-initial-line (inhibit-point-motion-hooks t) (opoint (point)) (ln-current-line-number (string-to-number (format-mode-line "%l"))) (window-start (if start start (window-start win))) (window-end (if end end (window-end win t))) (max-digits-string (number-to-string (length (progn (goto-char (point-max)) (format-mode-line "%l"))))) (width 0) ) (goto-char window-start) (setq my-initial-line (string-to-number (format-mode-line "%l"))) (setq line my-initial-line) (catch 'done (while t (when (= (point) (point-at-bol)) (let* ( (str (propertize (format (concat "%" max-digits-string "d") line) 'face (if (eq line ln-current-line-number) 'ln-active-face 'ln-inactive-face))) (ln-before-string (propertize " " 'display `((margin left-margin) ,str))) (visited (catch 'visited (dolist (o (overlays-in (point) (point))) (when (equal-including-properties (overlay-get o 'ln-str) str) (unless (memq o ln-overlays) (push o ln-overlays)) (setq ln-available (delq o ln-available)) (throw 'visited t))))) ) (push ln-before-string ln-before-string-list) (push str ln-str-list) (unless visited (let ((ov (if (null ln-available) (make-overlay (point) (point)) (move-overlay (pop ln-available) (point) (point))))) (push ov ln-overlays) (overlay-put ov 'before-string ln-before-string) (overlay-put ov 'ln-str str))) (setq width (max width (length str))))) (if (and (not (eobp)) (< (point) window-end)) (progn (forward-line) (setq line (1+ line))) (throw 'done nil)))) (set-window-margins win width (cdr (window-margins win))) (mapc #'delete-overlay ln-available) (setq ln-available nil) (setq ln-this-command nil) (goto-char opoint)))) (defsubst lawlist-remove-overlays (beg end name val) "Remove the overlays that are `equal-including-properties`. Includes a unique situation when an overlay with an `'after-string` property is at the very end of a narrowed-buffer." (let* ( (point-max (point-max)) (point-min (point-min)) (narrowed-p (buffer-narrowed-p)) (beg (if beg beg point-min)) (end (cond ((and (not narrowed-p) end) end) ((and (not narrowed-p) (null end)) point-max) ((and narrowed-p end (< end point-max)) end) ((and narrowed-p end (= end point-max)) (1+ end)) ((and narrowed-p (null end)) (1+ point-max)) )) (overlays (progn (overlay-recenter end) (overlays-in beg end))) ) (when (and beg end name val) (dolist (o overlays) (cond ((and (eq name 'face) (eq (overlay-get o name) val)) (if (< (overlay-start o) beg) (if (> (overlay-end o) end) (progn (move-overlay (copy-overlay o) (overlay-start o) beg) (move-overlay o end (overlay-end o))) (move-overlay o (overlay-start o) beg)) (if (> (overlay-end o) end) (move-overlay o end (overlay-end o)) (delete-overlay o)))) ((and (not (eq name 'face)) (equal-including-properties (overlay-get o name) val)) (delete-overlay o))))))) (define-minor-mode ln-mode "A minor-mode for line-numbers in the left-hand margin." :init-value nil :lighter " #" :keymap nil :global nil :group 'ln (cond (ln-mode (setq window-start-end-var t) (add-hook 'pre-command-hook 'ln-record-this-command nil t) (add-hook 'window-start-end-hook 'ln-draw-numbers nil t) (add-hook 'post-redisplay-hook 'ln-draw-numbers nil t) (ln-draw-numbers (selected-window) nil nil nil nil 'force) (when (called-interactively-p 'any) (message "Turned ON `ln-mode`."))) (t (remove-hook 'pre-command-hook 'ln-record-this-command t) (remove-hook 'window-start-end-hook 'ln-draw-numbers t) (remove-hook 'post-redisplay-hook 'ln-draw-numbers t) (kill-local-variable 'ln-overlays) (kill-local-variable 'ln-available) (dolist (val ln-str-list) (lawlist-remove-overlays nil nil 'ln-str val)) (kill-local-variable 'ln-str-list) (dolist (val ln-before-string-list) (lawlist-remove-overlays nil nil 'before-string val)) (kill-local-variable 'ln-before-string-list) (kill-local-variable 'window-start-end-var) (dolist (w (get-buffer-window-list (current-buffer) nil t)) (set-window-margins w 0 (cdr (window-margins w)))) (when (called-interactively-p 'any) (message "Turned OFF `ln-mode`."))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;