Is there any way to have the region highlighted without transient-mark-mode on? I'm trying to implement kakoune style editing in emacs and having a persistent region actually makes sense under that editing model.

EDIT: Clarification According to kakoune's documentation, there is always an active selection, with an anchor and a cursor. The anchor and the cursor in kakoune would correspond to the mark and point in emacs. Disabling transient mark-mode in emacs would bring it more in line with the idea of a persistent selection with an always active mark. According to the emacs manual, however, disabling transient-mark-mode disables region highlighting, since having highlighting all the time would be annoying. It is precisely this 'annoying' behavior that I'm trying to enable. The question is basically "how do I highlight the region?" Apologies for the confusing nature of the initial question. I'm new to emacs and have yet to get up to speed with all the terms.

  • 1
    Please clarify what you mean by "without transient-mark-mode" and what you mean by "persistent region". Describe the relevant part of what is "kakoune" (not only the question should make sense even if that link is broken, but I looked at that link and that did not help me understand what you want). Also, I recommend you rephrase your question because the answer to your current question is "yes" but I suspect you want another answer. – Stefan Sep 30 '18 at 14:40
  1. Active region means active mark. And this notion has no meaning outside of transient-mark-mode. If transient-mark-mode is off then the region/mark is neither active nor inactive -- that distinction exists only when transient-mark-mode is on.

  2. If you change your question to just "region" instead of "active region" then sure, there are many ways to highlight the region (whether active or not). Do that, and I and others will no doubt provide info/references about that.

    And please specify clearly what you mean by a "persistent region". Highlighting, for example, can persist until some event, or it can persist for an entire Emacs session, or it can persist across sessions.

  3. Please describe the behavior you want. Do not just post a link to some page that has lots of stuff on it that is, or at least seems to be, unrelated. Specify the behavior you are interested in. Otherwise, the question risks being closed because it is unclear.

| improve this answer | |

FWIW, here's a piece of Elisp which makes it always highlight the region, without affecting anything in Emacs's behavior (other than the visual aspect of the text in the region, obviously):

(advice-add 'redisplay--update-region-highlight
            (lambda (orig-fun &rest args)
              (let ((transient-mark-mode t)
                    (mark-active (if (mark t) t)))
                (apply orig-fun args))))
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.