help-gnu-emacs
[Top][All Lists]
Advanced

[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
changed...

;;; -*- lexical-binding: t -*-
;;;
;;; this file:
;;;   http://user.it.uu.se/~embe8573/emacs-init/incal-ecat.el
;;;   https://dataswamp.org/~incal/emacs-init/incal-ecat.el

(defvar sentence-overlay nil)

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

(defun highlight-sentence ()
  (interactive)
  (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 ()
  (interactive)
  (forward-sentence)
  (highlight-sentence) )

(defun highlight-sentence-prev ()
  (interactive)
  (backward-sentence)
  (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
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




reply via email to

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