[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: Sun, 07 Jun 2020 23:55:16 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)

Eric Abrahamsen wrote:

> You don't need to delete the overlay and make it
> again each time, just use `move-overlay'.

Alrighty, how about this? Only highlight-sentence has

;;; -*- 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 (backward-sentence) (point))) )
    (if (overlayp sentence-overlay)
        (move-overlay sentence-overlay beg end)
      (let ((overlay (make-overlay beg end)))
        (overlay-put overlay 'face 'font-lock-function-name-face)
        (setq sentence-overlay overlay) ))))

(defun highlight-sentence-next ()
  (highlight-sentence) )

(defun highlight-sentence-prev ()
  (highlight-sentence) )

> How do I know? Because this thread finally
> motivated me to finish the translation environment
> package I've been thinking of for a while, and
> I just wrote pretty much the same code a couple of
> days ago :)

Well... OK :)

underground experts united

reply via email to

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