Code Monkey home page Code Monkey logo

Comments (8)

clemera avatar clemera commented on July 18, 2024 1

The joy of Emacs :) This doesn't use regexp-opt because it was a bit easier to avoid it:

(swiper (mapconcat #'identity (mapcar #'car symbol-overlay-keywords-alist) "\\|"))

from symbol-overlay.

purcell avatar purcell commented on July 18, 2024

I think that's a bit tangential to symbol-overlay because it's very easy to implement in other ways. For example, here's what I do to address essentially the same use case: https://github.com/purcell/emacs.d/blob/master/lisp/init-ivy.el#L70-L76

from symbol-overlay.

clemera avatar clemera commented on July 18, 2024

Ah, yes! But this only works shows the symbol at point not all marked symbols for example. But I guess that's not to useful after all. Thanks!

from symbol-overlay.

purcell avatar purcell commented on July 18, 2024

But this only works shows the symbol at point not all marked symbols for example.

You could easily make a version of that function that gathered all the marked symbols and made a regexp which matched any of them using the regexp-opt function: then you could pass that regexp to swiper. :-)

from symbol-overlay.

purcell avatar purcell commented on July 18, 2024

This doesn't use regexp-opt because it was a bit easier to avoid it:

Really?

(swiper (regexp-opt (mapcar #'car symbol-overlay-keywords-alist)))

from symbol-overlay.

clemera avatar clemera commented on July 18, 2024

(swiper (regexp-opt (mapcar #'car symbol-overlay-keywords-alist)))

This does not work for me. regex-opt expects no regex so this adds to many backslashes around the symbol regex which have to be removed so swiper can "understand".

from symbol-overlay.

purcell avatar purcell commented on July 18, 2024

Ah yes! I'd forgotten that the alist keys could be regexes. Just ignore me... :-)

from symbol-overlay.

clemera avatar clemera commented on July 18, 2024

No, I'm happy you brought it up! This made me wonder if there is an easy way to remove regex signs from a string. For symbol regexes in Elisp the following works good enough, because Elisp does not use any of the regex signs for its symbols:

(swiper (regexp-opt (mapcar (lambda (el)
                                  (replace-regexp-in-string "[\\<>_]" "" (car el)))
                                      symbol-overlay-keywords-alist)))

from symbol-overlay.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.