Skip to content

Minor mode for highlighting 'printf' format specifiers in Emacs

License

Notifications You must be signed in to change notification settings

8dcc/hl-printf.el

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hl-printf.el

Minor mode for highlighting ‘printf’ format specifiers in Emacs.

This package provides a minor mode for highlighting printf format specifiers, such as %s, %lld or %-5.3f. This package is meant for C-like modes, but it can be used on any major mode (that can detect strings with the syntax-ppss Emacs function).

Installing

This package is available in Melpa. You can install it with M-x package-install RET hl-printf RET, and then require it:

(require 'hl-printf)

Or with use-package:

(use-package hl-printf)

Alternatively, you can install it with package-vc-install:

(package-vc-install "https://github.com/8dcc/hl-printf.el")

Lastly, if you are using straight.el, you can specify the recipe with straight-use-package:

(straight-use-package
 '(hl-printf :type git :host github :repo "8dcc/hl-printf.el"))

Customizing

The following variables can be customized.

Variable: hl-printf-regexp

Regular expression used to highlight format specifiers inside strings.

For example, to highlight escape sequences in strings, you can add the following to your init file:

(setq hl-printf-regexp
      (rx (or (regexp hl-printf-regexp)
              (seq "\\"
                   (or "a" "b" "e" "f" "n" "r" "t" "v" "\\" "'" "\"" "?"
                       (repeat 1 3 digit)
                       (seq "x" (one-or-more hex-digit))
                       (seq "u" (repeat 4 hex-digit))
                       (seq "U" (repeat 8 hex-digit)))))))
    
User Option: hl-printf-face

Face used when highlighting format specifiers.

Screenshots

Here are some screenshots of the package, using my fork of Protesilaos’ modus-themes.

assets/ss-dark.png

assets/ss-light.png

About

Minor mode for highlighting 'printf' format specifiers in Emacs

Topics

Resources

License

Stars

Watchers

Forks