obvious correction: (auto-insert-mode) ;;; Adds hook to find-files-hook (setq auto-insert-directory "~/.mytemplates/") ;;; Or use custom, *NOTE* Trailing slash important (setq auto-insert-query nil) ;;; If you don't want to be prompted before insertion (define-auto-insert "\.py" "my-python-template.py") (define-auto-insert "\.php" "my-php-template.php") the "#+BEGIN_QUOTE " did not belong to the code that I wanted to quote. 2018-06-08 9:32 GMT+02:00 Joseph Vidal-Rosset : > Hello, > > A solution to my problem was indeed given in this web page > https://www.emacswiki.org/emacs/AutoInsertMode: > > #+BEGIN_QUOTE > (auto-insert-mode) ;;; Adds hook to find-files-hook > (setq auto-insert-directory "~/.mytemplates/") ;;; Or use custom, *NOTE* Trailing slash important > (setq auto-insert-query nil) ;;; If you don't want to be prompted before insertion > (define-auto-insert "\.py" "my-python-template.py") > (define-auto-insert "\.php" "my-php-template.php") > > It should not be too difficult, even for me, to adapt this code that I > just tested. > > Best wishes, > – > Jo. >