0

In my current Emacs major-mode for Tecplot macro development, I have a few functions defined:

(defconst tecplot-macro-mode-syntax-table
  (let ((table (make-syntax-table)))
    ;; ' is a string delimiter
    (modify-syntax-entry ?' "\"" table)
    ;; " is a string delimiter too
    (modify-syntax-entry ?\" "\"" table)
    ;; |...| delimits variable names
    (modify-syntax-entry ?| "_" table)
    ;; $!... delimits macro calls
    (modify-syntax-entry ?$ "_" table)
    (modify-syntax-entry ?! "_" table)

    ;; / is punctuation, but # is a comment starter
    (modify-syntax-entry ?# "<" table)
    (modify-syntax-entry ?\n ">" table)
    table))

(defvar tecplot-macro-mode-keywords
  '(("[^#|{! ][[:alpha:]]* =" . font-lock-keyword-face)
    ("$![[:alpha:]]+" . font-lock-function-name-face)
    ("|\\(?:[[:ascii:]]\\|\\s_\\)+|" . font-lock-variable-name-face))
  ;;  )
  "List of keywords for `tecplot-macro-mode'.")

(define-derived-mode tecplot-macro-mode prog-mode "Tecplot"
  "Mode for editing Tecplot macros."
  :syntax-table tecplot-macro-mode-syntax-table
  (setq font-lock-defaults '(tecplot-macro-mode-keywords))
  (font-lock-mode)
  )

For some reason, Emacs has begun hanging when I put in the font-lock-keyword-face regexp. Why would this cause Emacs to hang? Is there a better way to get the text that the regexp grabs properly type colored?

  • If your code, as-is, works fine without the font-lock-keyword-face then your reflex is probably too broad – nega Mar 17 at 14:58
  • @nega: I think you mean regex. – NickD Mar 17 at 20:08
  • Set debug-on-quit to t, e.g with M-x toggle-debug-on-quit and run something that causes this delay; then press C-g which should give you a backtrace. Edit your question and add the backtrace. – NickD Mar 17 at 20:10
  • Unless something in font-lock is constraining it, "|\\(?:[[:ascii:]]\\|\\s_\\)+|" would match from the earliest | in the buffer all the way to the final | in the buffer, unless there were non-ascii (0-127) characters inbetween. (Or rather not-ascii and also not-punctuation syntax... all ascii punctuation would already have been covered, but I guess other unicode punctuation is a consideration.) – phils Mar 17 at 21:15
  • @nickd Indeed. Cursed iPhone autocorrect – nega Mar 18 at 5:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.