1

I edit some files that are mostly C code but include a few special extension tokens. The tokens that give c-mode a problem are @' and @".

I essentially want c-mode to ignore these two bigrams. The current behavior is that the quote (single or double) is interpreted as the beginning of a quoted string.

I reckon this is childs play for anyone well versed in elisp syntax tables but I am not hence my appeal for your help.

4
  • I don't really care how @' and @" are colorized by font-lock, as long as they do not make c-mode think the quote is the beginning of a string Commented Jul 28, 2016 at 22:05
  • Also, perhaps this is more of a font-lock issue than a c-mode issue. I'm not sure. Commented Jul 28, 2016 at 22:09
  • 1
    Is @ used anywhere else? I wonder if @ set to be “escape” in the syntax table would work: (modify-syntax-entry ?@ "/")
    – amitp
    Commented Jul 28, 2016 at 23:15
  • no, @ is not used anywhere else. I'll investigate this option Commented Aug 2, 2016 at 16:31

1 Answer 1

1

You have to put a syntax-table property on the ' and " characters, e.g.:

(defun c-propertize-@ ()
  (interactive)
  (save-excursion
    (goto-char (point-min))
    (while (re-search-forward "@\\(\"\\|'\\)" nil t)
      (put-text-property (match-beginning 1)
                         (match-end 1)
                         'syntax-table
                         '(1))))) ;;= punctuation

Take a look at syntax-propertize-function, if you also want to edit these tokens.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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