Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/8dcc/hl-printf.el

Minor mode for highlighting 'printf' format specifiers in Emacs
https://github.com/8dcc/hl-printf.el

emacs emacs-lisp emacs-package minor-mode printf syntax-highlighting

Last synced: 1 day ago
JSON representation

Minor mode for highlighting 'printf' format specifiers in Emacs

Awesome Lists containing this project

README

        

#+TITLE: hl-printf.el
#+AUTHOR: 8dcc
#+OPTIONS: toc:2
#+STARTUP: nofold

*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 [[https://melpa.org/][Melpa]]. You can install it with
=M-x package-install RET hl-printf RET=, and then =require= it:

#+begin_src emacs-lisp
(require 'hl-printf)
#+end_src

Or with =use-package=:

#+begin_src emacs-lisp
(use-package hl-printf)
#+end_src

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

#+begin_src emacs-lisp
(package-vc-install "https://github.com/8dcc/hl-printf.el")
#+end_src

Lastly, if you are using [[https://github.com/radian-software/straight.el][straight.el]], you can specify the recipe with
=straight-use-package=:

#+begin_src emacs-lisp
(straight-use-package
'(hl-printf :type git :host github :repo "8dcc/hl-printf.el"))
#+end_src

* 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:

#+begin_src emacs-lisp
(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)))))))
#+end_src

- User Option: hl-printf-face ::

Face used when highlighting format specifiers.

* Screenshots

Here are some screenshots of the package, using my fork of Protesilaos'
[[https://github.com/protesilaos/modus-themes][modus-themes]].

[[file:assets/ss-dark.png]]

[[file:assets/ss-light.png]]