Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a long string with boolean logic like

("Mercedes Benz" or "Audi" not "Volkswagen" not "truck") but much longer and more complex (with several parenthesis etc.)

I wonder how I can make this string more readable for me and others, I think indenting and coloring could help.

Is there a way to format this string automatically with emacs to make reading it easier?

Example string (which does not necessarily makes sense logically!)

("Mercedes Benz" or (Benz not Carl not Carl* not female ) or "Daimler Chrysler" or "Daimler corporation" or daimler or chrysler or amg or car or automobile or automotive or "automo* manufactur*" )

Operators:

  • and
  • or
  • not
  • nor
  • xor

Text strings

  • like that: "Daimler Chrysler"
  • or just words like daimler Benz etc.

Wildcards:

  • *
share|improve this question
    
I'm not sure what you're asking. Syntax highlighting is available but depends on the language. What language are you using? Elisp? –  SlowLearner Jul 11 '13 at 9:49
    
not really. It is a search term like used for a search engine (similar to google) to filter interesting content. It looks very similar to elisp, so maybe a syntax highlighting and formatting (with line breaks and indentation) for elisp could help. Unfortunately, I can not paste the real example here. –  Martin Jul 11 '13 at 11:19

1 Answer 1

Defining font-locking can be tricky. You would need to post an example of the syntax you want highlighted, even if a pseudo-example. Keep in mind too that if you want to highlight keywords such as or and and then, because these can often be part of larger terms, you will need a regular expression that can distinguish these when they are being used as keywords. E.g., is whitespace enough to distinguish them in your context?

In sum, give an example --- we cannot guess the syntax you are trying to work with.

share|improve this answer
    
thanks for your help! I've added a longer example string which should cover all general syntax –  Martin Jan 29 at 9:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.