emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

add LSE style tokens/placeholders to skeleton


From: Stephen Leake
Subject: add LSE style tokens/placeholders to skeleton
Date: Tue, 29 Oct 2019 16:08:57 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (windows-nt)

Emacs ada-mode provides an LSE (1) style token/placeholder extension to
skeleton.el; I'm proposing that it be added to skeleton.el.

The code is attached; wisi-skel.el defines wisi-skel-expand and
ancilliary functions, ada-skel.el provides templates for Ada, and the
token alist/menu. Note that this is from my development branch; in
current Gnu ELPA ada-mode, wisi-skel-expand is ada-skel-expand.

A brief explanation of how it works:

In an Ada buffer, the user types 'if' C-c C-e. That expands to:

if  then
elsif  then
else
end if;

which is the Ada skeleton for an "if then else" statement.

In this case, "if" is a "token"; a keyword that wisi-skel-hippie-try
recognizes.

A more complex example: type "separate" C-c C-e. That expands to:

separate ()
{proper_body}

Here, "{proper_body}" is a "placeholder". It has generic comment syntax,
and the Ada parser treats it as a comment. It can be expanded in turn;
place point after it, type C-c C-e. it first prompts for another
keyword, with completion; pick 'function'. That expands to:

separate (foo)
function  return 
is
begin
end ;

A final example: type "package Example" C-c C-e. That prompts for spec
or body; pick spec. It exands to:

package Example is
private
end Example;

Note that it treats "Example" as a name, and provides the duplicate
after "end" that Ada allows.

In the original LSE, the entire Ada language was provided as
placeholders; you could write entire programs using placeholder
expansion. The system provided here is not so ambitious; it is designed
to quickly insert basic statements that the Ada parser handles with no
syntax errors, and to easily handle the duplicate names.


-- 
-- Stephe

(1) LSE is the old Digital Equipment Corporation Language Sensitive
Editor, which went much further in this direction (and what I was using
when I first learned Ada).

Attachment: wisi-skel.el
Description: application/emacs-lisp

Attachment: ada-skel.el
Description: application/emacs-lisp


reply via email to

[Prev in Thread] Current Thread [Next in Thread]