Hide first columns in emacs

I am writing a mode to more easily deal with some of the log files that I have. The first few columns are all the same metadata, and I would like to omit this from the display. What is the best way to hide this information - going through each line and marking this section of each line with an "invisible text property"?

These log files will be displayed, not edited.

+4
source share
3 answers

Add this to your .emacs :

 (add-hook 'text-mode-hook (lambda () (font-lock-add-keywords nil '(("\\[.*\\]" (0 '(face default display "meta") append))) t) (push 'display font-lock-extra-managed-props))) 

This will display your metadata, which is matched using the regular expression "\\[.*\\]" as meta

 [01/01/2012 14:00 - Message] Hello World! 

Will be temporarily

 meta Hello World! 

Just replace the regex with one that matches your metadata.

Hope this helps!

+2
source

I would try using the font-lock keyword, which adds the `invisible 'property. Something like 100% guaranteed unverified code below:

 (font-lock-add-keywords nil '(("^.............." (0 '(face nil invisible t))))) 
+2
source

I would suggest writing an elisp function that reads every line of the log and discards information that you do not want before printing it.

+1
source

All Articles