Create area-indent-function to keep area marked

I'm having problems with haml-mode region-indent-function , which I am trying to reuse in another major mode. It is assumed that we can cyclically select an area, holding the area marked after the haml-indent area is enveloped, but it does not work properly. After some hacking, I found that the error at the end of the function causes Emacs to mark the area, as in this example:

 (defun haml-indent-region (start end) (save-excursion ...) (error "")) ;; Terrible hack 

But I really don't like it. Is there a clean way to get this behavior without such a terrible hack?

+4
source share
1 answer

After the command completes, the reset area is, therefore, activating the label does not have any effect. Throwing an error (non-local exit) seems to prevent this step, but it could be an error.

Trick: deactivate-mark

If the editing command sets this value to t, deactivate the character after that. The command loop sets this value to nil before each command, and checks the value when the command returns. A buffer modification stores t in this variable.

So just do it at the end of your command:

  (setq deactivate-mark nil)
+3
source

All Articles