[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Emacs as a translator's tool

From: Emanuel Berg
Subject: Re: Emacs as a translator's tool
Date: Wed, 10 Jun 2020 23:29:54 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)

Marcin Borkowski wrote:

> Check out the function `overlay-buffer'.

You mean like this:

;;; -*- lexical-binding: t -*-
;;; this file:

(defvar sentence-overlay nil)

(defun remove-highlight ()
  (when (overlayp sentence-overlay)
    (delete-overlay sentence-overlay) ))

(defun highlight-sentence ()
  (let ((beg (progn (forward-sentence)    (point)))
        (end (progn (forward-sentence -1) (point))) )
    (if (overlayp sentence-overlay)
        (move-overlay sentence-overlay beg end)
      (let ((overlay (make-overlay beg end)))
        (overlay-put overlay 'face 'font-lock-comment-face)
        (setq sentence-overlay overlay) ))))
(defalias 'hs-init #'highlight-sentence)

(defun highlight-sentence-move (next)
  (if (overlayp sentence-overlay)
      (with-current-buffer (overlay-buffer sentence-overlay)
        (forward-sentence (if next 1 -1))
    (highlight-sentence) ))

(defun highlight-sentence-next ()
  (highlight-sentence-move t) )

(defun highlight-sentence-prev ()
  (highlight-sentence-move nil) )

underground experts united

reply via email to

[Prev in Thread] Current Thread [Next in Thread]