#+options: ':t toc:nil num:nil ^:{}
#+startup: content indent
-This file describes changes in =sweep= up to version =0.4.4=.
+This file contains the release notes for =sweep=, an embedding of
+SWI-Prolog in Emacs.
+
+For further details, please consult the manual:
+<https://eshelyaron.com/sweep.html>.
+
+* Version 0.4.6 on 2022-10-01
+
+** Added integration with =auto-insert=
+
+=sweeprolog.el= now extends =auto-insert-alist= with a Prolog module
+template associated with =sweeprolog-mode=. The module template is
+inserted into empty =sweeprolog-buffers= when =auto-insert-mode= is
+enabled.
* New commands in =sweep= version =0.4.0=
** New command =sweeprolog-load-buffer=.
[[https://www.swi-prolog.org/pldoc/man?section=quasiquotations][library(quasi_quotations) in the SWI-Prolog manual]].
-
** Term-based editing and motion commands
:PROPERTIES:
:CUSTOM_ID: term-based-commands
More relevant information about loading code in SWI-Prolog can be
found in [[https://www.swi-prolog.org/pldoc/man?section=consulting][Loading Prolog source files]] in the SWI-Prolog manual.
+** Using templates for creating new modules
+:PROPERTIES:
+:CUSTOM_ID: auto-insert
+:END:
+
+#+CINDEX: auto-insert
+=sweep= integrates with the Emacs =auto-insert= facility to simplify
+creation of new SWI-Prolog modules. =auto-insert= allows for populating
+newly created files with templates defined by the relevant major mode.
+
+=sweep= associates a Prolog module skeleton with =sweeprolog-mode=, the
+skeleton begins with a "file header" multi-line comment which includes
+the name and email address of the user based on the values of
+=user-full-name= and =user-mail-address= respectively. A =module/2=
+directive is placed after the file header, with the module name set to
+the base name of the file. Lastly the skeleton inserts a =PlDoc= module
+comment to be filled with the module's documentation (see [[https://www.swi-prolog.org/pldoc/man?section=sectioncomments][File
+comments in the SWI-Prolog manual]]).
+
+As an example, after inserting the module skeleton, a new Prolog file
+=foo.pl= will have the following contents:
+
+#+begin_src prolog
+ /*
+ Author: John Doe
+ Email: john.doe@example.com
+
+ ,*/
+
+ :- module(foo, []).
+
+ /** <module> foo
+
+ ,*/
+
+#+end_src
+
+#+VINDEX: sweeprolog-module-header-comment-skeleton
+The multi-line comment included above the =module/2= directive can be
+extended by customizing the user option
+=sweeprolog-module-header-comment-skeleton=, which see. This can be
+useful for including e.g. copyright text in the file header.
+
+To open a new Prolog file, use the standard =C-x C-f= (=find-file=) and
+select a location for the new file. In the new =sweeprolog-mode=
+buffer, type =M-x auto-insert= to insert the Prolog module skeleton.
+
+To automatically insert the module skeleton when opening new files in
+=sweeprolog-mode=, enable the minor mode =auto-insert-mode=. For detailed
+information about =auto-insert= and its customization options, see
+[[info:autotype#Autoinserting][Autoinserting in the Autotyping manual]].
+
+
* The Prolog top-level
:PROPERTIES:
:CUSTOM_ID: prolog-top-level
;; Maintainer: Eshel Yaron <~eshel/dev@lists.sr.ht>
;; Keywords: prolog languages extensions
;; URL: https://git.sr.ht/~eshel/sweep
-;; Package-Version: 0.4.5
+;; Package-Version: 0.4.6
;; Package-Requires: ((emacs "28"))
;; This file is NOT part of GNU Emacs.
(require 'comint)
(require 'xref)
+(require 'autoinsert)
(defgroup sweeprolog nil
"SWI-Prolog Embedded in Emacs."
:group 'prolog)
+(defcustom sweeprolog-module-header-comment-skeleton ?\n
+ "Additional content for the topmost comment in module headers.
+
+The SWI-Prolog module header inserted by \\[auto-insert] includes
+a multiline comment at the very start of the buffer which
+contains the name and mail address of the author based on the
+user options `user-full-name' and `user-mail-address'
+respectively, followed by the value of this variable, is
+interpreted as a skeleton (see `skeleton-insert'). In its
+simplest form, this may be a string or a character.
+
+This user option may be useful, for example, to include copyright
+notices with the module header."
+ :package-version '((sweeprolog . "0.4.6"))
+ :type 'any
+ :group 'sweeprolog)
+
(defcustom sweeprolog-indent-offset 4
"Number of columns to indent lines with in `sweeprolog-mode' buffers."
:package-version '((sweeprolog . "0.3.1"))
[ "Find Prolog module" sweeprolog-find-module t ]
[ "Find Prolog predicate" sweeprolog-find-predicate t ]
[ "Open top-level" sweeprolog-top-level t ]
+ [ "Insert module template"
+ auto-insert
+ (eq major-mode 'sweeprolog-mode) ]
"--"
[ "Reset sweep" sweeprolog-restart t ]
[ "View sweep messages" sweeprolog-view-messages t ]))
(when sweeprolog-enable-cursor-sensor
(cursor-sensor-mode 1)))
+(add-to-list 'auto-insert-alist
+ '((sweeprolog-mode . "SWI-Prolog module header")
+ (or (and (buffer-file-name)
+ (file-name-sans-extension (file-name-base (buffer-file-name))))
+ (read-string "Module name: "))
+ "/*"
+ "\n Author: "
+ (progn user-full-name)
+ "\n Email: "
+ (progn user-mail-address)
+ (progn sweeprolog-module-header-comment-skeleton)
+ "\n*/"
+ "\n\n:- module("
+ str
+ ", [])."
+ "\n\n/** <module> "
+ str
+ "\n\n*/\n\n"))
(provide 'sweeprolog)