Question

some times i have comments to my code at different structure levels, for example the following python code:

# level one comment
for i in list:
    # level two comment
    if mod(i, 2):
        # level three comment
        print 'odd number'
    else:
        print 'even number

i want to have different font size (or slightly different color) for different level of comments, is there such a package to do something like this? also, for example for elisp code, i usually add comments to different levels with different number of heading chars ;, for example:

;;; level 1 comments
(sexp level 1
  ;; level 2 comments
  (sexp level 2
     ; level 3 and >3 coments 
       (sexp level 3)))

if i can display the comments of different levels using different faces, that can greatly help to review and understand the structures of my code. thanks!

Était-ce utile?

La solution

The face used to display comments and strings is decided by the function set in font-lock-syntactic-face-function. So you can just set that variable to a function of your own which can take the number of semi-colons, or the indentation as a cue to choose different faces.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top