Skip to content
Snippets Groups Projects
Commit 94dec687 authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

Ajoute un simple mode pour pugs

parent d6a9570f
No related branches found
No related tags found
No related merge requests found
......@@ -24,3 +24,7 @@ auto-save-list
/custom.el
/Installation.tex
/.last-package-update-day
.lsp-session-v1
forge-database.sqlite
games/
projectile.cache
......@@ -1216,6 +1216,13 @@ statistiques, utiliser la commande ~M-x keyfreq-show~
:ensure t)
#+END_SRC
** Mode pugs
#+BEGIN_SRC emacs-lisp
(load-library "~/.emacs.d/extra/pugs.el")
(add-to-list 'auto-mode-alist '("\\.pgs?\\'" . pugs-mode))
(require 'pugs-mode)
#+END_SRC
* Annexes
** Génération de toute la documentation
......
;;; pugs -- simple major mode for pgs files
;;; Commentary:
;;; simple major mode for pugs
;;; Code:
(define-derived-mode pugs-output-mode compilation-mode "pugs-output"
"Define a special mode for pugs process output."
)
(defun pugs-run-file ()
"Execute the current pugs script.
Ask to save the buffer if needed"
(interactive)
(when (buffer-modified-p)
(save-buffer))
(let ((output-buffer "*pugs-output*")
(pugs-binary "~/src/pugs/build/pugs")
(pugs-file (buffer-file-name (current-buffer)))
(pugs-buffer (current-buffer)))
(when (get-buffer output-buffer)
(kill-buffer output-buffer))
(get-buffer-create output-buffer)
(follow-mode)
(display-buffer output-buffer)
(set-buffer output-buffer)
(pugs-output-mode)
(setq-local inhibit-read-only t)
(insert (format "started: %s\n" (current-time-string)))
(insert (format "binary : %s\n" pugs-binary))
(insert (format "script : %s\n\n" pugs-file))
;;; run the process
(process-file pugs-binary nil output-buffer nil pugs-file "--no-color")
; (start-process pugs-binary nil output-buffer t pugs-file "--no-color")
;;;
(insert (format "\nfinished: %s\n" (current-time-string)))
(insert (format "binary : %s\n" pugs-binary))
(insert (format "script : %s\n" pugs-file))
))
(define-derived-mode pugs-mode prog-mode "pugs"
"pugs mode is a major mode for editing pugs files"
;; define pugs keywords
(defvar pugs-keywords
'("import" "let" "Z" "N" "B" "R" "string" "and" "or" "xor" "not" "true" "false" "let" "do" "while" "for" "if" "else" "break" "continue" "cout" "cerr" "clog" "+"))
(defvar pugs-special-symbols
'(":" "," ";" "{" "}" "->" "<=" ">=" "=" "+" "-" "*" "/" "<" ">" "^"))
(defvar pugs-font-lock-defaults
`((
;; strings
("\"\\.\\*\\?" . font-lock-string-face)
;; keywords
( ,(regexp-opt pugs-keywords 'words) . font-lock-keyword-face)
;; special symbols
( ,(regexp-opt pugs-special-symbols) . font-lock-constant-face)
)))
(setq font-lock-defaults pugs-font-lock-defaults)
;; for comments
(setq comment-start "//")
(setq comment-end "")
(modify-syntax-entry ?\\ "\\" pugs-mode-syntax-table)
(modify-syntax-entry ?/ ". 124b" pugs-mode-syntax-table)
(modify-syntax-entry ?* ". 23" pugs-mode-syntax-table)
(modify-syntax-entry ?\n "> b" pugs-mode-syntax-table)
(local-set-key (kbd "C-c C-c") 'pugs-run-file)
)
(provide 'pugs-mode)
;;; (provide 'pugs-mode)
;;; pugs.el ends here
# -*- mode: snippet -*-
# name: #ifndef XXX; #define XXX; #endif
# key: ONCE
# --
#ifndef ${1:`(let ((case-fold-search nil)) (concat (upcase (replace-regexp-in-string "\\([A-Z][a-z]*\\)" "\\1_" (file-name-nondirectory (file-name-sans-extension (or (buffer-file-name) ""))))) "HPP"))`}
#define $1
$0
#endif // $1
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment