From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Manuel Giraud Newsgroups: gmane.emacs.help Subject: Re: overlays and movement Date: Tue, 28 Jun 2022 17:56:38 +0200 Message-ID: <8735fo93yh.fsf@elite.giraud> References: <87tu855eqs.fsf@elite.giraud> <877d5183l8.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4155"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (berkeley-unix) Cc: help-gnu-emacs@gnu.org To: Tassilo Horn Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Tue Jun 28 18:01:36 2022 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o6Dei-0000wW-CM for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 28 Jun 2022 18:01:36 +0200 Original-Received: from localhost ([::1]:46090 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o6Deh-0004MS-8c for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 28 Jun 2022 12:01:35 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34018) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o6Da5-0000h0-N1 for help-gnu-emacs@gnu.org; Tue, 28 Jun 2022 11:56:49 -0400 Original-Received: from ledu-giraud.fr ([51.159.28.247]:40024) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o6DZx-0003Ys-V0; Tue, 28 Jun 2022 11:56:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; s=rsa; bh=gXamsaGqUIaZiEC0 vfEHJyyMosXU/a1obTM9KOgT49Y=; h=in-reply-to:date:references:subject: cc:to:from; d=ledu-giraud.fr; b=bRdb1qbiMlUoao+mKAcz9PG6pR5h8UX1JCAXsp U4mCK3Oo7HQoXqTHcj2JvOoCsl5ZH5avAZQALQBWHbTZXnpCEGscQ5pz4fB6dvrxaXGaGG WBIlav8PKpt8Lhfh09bb7HcQyPJ5sn0Qsiktw5/DTimjjT1LMGXguwJUyHnMWS4qYEvdfG cVnxkhA19ODsMl9H+CGArSQPZ4uuYDNI2sstIdh4ZJ68XtIMPVJTg+kAx9gU+V5FcEkfzc FofvXk44G9+fL56gXyIoeJN6H57AM02g2m5JqW0n30KJIS0CcgQyJ1wanLpMxq/e/+ldo2 h33LQcRwSaRwBULiB2BwuXyQ== Original-Received: from elite.giraud ( [10.1.1.1]) by ledu-giraud.fr (OpenSMTPD) with ESMTPSA id d95267ae (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Tue, 28 Jun 2022 17:56:38 +0200 (CEST) In-Reply-To: <877d5183l8.fsf@gnu.org> (Tassilo Horn's message of "Tue, 28 Jun 2022 12:39:38 +0200") Received-SPF: pass client-ip=51.159.28.247; envelope-from=manuel@ledu-giraud.fr; helo=ledu-giraud.fr X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:138168 Archived-At: Hi, FWIW, here is what I wanted to do. It is not super fast but quite usable. --8<---------------cut here---------------start------------->8--- ;; Fog (defvar up-fog nil) (defvar down-fog nil) (defvar fog-distance 10) (defun up-fog-end () (save-excursion (if (zerop (forward-line (- (+ fog-distance 1)))) (progn (end-of-line) (point)) (point-min)))) (defun down-fog-start () (save-excursion (forward-line (+ fog-distance 1)) (beginning-of-line) (point))) (defface fog '((t :foreground "grey90" :background "grey95")) "Fog face.") (defun maybe-move-fog () (while-no-input (redisplay) (let ((new-end (up-fog-end)) (new-start (down-fog-start))) (when (or (/= (overlay-end up-fog) new-end) (/= (overlay-start down-fog) new-start)) (move-overlay up-fog (point-min) new-end) (move-overlay down-fog new-start (point-max)))))) (defun fog-on () (maybe-move-fog) (overlay-put up-fog 'face 'fog) (overlay-put down-fog 'face 'fog)) (defun fog-off () (overlay-put up-fog 'face nil) (overlay-put down-fog 'face nil)) (define-minor-mode fog-mode "Minor fog mode" :lighter " fog" (if fog-mode (progn (setq up-fog (make-overlay 1 1) down-fog (make-overlay 1 1)) (fog-on) (add-hook 'post-command-hook 'maybe-move-fog 0 t)) (fog-off) (remove-hook 'post-command-hook 'maybe-move-fog t) (delete-overlay up-fog) (delete-overlay down-fog) (setq up-fog nil down-fog nil))) --8<---------------cut here---------------end--------------->8--- -- Manuel Giraud