wolray / symbol-overlay

Highlight symbols with keymap-enabled overlays
334 stars 42 forks source link

Request: Add regexp support #40

Open snowman opened 5 years ago

snowman commented 5 years ago

Wanted

Like highlight-regexp, but with overlay functionality.

Reproduction steps

sample code extracted for illustration from https://raw.githubusercontent.com/bbatsov/prelude/master/utils/installer.sh

install_prelude() {
  printf " Cloning Emacs Prelude's GitHub repository...\n$RESET"

  if [ x$PRELUDE_VERBOSE != x ]; then
    /usr/bin/env git clone $PRELUDE_URL "$PRELUDE_INSTALL_DIR"
  else
    /usr/bin/env git clone $PRELUDE_URL "$PRELUDE_INSTALL_DIR" >/dev/null
  fi

  if ! [ $? -eq 0 ]; then
    printf "$RED A fatal error occurred during Prelude's installation. Aborting..."
    exit 1
  fi
}

make_prelude_dirs() {
  printf " Creating the required directories.\n$RESET"
  mkdir -p "$PRELUDE_INSTALL_DIR/savefile"
}

When overlay string PRELUDE_INSTALL_DIR inside "$PRELUDE_INSTALL_DIR" with symbol-overlay-put, it would not highlight $PRELUDE_INSTALL_DIR inside "$PRELUDE_INSTALL_DIR/savefile"

image

DWgit commented 3 years ago

Wondering if this feature was considered? Doesn't seem to be in current master branch.

In addition to @snowman's original example, matching synonyms is another use-case. It would be great to have a single symbol overlay on a regex, for example AB-?16\|XYZ, which matches three synonyms.

One possible UI would be:

  1. yank symbol at point into the minibuffer
  2. let me edit the minibuffer to include a regex
  3. do symbol overlay on my regex