[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#40338: 27.0.60; c-fill-paragraph and after-change-functions
From: |
Noam Postavsky |
Subject: |
bug#40338: 27.0.60; c-fill-paragraph and after-change-functions |
Date: |
Mon, 30 Mar 2020 21:56:56 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.90 (gnu/linux) |
Yuan Fu <casouri@gmail.com> writes:
> (defun mytrack-hook (beg end len)
> (if (> len 0)
> ;; delete
> (with-current-buffer trackbuf
> (delete-region beg (+ beg len)))
> ;; insert
> (let ((content (buffer-substring beg end)))
> (with-current-buffer trackbuf
> (goto-char beg)
> (insert content)))))
I'm not very familiar with either eglot or cc-mode, but I can say the
problem in your example lies with mytrack-hook: there can be kinds of
changes other than just pure delete or insert (replace, for example).
It can be fixed like this:
(defun mytrack-hook (beg end len)
(when (> len 0)
;; Delete old text.
(with-current-buffer "trackbuf"
(delete-region beg (+ beg len))))
;; Insert new text.
(let ((content (buffer-substring beg end)))
(with-current-buffer "trackbuf"
(goto-char beg)
(insert content))))