all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Jean Louis <bugs@gnu.support>
To: Heime <heimeborgia@protonmail.com>
Cc: John Haman <mail@johnhaman.org>, help-gnu-emacs@gnu.org
Subject: Re: Constructing code template systems
Date: Wed, 19 Oct 2022 07:12:36 +0300	[thread overview]
Message-ID: <Y095NJmiS0CUSERD@protected.localdomain> (raw)
In-Reply-To: <LkVGyVVbEoUBN3zivnILCsDqyE9H_f6aSzQroVwIersb9qYi2rNmkGauMVBF29QHexAa-RAVkh9_S5eXjh0gnYvaJpBNHLVV7uW0ZdEFV8w=@protonmail.com>

* Heime <heimeborgia@protonmail.com> [2022-10-19 04:00]:
> ------- Original Message -------
> On Wednesday, October 19th, 2022 at 12:17 AM, John Haman <mail@johnhaman.org> wrote:
> 
> 
> > On 10/17/22 6:36 PM, Heime via Users list for the GNU Emacs text editor
> > wrote:
> > 
> > > code template systems
> > 
> > 
> > Like macros?
> 
> Do not know what emacs calls them.
> 
> Basically rather than writing the following, I just press some text,
> and the section of code gets inserted for me. 
> 
> (:documentation (concat "DECSTR.\n\n" DETAILS))


Evaluate following to get into section explaining about skeletons:

(info "(autotype) Top")




I often use this one:
---------------------


(define-skeleton with-tabulated-id
  "Helper skeleton for `tabulated-list-get-id'"
  nil
  "(defun " (skeleton-read "Function name: ") " (" (skeleton-read "Arguments: " "&optional id") ")
  \"\"
  (interactive)
  (when-tabulated-id \"" (skeleton-read "Table: ") "\"
     ))")


Or I use this one to generate necessary SQL:
--------------------------------------------

(define-skeleton cf-sql-table
    "Prepare the SQL table for Central Files database design."
  nil
  "
-- ------------------------------------------
-- ------------ Table " (setq table (skeleton-read "Table name: ")) "
-- ------------------------------------------
DROP SEQUENCE " table "_id_seq;

CREATE TABLE " table " (
" table "_id INTEGER GENERATED BY DEFAULT AS IDENTITY,
" table "_uuid UUID NOT NULL DEFAULT gen_random_uuid(),
" table "_datecreated TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
" table "_datemodified TIMESTAMP,
" table "_usercreated TEXT NOT NULL DEFAULT current_user,
" table "_usermodified TEXT NOT NULL DEFAULT current_user,
" table "_name TEXT,
" table "_description TEXT,
" table "_ TEXT
);
GRANT ALL ON " table " TO PUBLIC;
DROP VIEW " table "_combo;
CREATE OR REPLACE VIEW " table "_combo AS
SELECT " table "_id AS id,
" table "_name AS TEXT
FROM " table ";
GRANT SELECT ON " table "_combo TO PUBLIC;
COMMENT ON TABLE " table " IS '" (capitalize table) "';
COMMENT ON COLUMN " table "." table "_id IS 'ID';
COMMENT ON COLUMN " table "." table "_uuid IS 'UUID';
COMMENT ON COLUMN " table "." table "_datecreated IS 'Date created';
COMMENT ON COLUMN " table "." table "_datemodified IS 'Date modified';
COMMENT ON COLUMN " table "." table "_usercreated IS 'User created';
COMMENT ON COLUMN " table "." table "_usermodified IS 'User modified';
COMMENT ON COLUMN " table "." table "_name IS 'Name';
COMMENT ON COLUMN " table "." table "_description IS 'Description';
COMMENT ON COLUMN " table "." table "_IS '';

CREATE UNIQUE INDEX " table "_index ON " table " ( " table "_name );

-- INSERT INTO " table " (" table "_name) VALUES ('');
-- INSERT INTO meta_tables VALUES ('" table "', 'hide', '1');

-- Triggers
-- For Date Modified
CREATE TRIGGER " table "_moddatetime
BEFORE UPDATE ON " table "
FOR EACH ROW
EXECUTE PROCEDURE moddatetime(" table "_datemodified);

-- For User Modified
CREATE TRIGGER insert_username_" table "
BEFORE INSERT OR UPDATE ON " table "
FOR EACH ROW
EXECUTE PROCEDURE insert_username(" table "_usermodified);

")



-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



      parent reply	other threads:[~2022-10-19  4:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-17 22:36 Constructing code template systems Heime via Users list for the GNU Emacs text editor
2022-10-19  0:17 ` John Haman
2022-10-19  0:36   ` Emanuel Berg
2022-10-19  0:58   ` Heime
2022-10-19  1:23     ` Emanuel Berg
2022-10-19  4:12     ` Jean Louis [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y095NJmiS0CUSERD@protected.localdomain \
    --to=bugs@gnu.support \
    --cc=heimeborgia@protonmail.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=mail@johnhaman.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.