1

I am trying to derive mode based on Sample Mode. Reduced contents here:

;;; pandoc-template.el --- Pandoc-Template major mode

;; Copyright (C) 2017

;; Author: VaclavHaisman
;; Keywords: extensions
(defvar pandoc-template-mode-syntax-table
  (let ((st (make-syntax-table)))
    ;(modify-syntax-entry ?# "<" st)
    ;(modify-syntax-entry ?\n ">" st)
    st)
  "Syntax table for `pandoc-template-mode'.")

(defvar pandoc-template-font-lock-keywords
   '(("\\(\\$\\)\\(if\\)(\\([^)]+\\))\\(\\$\\)"
      . font-lock-preprocessor-face)
      ;(1 font-lock-preprocessor-face)
      ;(2 font-lock-keyword-face)
      ;(3 font-lock-variable-face)
      ;(4 font-lock-preprocessor-face))
     ("\\$endif\\$" . font-lock-keyword-face)
     )
  "Keyword highlighting specification for `pandoc-template-mode'.")

 ;;;###autoload
(define-derived-mode pandoc-template-mode fundamental-mode "Pandoc-Template"
  "A major mode for editing Pandoc-Template files."
  :syntax-table nil ;pandoc-template-mode-syntax-table
  ;(setq-local comment-start "# ")
  ;(setq-local comment-start-skip "#+\\s-*")
  (setq-local font-lock-defaults
              '(pandoc-template-font-lock-keywords))

  )


(provide 'pandoc-template-mode)
 ;;; pandoc-template.el ends here

It does nothing. I cannot tell why it does not highlight anything. Sample text of the Pandoc template:

\PassOptionsToPackage{unicode=true}{hyperref} % options for packages loaded elsewhere
\PassOptionsToPackage{hyphens}{url}
$if(colorlinks)$
\PassOptionsToPackage{usenames,dvipsnames}{color}
$endif$
%
\documentclass[$if(fontsize)$$fontsize$,$endif$$if(lang)$$babel-lang$,$endif$$if(papersize)$$papersize$paper,$endif$$for(classoption)$$classoption$$sep$,$endfor$]{$documentclass$}
$if(beamerarticle)$
\usepackage{beamerarticle} % needs to be loaded first
$endif$
$if(fontfamily)$
\usepackage[$for(fontfamilyoptions)$$fontfamilyoptions$$sep$,$endfor$]{$fontfamily$}
$else$
\usepackage{lmodern}
$endif$
Drew
  • 75,699
  • 9
  • 109
  • 225
wilx
  • 173
  • 7
  • 1
    I just tried it here, and it works straight out of the box. My guess is that you haven't updated the variables properly. When you do something like `eval-buffer`, variables are not updated. To update them, you have to press `M-C-x` on each variable. (Also, I'd like to take the opportunity to recommend my font-lock debugger https://github.com/Lindydancer/font-lock-studio -- it's useful when tracking down font-lock related problems lite this.) – Lindydancer Sep 01 '17 at 06:59
  • I was using the "byte compile and load" from menu. – wilx Sep 01 '17 at 07:22
  • But it works with M-C-x! Great! – wilx Sep 01 '17 at 07:25
  • Good! (The reason that loading a file or evaluating a buffer does not set variables is that users should be able to configure packages before they are loaded. However, it is a constant problem for package developers -- I don't know how many times I've missed it myself...) – Lindydancer Sep 01 '17 at 07:40

0 Answers0