diff options
author | David Aspinall <da@inf.ed.ac.uk> | 2012-08-14 10:37:25 +0000 |
---|---|---|
committer | David Aspinall <da@inf.ed.ac.uk> | 2012-08-14 10:37:25 +0000 |
commit | caf7542b618ef6e39853613733c5aa7d4607f224 (patch) | |
tree | b130d13cc2d5fe9cb6749cba24eebc1576344c41 /generic | |
parent | cdacdc30c3708e1a824ada65584f6d6a5a4bc03d (diff) |
Add user option proof-next-command-insert-space.
Diffstat (limited to 'generic')
-rw-r--r-- | generic/pg-user.el | 42 | ||||
-rw-r--r-- | generic/proof-useropts.el | 8 |
2 files changed, 30 insertions, 20 deletions
diff --git a/generic/pg-user.el b/generic/pg-user.el index 3ff06579..10e27da9 100644 --- a/generic/pg-user.el +++ b/generic/pg-user.el @@ -41,27 +41,29 @@ ;;;###autoload (defun proof-script-new-command-advance () - "Move point to a nice position for a new command. -Assumes that point is at the end of a command." + "Move point to a nice position for a new command, possibly inserting spaces. +Assumes that point is at the end of a command. +No effect if `proof-next-command-insert-space' is nil." (interactive) - (let (sps) - (if (and (proof-next-command-new-line) - (setq sps (skip-chars-forward " \t")) - ;; don't break existing lines - (eolp)) - (progn (newline) - (unless proof-next-command-on-new-line - (indent-relative)))) - (unless (proof-next-command-new-line) - ;; Multiple commands per line: skip spaces at point, and insert - ;; the 1/0 number of spaces that were skipped in front of point - ;; (at least one). This has the pleasing effect that the spacing - ;; policy of the current line is copied: e.g. <command>; - ;; <command>; Tab columns don't work properly, however. - (let ((newspace (max (or sps 1) (skip-chars-forward " \t"))) - (p (point))) - (insert-char ?\040 newspace) - (goto-char p))))) + (when proof-next-command-insert-space + (let (sps) + (if (and (proof-next-command-new-line) + (setq sps (skip-chars-forward " \t")) + ;; don't break existing lines + (eolp)) + (progn (newline) + (unless proof-next-command-on-new-line + (indent-relative)))) + (unless (proof-next-command-new-line) + ;; Multiple commands per line: skip spaces at point, and insert + ;; the 1/0 number of spaces that were skipped in front of point + ;; (at least one). This has the pleasing effect that the spacing + ;; policy of the current line is copied: e.g. <command>; + ;; <command>; Tab columns don't work properly, however. + (let ((newspace (max (or sps 1) (skip-chars-forward " \t"))) + (p (point))) + (insert-char ?\040 newspace) + (goto-char p)))))) (defun proof-maybe-follow-locked-end (&optional pos) diff --git a/generic/proof-useropts.el b/generic/proof-useropts.el index d228016c..0a7d8bfe 100644 --- a/generic/proof-useropts.el +++ b/generic/proof-useropts.el @@ -71,6 +71,14 @@ terminator somewhere nearby. Electric!" :set 'proof-set-value :group 'proof-user-options) +(defcustom proof-next-command-insert-space t + "*If non-nil, PG will use heuristics to insert newlines or spaces in scripts. +In particular, if electric terminator is switched on, spaces or newlines will +be inserted as the user types commands to the prover." + :type 'boolean + :set 'proof-set-value + :group 'proof-user-options) + (defcustom proof-toolbar-enable t "*If non-nil, display Proof General toolbar for script buffers." :type 'boolean |