2

I am trying to convert markdown to html and then use impatient-mode to display it live on browser on the fly.

Impatient mode uses after-change-hook to detect changes in html. I am using after-change-hook to detect changes in markdown buffer.

Buffer changes made while executing the after-change-functions don't call any before-change or after-change functions. That's because inhibit-modification-hooks is temporarily set non-nil.

As documentation says it won't work.

I can use timer to update every second but I am looking for a better solution.

Drew
  • 75,699
  • 9
  • 109
  • 225
Chillar Anand
  • 4,042
  • 1
  • 23
  • 52
  • 1
    Nothing preventing you from `let`-binding this variable to nil before modifying the html buffer. Just make sure you're not running into an endless loop, which shouldn't happen if the modifications happen in 2 different buffers and the hooks are added locally. – politza Jul 16 '15 at 20:12
  • @politza I thought it will be anti-pattern. Please post it as answer. – Chillar Anand Jul 17 '15 at 16:28
  • 2
    You could also run a timer in the `after-change-function running` after 0 secs, which is like a throw to toplevel. Those are just ideas. Try it, and then post your own answer. – politza Jul 17 '15 at 18:28

1 Answers1

1

As politza mentioned let binding of inhibit-modification-hooks to nil worked well.

(let ((inhibit-modification-hooks nil))
   (my-custom-function))
Chillar Anand
  • 4,042
  • 1
  • 23
  • 52