From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jean Louis Newsgroups: gmane.emacs.help Subject: Re: Constructing code template systems Date: Wed, 19 Oct 2022 07:12:36 +0300 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="31486"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mutt/2.2.7+37 (a90f69b) (2022-09-02) Cc: John Haman , help-gnu-emacs@gnu.org To: Heime Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Wed Oct 19 06:14:41 2022 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ol0TX-0007w1-FT for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 19 Oct 2022 06:14:39 +0200 Original-Received: from localhost ([::1]:47204 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ol0TV-0001v1-VF for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 19 Oct 2022 00:14:37 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56834) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ol0SZ-0001ut-T8 for help-gnu-emacs@gnu.org; Wed, 19 Oct 2022 00:13:39 -0400 Original-Received: from stw1.rcdrun.com ([217.170.207.13]:50851) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ol0SU-0006AB-Mw for help-gnu-emacs@gnu.org; Wed, 19 Oct 2022 00:13:36 -0400 Original-Received: from localhost ([::ffff:154.231.222.81]) (AUTH: PLAIN admin, TLS: TLS1.3,256bits,ECDHE_RSA_AES_256_GCM_SHA384) by stw1.rcdrun.com with ESMTPSA id 0000000000056229.00000000634F794B.00002334; Tue, 18 Oct 2022 21:12:57 -0700 Mail-Followup-To: Heime , John Haman , help-gnu-emacs@gnu.org Content-Disposition: inline In-Reply-To: Received-SPF: pass client-ip=217.170.207.13; envelope-from=bugs@gnu.support; helo=stw1.rcdrun.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:140144 Archived-At: * Heime [2022-10-19 04:00]: > ------- Original Message ------- > On Wednesday, October 19th, 2022 at 12:17 AM, John Haman 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/