Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Well, let's start with <a href="https://stackoverflow.com/questions/756666/match-regular-expression-as-keyword-in-define-generic-mode/756927#756927">this answer</a>, which uses <a href="http://www.gnu.org/software/emacs/elisp/html_node/Generic-Modes.html" rel="nofollow noreferrer"><code>define-generic-mode</code></a>.</p> <p>Flesh it out with some comment characters like: <code>/* */</code>, some keywords: <code>hello</code> <code>hi</code> etc., re-use the face from the original answer, a file extension <code>.hello</code>, and a function call to do further customization.</p> <p>There's the additional line to get autoloading working, but you have to <a href="http://www.gnu.org/software/emacs/elisp/html_node/Autoload.html" rel="nofollow noreferrer">generate the loaddefs.el</a> file. That's more advanced than hello world.</p> <p>And, you end up with this:</p> <pre><code>(make-face 'my-date-face) (set-face-attribute 'my-date-face nil :underline t) (set-face-attribute 'my-date-face nil :family "times") (set-face-attribute 'my-date-face nil :slant 'normal) (set-face-attribute 'my-date-face nil :height '340) ;;;###autoload (define-generic-mode hello-world '(("/*" . "*/")) ; comment characters '("hello" "hi" "howdy" "greetings" "hola") ; keywords '(("\\([0-9]+/[0-9]+/[0-9]+\\)" (1 'my-date-face))) ; font lock '("\\.hello$") ; auto-mode-alist '(hello-world-special-setup) ; function-list "An example major mode. We have comments, keywords, a special face for dates, and recognize .hello files.") (defun hello-world-special-setup () "Some custom setup stuff done here by mode writer." (message "You've just enabled the most amazing mode ever.")) </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload