; Macros for editing Perl scripts that generate the IC WWW pages ; Created by Jorge Stolfi on 96-06-26 ; Last edited on 2019-08-26 13:39:10 by stolfilocal (defvar plw-keymap nil "Keymap used in Perl-WWW mode.") (if plw-keymap () (let ((map (make-sparse-keymap))) ; (define-key map "\C-c\C-c" 'plw-run-make) (define-key map "\C-c\C-a" 'plw-compile) (define-key map "\C-c\C-t" 'plw-get-alt-file) ; (define-key map "\C-c`" 'next-error) ; also (usually) on "\C-x`" (setq plw-keymap map) ) ) (defun perl-www-mode () "This is a mode for editing Perl scripts that generate the IC HTML files. \\{plw-keymap}." (interactive) (kill-all-local-variables) ; (setq debug-on-error t) ; DEBUG (use-local-map plw-keymap) (setq major-mode 'perl-www-mode) (setq mode-name "Perl-WWW") (setq indent-tabs-mode nil) (make-local-variable 'require-final-newline) (setq require-final-newline t) (make-local-variable 'comment-start) (setq comment-start "# ") (make-local-variable 'comment-end) (setq comment-end "") (make-local-variable 'comment-column) (setq comment-column 1) (make-local-variable 'comment-start-skip) (setq comment-start-skip "\\*+ *") (make-local-variable 'comment-indent-hook) (setq comment-indent-hook 'c-comment-indent) (make-local-variable 'parse-sexp-ignore-comments) (setq parse-sexp-ignore-comments t) ; Do not delete time stamps, update them: (stolfi-time-stamp-buffer-setup t nil nil t "^[ #]*last_edited *( *" "\"%04y-%02m-%02d %02H:%02M:%02S\", \"%u\"" ") *; *$" "last_edited(\"DATE TIME\", \"USER\"" ) (run-hooks 'perl-www-mode-hook) ) (defvar plw-compile-command "cd .. && ${STOLFIHOME}/sites/tools/run-perl-on-page ${STOLFIHOME}/sites/tools source temp new %s" "Command to compile the .pl file in the current buffer") (defun plw-compile() "Compiles the .pl file in the current buffer" (interactive) (let ( ( pagename (file-name-sans-extension (file-name-nondirectory (buffer-file-name))) ) ) (compile (format plw-compile-command pagename)) ) ) (defun plw-get-alt-file() "Visit the file in the alternate language, switching -e/-p in name." (interactive) (let* ( ( this-file (buffer-file-name) ) ( that-file (cond ( (string-equal (substring this-file -5) "-e.pl") (concat (substring this-file 0 -5) "-p.pl")) ( (string-equal (substring this-file -5) "-p.pl") (concat (substring this-file 0 -5) "-e.pl")) (t nil) ) ) ) (if that-file (find-file-other-window that-file) (error "cannot guess the other file's name") ) ) )