Skip to content

Improve readability of escape characters in ELisp regular expressions

License

Notifications You must be signed in to change notification settings

cpitclaudel/easy-escape

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

easy-escape

Easy-escape: before and after

easy-escape-minor-mode uses syntax highlighting and composition to make ELisp regular expressions more readable. More precisely, it hides double backslashes preceding regexp specials (()|), composes other double backslashes into single ones, and applies a special face to each. The underlying buffer text is not modified.

The default is to use a single \ character instead of two, and to hide backslashes preceding parentheses or |. The escape character and its color can be customized using easy-escape-face and easy-escape-character (which see), and backslashes before ()| can be shown by disabling easy-escape-hide-escapes-before-delimiters.

Setup

MELPA (preferred)

  1. Setup MELPA if you haven't yet

    In your .emacs, add these three lines:

    (require 'package)
    (add-to-list 'package-archives '("melpa" . "http:https://melpa.org/packages/") t)
    (package-initialize)
  2. Install the package: M-x package-install RET easy-escape RET

  3. Enable easy-escape-minor-mode in Lisp buffers:

    ;; Replace 'lisp-mode-hook with 'prog-mode-hook to enable everywhere
    (add-hook 'lisp-mode-hook 'easy-escape-minor-mode)
    (add-hook 'emacs-lisp-mode-hook 'easy-escape-minor-mode)

Alternative setup

  1. Download this file

  2. Add this to your .emacs:

    (load-file "PATH-TO-THE-FILE-YOU-JUST-DOWNLOADED")
    (add-hook 'lisp-mode-hook 'easy-escape-minor-mode)

Fine-tuning

  • If you find the distinction between the fontified double-slash and the single slash too subtle, try the following:

    • Adjust the foreground of easy-escape-face:

      (set-face-attribute 'easy-escape-face nil :foreground "red")
    • Set easy-escape-character to a different character:

      (setq easy-escape-character ?╲)

About

Improve readability of escape characters in ELisp regular expressions

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published