From: Manuel Giraud <manuel@ledu-giraud.fr>
To: Tassilo Horn <tsdh@gnu.org>
Cc: help-gnu-emacs@gnu.org
Subject: Re: overlays and movement
Date: Tue, 28 Jun 2022 17:56:38 +0200 [thread overview]
Message-ID: <8735fo93yh.fsf@elite.giraud> (raw)
In-Reply-To: <877d5183l8.fsf@gnu.org> (Tassilo Horn's message of "Tue, 28 Jun 2022 12:39:38 +0200")
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
next prev parent reply other threads:[~2022-06-28 15:56 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-28 9:17 overlays and movement Manuel Giraud
2022-06-28 10:39 ` Tassilo Horn
2022-06-28 12:12 ` Manuel Giraud
2022-06-28 15:56 ` Manuel Giraud [this message]
2022-06-28 16:13 ` Emanuel Berg
2022-06-29 7:12 ` Manuel Giraud
2022-06-29 7:34 ` tomas
2022-06-30 6:11 ` Emanuel Berg
2022-06-28 19:22 ` Tassilo Horn
2022-06-29 7:23 ` Manuel Giraud
2022-06-30 4:51 ` Tassilo Horn
2022-06-30 6:14 ` Emanuel Berg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8735fo93yh.fsf@elite.giraud \
--to=manuel@ledu-giraud.fr \
--cc=help-gnu-emacs@gnu.org \
--cc=tsdh@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.